Commit graph

460 commits

Author SHA1 Message Date
overlookmotel
cba93f52d0 feat(ast)!: add ThisExpression variants to JSXElementName and JSXMemberExpressionObject (#5466)
Close #5352.

Add to AST:

* `JSXElementName::ThisExpression` (`<this>`)
* `JSXMemberExpressionObject::ThisExpression` (`<this.foo>`, `<this.foo.bar>`)
2024-09-05 02:06:20 +00:00
Boshen
10279f55d9 feat(parser): add syntax error for hyphen in JSXMemberExpression <Foo.bar-baz /> (#5440)
closes #5355
2024-09-04 14:09:06 +00:00
overlookmotel
d9d7e7c596 refactor(ast): remove IdentifierName from TSThisParameter (#5327)
`TSThisParameter` does not need to include an `IdentifierName` which is always "this". Just storing the `Span` is sufficient.
2024-09-04 12:46:53 +00:00
rzvxa
59abf27d95 feat(ast, parser): add oxc_regular_expression types to the parser and AST. (#5256)
closes #5060
2024-09-03 02:36:37 +00:00
Dunqing
1aa49af010 feat(ast)!: remove JSXMemberExpressionObject::Identifier variant (#5358)
close: #5353

`JSXMemberExpressionObject::Identifier` is dead code.
2024-09-02 18:35:39 +00:00
_lmmmmmm
3864eb42ce
chore: typo fix (#5380)
fixed #5379
Fix typos so `just ready` works
2024-09-01 15:10:40 +08:00
overlookmotel
d236554512 refactor(parser): move JSXIdentifier conversion code into parser (#5345)
Outside of the parser, a `JSXIdentifier` in a `JSXElementName::Identifier` will never be a identifier reference. So move the code for deciding if a `JSXElementName` is `JSXElementName::Identifier` or `JSXElementName::IdentifierReference`, and the code for converting from one to the other, into the parser - which is only place it should be used.
2024-08-30 14:47:09 +00:00
Dunqing
32f730085c feat(ast)!: add JSXElementName::IdentifierReference and JSXMemberExpressionObject::IdentifierReference (#5223)
close: #3528

part of #4746
2024-08-30 11:11:04 +00:00
Boshen
70091771b6
test(parser): fix incorrect flow error test 2024-08-28 20:53:32 +08:00
Boshen
fb75d2576b
Revert "fix(parser): Revert "check for @flow with recoverable errors as well" (#5297)"
This reverts commit d4c06ef093.
2024-08-28 20:53:13 +08:00
overlookmotel
d4c06ef093 fix(parser): Revert "check for @flow with recoverable errors as well" (#5297)
e1d8b92080 caused CI to fail. Revert it.
2024-08-28 12:48:37 +00:00
Boshen
e1d8b92080
fix(parser): check for @flow with recoverable errors as well 2024-08-28 19:39:07 +08:00
Dunqing
550574982f feat(ast): add accessibility field to AccessorProperty (#5290) 2024-08-28 08:42:37 +00:00
Kevin Deng 三咲智子
234a24c14d
fix(ast)!: merge UsingDeclaration into VariableDeclaration (#5270)
relate #2854
2024-08-28 11:26:05 +08:00
Boshen
e6fd52e2a6 fix(parser): change unterminated regex error to be non-recoverable (#5285)
closes #5257
2024-08-28 01:57:31 +00:00
overlookmotel
bc59dd2b29 refactor(parser): improve example for byte_search! macro usage (#5234)
It's more efficient when reading 2 bytes to use `read2()` than 2 x `read()` calls. Reflect that in example for using `byte_search!` macro.
2024-08-26 14:22:37 +00:00
overlookmotel
a3ddfdd9d7 refactor(parser): improve lexer pointer maths (#5233)
Small tweaks to pointer maths in lexer which may result in slightly more compact assembly.
2024-08-26 14:22:36 +00:00
leaysgur
1686920e23 fix(parser): Span for invalid regex flags (#5225)
### Before
```
  x Flag u is mentioned twice in regular expression literal
   ,-[1:20]
 1 | const a = /\2(.)/uuxig;
   :                    ^
 2 | debugger;
   `----

  x Unexpected flag x in regular expression literal
   ,-[1:21]
 1 | const a = /\2(.)/uuxig;
   :                     ^
 2 | debugger;
   `----
```

### After
```
  x Flag u is mentioned twice in regular expression literal
   ,-[1:19]
 1 | const a = /\2(.)/uuxig;
   :                   ^
 2 | debugger;
   `----

  x Unexpected flag x in regular expression literal
   ,-[1:20]
 1 | const a = /\2(.)/uuxig;
   :                    ^
 2 | debugger;
   `----
```
2024-08-26 10:24:47 +00:00
DonIsaac
49cd5db54f feat(ast,parser): add definite flag to AccessorProperty node (#5182) 2024-08-25 01:02:50 +00:00
DonIsaac
7dfd51a62b feat(parser): report class properties that are both definite and optional (#5181) 2024-08-25 01:02:49 +00:00
DonIsaac
a563968386 feat(parser): report errors on optional accessor properties (#5180) 2024-08-25 01:02:49 +00:00
DonIsaac
c2fa72571f feat(ast,parser): parse TSTypeAnnotations on AccessorProperty (#5179)
Closes #5177

While making this, I noticed an uncaught parse error for accessors: accessors cannot be optional. I'll add a fix for this in an up-stack PR.
2024-08-25 01:02:48 +00:00
Boshen
efbdced597 fix(parser): only show flow error if it's a flow file (#5069)
Otherwise we get a mixture of confusing error messages.
2024-08-22 12:19:45 +00:00
Boshen
afe728a73a feat(parser): parse regular expression with regex parser (#4998)
Many false positives and incorrect errors. @leaysgur Enjoy 😁

Run `just conformance` to update the snapshot.
2024-08-22 03:09:55 +00:00
overlookmotel
ca70cc7c03 refactor(linter, mangler, parser, semantic, transformer, traverse, wasm): rename various flag vars to flags (#5028)
Part of #4991.
2024-08-21 00:19:58 +00:00
Boshen
b2ff2df5af refactor(parser)!: remove builder pattern from Parser struct (#5000)
part of #4455

use `with_options(ParseOptions { ..ParseOptions::default() })` API instead.
2024-08-20 07:40:25 +00:00
Burlin
f88970bc79
refactor(ast)!: Change order of fields in CallExpression (#4859)
fix: #4821

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-08-20 09:47:12 +08:00
Boshen
6800e694e3
feat(oxc): add Compiler and CompilerInterface (#4954)
This PR adds a full compiler pipeline to the `oxc` crate, to stop us
from implementing the same pipeline over and over again.

relates #4455
2024-08-19 10:20:05 +08:00
rzvxa
c164bb8b64 chore(deps): remove static_assertions dependency. (#4883) 2024-08-14 02:18:06 +00:00
Boshen
1bdde2c117 fix(parser): detect @flow in `/** @flow */ comment (#4861)
Discovered in https://github.com/oxc-project/monitor-oxc

There are files with

```
/**
 * @flow
 */
```

https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__mocks__/JSXAttributeMock.js#L1

So I changed the logic to checking the first comment instead.
2024-08-13 05:43:48 +00:00
Boshen
559baa5602
docs(parser): clean up doc regarding performance; remove conformance
conformance is removed due to needing to keep it updated.
2024-08-12 14:02:09 +08:00
Boshen
a40a217de4 fix(parser): parse assert keyword in TSImportAttributes (#4610)
closes #4601
2024-08-04 01:41:31 +00:00
rzvxa
d25dea7b94 refactor(parser): use ast_builder in more places. (#4612) 2024-08-02 22:38:06 +00:00
overlookmotel
55a8763d6e perf(parser): faster decoding unicode escapes in identifiers (#4579)
Replace `next_char` and `peek_char` with `peek_byte` when decoding unicode escape sequences in identifiers.
2024-07-31 03:33:08 +00:00
overlookmotel
ae1d38f60d perf(parser): fast path for ASCII when checking char after numeric literal (#4577)
Make a fast path for ASCII characters when lexer checks for invalid chars after a numeric literal. Also shorten the check for ASCII chars.
2024-07-31 03:33:05 +00:00
overlookmotel
56ae615b6e perf(parser): make not at EOF the hot path in Source methods (#4576)
Reverse `if` arms in 2 very commonly-called methods in `Source` so that "not at EOF" is the first branch. This will encourage compiler to treat EOF as the cold branch (which it should be, as we're almost never at EOF).
2024-07-31 03:33:02 +00:00
overlookmotel
e68ed628b8 refactor(parser): convert lexer byte handler for | to a single match (#4575)
Same as #4573 and #4574. Convert lexer's byte handler for `|` to a single match rather than multiple `next_ascii_byte_eq` calls.
2024-07-31 03:33:00 +00:00
overlookmotel
bba824bc34 refactor(parser): convert Lexer::read_minus to a single match (#4574)
Same as #4573. Convert `Lexer::read_minus` to a single match rather than multiple `next_ascii_byte_eq` calls.
2024-07-31 03:32:57 +00:00
overlookmotel
ef5418a917 refactor(parser): convert Lexer::read_left_angle to a single match (#4573)
`Lexer::read_left_angle` was a series of disparate `next_ascii_byte_eq` and `peek_byte` calls. Convert it to a single match on `peek_byte`. This I think will remove a couple of bounds checks.
2024-07-31 03:32:54 +00:00
overlookmotel
25679e6277 perf(parser): optimize Lexer::hex_digit (#4572)
Optimize `Lexer::hex_digit`.

Rather than checking for `A-F` and `a-f` separately, can check for them both in one go. `b'A' | 32 == b'a'` (and same for all other alphabetic letters) so matching against `b | 32` allows checking for all matching letters, lower or upper case, in one operation.
2024-07-31 03:32:52 +00:00
overlookmotel
bb33bcce35 perf(parser): speed up lexing non-decimal numbers (#4571)
Inline `Lexer::read_non_decimal` to reduce branching.
2024-07-31 00:29:00 +00:00
overlookmotel
9e5be78af5 refactor(parser): add Lexer::consume_2_chars (#4569)
Add `Lexer::consume_2_chars` to replace `lexer.consume_char(); lexer.consume_char();`. Mostly this is just neater code, but *may* also help compiler to elide bounds checks when it's preceded by `lexer.peek_2_bytes()`.
2024-07-31 00:28:58 +00:00
overlookmotel
649913e6cd refactor(parser): extract u8 not &u8 when iterating over bytes (#4568)
Iterating over `str.as_bytes()` produces `&u8`s. Dereference to `u8` in `for` statement. Should make no difference to generated assembly, purely making this change for neater code style.
2024-07-31 00:28:57 +00:00
overlookmotel
59f00c0a44 refactor(parser): rename function (#4566)
Rename `matches_number_char` function to `matches_number_byte` as it takes a `u8` byte, not a `char`.
2024-07-31 00:28:55 +00:00
overlookmotel
8e3e9104e5 refactor(parser): rename vars (#4565)
Use `b` everywhere in lexer for a `u8` byte, keeping the name `c` for a vars containing a `char`.
2024-07-31 00:28:53 +00:00
overlookmotel
0c0601f9a4 refactor(parser): rename function (#4564)
Rename `Lexer::next_ascii_char_eq` to `next_ascii_byte_eq`, for consistency with other method names which operate on bytes.
2024-07-31 00:28:51 +00:00
overlookmotel
0acc4a726e refactor(parser): fetch 2 bytes in ? byte handler (#4563)
Lexer's `?` byte handler needs to fetch next 2 bytes, so do that in one shot, rather than bounds-checking twice.
2024-07-31 00:28:50 +00:00
overlookmotel
565eccf631 refactor(parser): shorten lexer code (#4562)
Use `lexer.peek_byte()` instead of `lexer.source.peek_byte()`.
2024-07-31 00:28:48 +00:00
overlookmotel
ab8509edaa perf(parser): use - not saturating_sub (#4561)
Follow-on after #4304. Avoid using `saturating_sub` when plain `-` will do. `-` is cheaper - it's a single assembly instruction, whereas `saturating_sub` is usually 3 instructions.

https://godbolt.org/z/fo8Tcx6bK
2024-07-31 00:28:46 +00:00
lucab
c9c38a187c perf(parser): support peeking over bytes (#4304)
Closes https://github.com/oxc-project/oxc/issues/3291
2024-07-30 17:53:13 +00:00