oxc/crates
leaysgur f8e1907c4f feat(regular_expression): Intro ConstructorParser(and LiteralParser) to handle escape sequence in RegExp('pat') (#6635)
Preparation for #6141

`oxc_regular_expression` can already parse and validate both `/regexp-literal/` and `new RegExp("string-literal")`.

But one thing that is not well-supported was reporting `Span` for the `RegExp("string-literal-with-\\escape")` case.

For example, these two cases produce the same `RegExp` instances in JavaScript:

- `/\d+/`
- `new RegExp("\\d+")`

For now, mainly in `oxc_linter`, the latter case is parsed with `oxc_parser` -> `ast::literal::StringLiteral` AST node -> `value` property.

At this point, escape sequences are resolved(!), `oxc_regular_expression` can handle aligned `&str` as an argument without any problem in both cases.

However, in terms of `Span` representation, these cases should be handled differently because of the `\\` in string literals...

As a result, the parsed AST's `Span` for `new RegExp("string-literal")` is not accurate if it contains escape sequences.

e.g. a01a5dfdaf/crates/oxc_linter/src/snapshots/no_invalid_regexp.snap (L118-L122)

Each time the `\` appears, the subsequent position is shifted. `_` should be placed under `*` in this case.

So... to resolve this issue, we need to implement `string_literal_parser` first, and use them as reading units of `oxc_regular_expression`.
2024-10-21 07:07:27 +00:00
..
oxc release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_allocator fix(allocator)!: make Vec non-drop (#6623) 2024-10-19 15:43:54 +00:00
oxc_ast docs(ast): enforce doc comments on AST node methods (#6714) 2024-10-21 05:28:55 +00:00
oxc_ast_macros release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_cfg release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_codegen docs(codegen): add #![warn(missing_docs)] to oxc_codegen (#6711) 2024-10-21 00:13:57 +00:00
oxc_data_structures release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_diagnostics release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_ecmascript refactor(minifier): binary operations use ConstantEvaluation (#6700) 2024-10-20 15:13:27 +00:00
oxc_estree release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_index release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_isolated_declarations refactor(isolated-declarations): protect internal transform methods (#6723) 2024-10-21 02:03:33 +00:00
oxc_language_server refactor(oxc): remove useless allocator.alloc(program) calls (#6571) 2024-10-15 02:21:20 +00:00
oxc_linter release(oxlint): v0.10.1 (#6729) 2024-10-21 12:29:57 +08:00
oxc_macros refactor(linter): add run_on_jest_node to run rules on only jest nodes (#6721) 2024-10-21 02:13:58 +00:00
oxc_mangler release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_minifier refactor(minifier): binary operations use ConstantEvaluation (#6700) 2024-10-20 15:13:27 +00:00
oxc_module_lexer release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_parser release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_prettier fix(allocator)!: make Vec non-drop (#6623) 2024-10-19 15:43:54 +00:00
oxc_regular_expression feat(regular_expression): Intro ConstructorParser(and LiteralParser) to handle escape sequence in RegExp('pat') (#6635) 2024-10-21 07:07:27 +00:00
oxc_semantic release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_sourcemap release(crates): v0.32.0 (#6691) 2024-10-19 23:09:35 +08:00
oxc_span test(span): add Span::is_empty unit tests (#6706) 2024-10-20 15:39:14 -04:00
oxc_syntax refactor(ast_tools): add line breaks to generated code for ESTree derive (#6680) 2024-10-19 19:50:13 +00:00
oxc_transformer refactor(ast): change plain_function to accept FunctionBody as a required parameter (#6709) 2024-10-21 03:03:33 +00:00
oxc_traverse refactor(traverse): change generate_uid_in_based_on_node to accept a generic type parameter as node type (#6708) 2024-10-21 03:03:32 +00:00
oxc_wasm chore(semantic, wasm): re-order dependencies in Cargo.toml files (#6657) 2024-10-18 13:40:37 +00:00