Huáng Jùnliàng
7250d2562b
Simplifiy tracking of valid JSX positions ( #13891 )
...
Remove `state.inPropertyName` and simplifies `state.canStartJSXElement` tracking
2021-11-04 17:12:42 +01:00
Huáng Jùnliàng
1fa759f989
refactor: extract tt.lt and tt.gt from tt.relation ( #13892 )
2021-11-01 21:15:42 -04:00
Huáng Jùnliàng
872086a9a0
feat: support startColumn option ( #13887 )
2021-10-29 01:20:32 +02:00
J. S. Choi
ad59a2c618
Caret topic (pipe operator) ( #13749 )
...
* parser: Add caret as topic reference (tests)
* parser: Add caret as topic reference (implement)
* generator: Avoid reconstructing validTopicTokenSet
* babel-parser: Remove redundant throws in expression.js
* Minimize diff
* Update error message
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-10-28 16:04:55 -04:00
Huáng Jùnliàng
178d43ff17
Tokenize keywords-like identifier as new tokens ( #13769 )
...
* refactor: add more identifier token helpers
* refactor: explode tt.name into multiple tokens
* fix: disallow escape in interface keyword
* refactor: simplify isMaybeDefaultImport
* review comments
* refactor: avoid string comparison
2021-09-23 10:54:44 -04:00
Huáng Jùnliàng
d2076a531f
Store token type as number ( #13768 )
...
* refactor: abstract token metadata access
* refactor: move token-specific update context logic
* refactor: centralize token definitions
* refactor: abstract token type creation
* refactor: use number as token storage
* build: replace tt.* as number
* fix flow errors
* fix: build on Node 12
* Update packages/babel-parser/src/tokenizer/types.js
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* refactor: rename token types exports to tt
* update unit test
* test: update Babel 8 test fixtures
* fix: centralize obsolete token type updateContext
* fix flow errors
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-09-17 09:36:11 -04:00
Mickey Rose
da1d166ea6
perf: minor tokenizer tweaks ( #13652 )
2021-08-09 21:20:44 +02:00
Huáng Jùnliàng
d5b0d9e33d
Add attachComment parser option to disable comment attachment ( #13229 )
2021-08-04 17:04:22 +02:00
Nicolò Ribaudo
ff287ac5a5
Fix %== parsing in hack pipes ( #13536 )
...
* Fix `%==` parsing in hack pipes
* Use custom token type
* Update packages/babel-parser/src/parser/expression.js
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
* Apply suggestions from code review
Co-authored-by: J. S. Choi <jschoi@jschoi.org>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: J. S. Choi <jschoi@jschoi.org>
2021-08-03 23:30:16 +02:00
J. S. Choi
35e4e1f067
Hack-pipe proposal with % topic token ( #13416 )
...
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
2021-08-03 23:30:16 +02:00
J. S. Choi
6276853eb9
Add support for the "Hack" pipeline proposal ( #13191 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-08-03 23:30:16 +02:00
overlookmotel
dd942f92af
fix: parser strictMode option ( #13548 )
2021-07-20 10:42:04 -04:00
Huáng Jùnliàng
79d3276f61
Overhaul comment attachment ( #13521 )
...
* refactor: inline pushComment
* chore: add benchmark cases
* perf: overhaul comment attachment
* cleanup
* update test fixtures
They are all bugfixes.
* fix: merge HTMLComment parsing to skipSpace
* perf: remove unattachedCommentStack
baseline 128 nested leading comments: 11_034 ops/sec ±50.64% (0.091ms)
baseline 256 nested leading comments: 6_037 ops/sec ±11.46% (0.166ms)
baseline 512 nested leading comments: 3_077 ops/sec ±2.31% (0.325ms)
baseline 1024 nested leading comments: 1_374 ops/sec ±3.22% (0.728ms)
current 128 nested leading comments: 11_027 ops/sec ±37.41% (0.091ms)
current 256 nested leading comments: 6_736 ops/sec ±1.39% (0.148ms)
current 512 nested leading comments: 3_306 ops/sec ±0.69% (0.302ms)
current 1024 nested leading comments: 1_579 ops/sec ±2.09% (0.633ms)
baseline 128 nested trailing comments: 10_073 ops/sec ±42.95% (0.099ms)
baseline 256 nested trailing comments: 6_294 ops/sec ±2.19% (0.159ms)
baseline 512 nested trailing comments: 3_041 ops/sec ±0.8% (0.329ms)
baseline 1024 nested trailing comments: 1_530 ops/sec ±1.18% (0.654ms)
current 128 nested trailing comments: 11_461 ops/sec ±44.89% (0.087ms)
current 256 nested trailing comments: 7_212 ops/sec ±1.6% (0.139ms)
current 512 nested trailing comments: 3_403 ops/sec ±1% (0.294ms)
current 1024 nested trailing comments: 1_539 ops/sec ±1.49% (0.65ms)
* fix: do not expose CommentWhitespace type
* add comments on CommentWhitespace
* add test case for #11576
* fix: mark containerNode be the innermost node containing commentWS
* fix: adjust trailing comma comments for Record/Tuple/OptionalCall
* fix: drain comment stacks in parseExpression
* docs: update comments
* add a new benchmark
* chore: containerNode => containingNode
* add more benchmark cases
* fix: avoid finishNodeAt in stmtToDirective
* finalize comment right after containerNode is set
* add testcase about directive
* fix: finish SequenceExpression at current pos and adjust later
* chore: rename test cases
* add new test case on switch statement
* fix: adjust comments after trailing comma of function params
* add comment attachment design doc
* misc fix
* fix: reset previous trailing comments when parsing async method/accessor
* chore: add more comment testcases
* fix flow errors
* fix: handle comments when parsing async arrow
* fix: handle comments when "static" is a class modifier
* fix flow errors
* fix: handle comments when parsing async function/do
* refactor: simplify resetPreviousNodeTrailingComments
* update test fixtures
2021-07-07 11:51:40 -04:00
Huáng Jùnliàng
5145c98a73
Simplify token context ( #13450 )
...
* refactor: unify tc.brace and tc.templateQuasi
* refactor: remove unused context check
* perf: reduce arrayPrototype call and hoist variables
2021-06-21 10:51:00 -04:00
Huáng Jùnliàng
6c8b2336f6
Faster readRegexp ( #13453 )
2021-06-10 19:00:21 -04:00
Huáng Jùnliàng
d3f4c22c28
update test fixtures ( #13440 )
...
* update test fixtures
* chore: typo
2021-06-09 11:48:29 -04:00
Huáng Jùnliàng
b9c1884a58
Reduce exprAllowed usage ( #13431 )
2021-06-09 16:36:09 +02:00
Federico Ciardi
a64d08c101
fix(parser): correctly parse record and tuple tokens ( #13418 )
...
* fix(parser): correctly parse token location for `#{` and `#[`
* fix: `bar` tokens
* fix: don't parse record and tuple pipe closing tokens as operators
2021-06-08 20:58:48 -04:00
Eyoatam Tamirat
56db172b0e
fix(@babel/parser): fix tokenizer context update code ( #13422 )
...
* fix(`@babel/parser`): fix `_function` update code
* fmt
2021-06-08 08:26:50 -04:00
Huáng Jùnliàng
ae3f5d905a
Back parser state exportedIdentifiers by set ( #13406 )
2021-06-01 07:17:30 -04:00
Yosuke Ota
0b29b5c2c0
Add support for d flag of regex literals in parser ( #13396 )
2021-05-31 08:34:53 -04:00
Huáng Jùnliàng
acf2a10899
Faster tokenizer lookahead ( #13341 )
...
* refactor: simplify token context structure
* add benchmark
* perf: return a sub-state on tokenizer lookahead
* Update packages/babel-parser/src/tokenizer/index.js
Co-authored-by: Brian Ng <bng412@gmail.com>
* Update packages/babel-parser/src/tokenizer/index.js
Co-authored-by: Brian Ng <bng412@gmail.com>
* remove irrelevant comment
* fix: guard curPosition with isLookahead
* add test cases
Co-authored-by: Brian Ng <bng412@gmail.com>
2021-05-25 21:12:38 -04:00
Huáng Jùnliàng
a8fea4037d
Faster identifier tokenizing ( #13262 )
...
* add benchmark
* perf: faster identifier tokenizing
- Mover iterator identifier parsing to the Flow plugin
- If the character is an identifier start, pass it to readWord1
2021-05-06 18:47:19 -04:00
Huáng Jùnliàng
a387973821
Refactor private name tokenizing ( #13256 )
...
* add benchmark
* refactor: create tt.privateName token for private names
* add backward compat privateName = hash + name to Babel 7
* perf: get private name SV from token value
* chore: tweak benchmark file
* chore: update test fixtures
* convert tt.privateName to PrivateIdentifier
* perf: avoid most isPrivateName call
* Update packages/babel-parser/src/parser/expression.js
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
* perf: use inlinable codePointAtPos
* make prettier happy
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2021-05-06 09:46:09 -04:00
Huáng Jùnliàng
278193b6f7
fix: update chunkStart on missing unicode escape ( #13261 )
2021-05-06 08:31:11 -04:00
Sosuke Suzuki
7f5b212322
babel-parser: Add new typescript plugin option dts: boolean ( #13113 )
2021-04-28 18:24:18 +02:00
Sosuke Suzuki
0ee98139a6
Introduce parser error codes ( #13033 )
2021-04-28 18:21:31 +02:00
Huáng Jùnliàng
108564fdad
refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed ( #12716 )
...
* refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed
* tweak logic
* early exit when errors are before thrown error position
* fix: always return true in assert.throws callback
See https://nodejs.org/api/assert.html#assert_assert_throws_fn_error_message
* update test fixtures
* fix flow error
2021-02-01 10:46:43 -05:00
Sosuke Suzuki
45fdde0ce2
(ts) Throw for abstract methods in a non-abstract class ( #12686 )
2021-01-27 18:56:55 +01:00
Sosuke Suzuki
8fcba6eb55
Raise recoverable error for await expressions in sync functions ( #12520 )
2021-01-24 01:45:27 +01:00
Huáng Jùnliàng
a0c1a9a9e4
Disallow non octal decimal escape before use strict ( #12366 )
2020-12-15 12:24:32 +01:00
Huáng Jùnliàng
a8c66f4680
Handle exprAllowed before ObjectLike is parsed ( #12267 )
...
* fix: disallow expression after `}` is consumed in parseObjectLike
* refactor: avoid accessing this.prodParam in context update
2020-10-27 20:25:50 -04:00
Huáng Jùnliàng
ea2892fefc
add declare to class properties type annotations ( #12257 )
...
* add declare to class properties type annotations
* chore: use preset-flow
2020-10-27 10:05:01 -04:00
Huáng Jùnliàng
2782a549e9
Refactor yield await classification ( #12230 )
...
* fix: incomplete ParamKind declaration
* refactor: add expression scope handler
* test: update test262 allowlist
* chore: cleanup
* fix: push expression scope for function body
* fix: push new expression scope for initializer and static block
* test: add more test cases
* fix flow error
* refactor: remove unecessary expression scope
* fix: parameter initializer error should not cross expression scope boundary
* chore: cleanup outdated comments
* fix: do not record async arrow error on ParameterDeclaration
* Update packages/babel-parser/src/util/expression-scope.js
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* polish: clear ancestry declaration error on validate
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-10-26 11:42:02 -04:00
iamfotx
59d97d9bca
[parser] Better error message for missing number exponent ( #12072 )
...
* fix(babel-parser) better error message for missing number exponent after 'e'
* fix(babel-parser) requested changes
* msg
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-10-14 21:17:38 +02:00
Sosuke Suzuki
ae18f9c0d9
Throw a syntax error for a declare function with a body ( #12054 )
2020-09-19 00:35:37 +02:00
Huáng Jùnliàng
df9ee2c7cd
Simplify tokenizer update context ( #11944 )
...
* replace lineBreak.test by hasPrecedingLingBreak
* refactor: simplify updateContext
2020-08-11 13:43:03 -04:00
Huáng Jùnliàng
3995160fc7
fix: push new token context when braceHashL is seen ( #11941 )
...
* fix: push new token context when braceHashL is seen
* Update packages/babel-parser/src/tokenizer/context.js
2020-08-11 09:55:13 -04:00
Brian Ng
c0f6f0394d
Support ConditionalExpressions in dry-error-messages rule ( #11917 )
...
* Support ConditionalExpressions in dry-error-messages rule
* tests
2020-08-05 16:28:35 -04:00
Huáng Jùnliàng
a1eabb84ea
rescan gt/lt token after TsAsExpression is parsed ( #11912 )
...
* refactor: move inType checks to flow plugin
* polish: replace hardcoded char codes
* fix: rescan greater/less token after asExpression is parsed
2020-08-04 17:00:21 -04:00
Huáng Jùnliàng
0e985fb287
feat: enable numericSeparator parsing support ( #11863 )
2020-07-29 18:32:12 -04:00
Huáng Jùnliàng
059e9124ff
Add decimal parsing support ( #11640 )
...
* docs: add DecimalLiteral to AST spec
* add decimal support
* fix: throw invalid decimal on start
* add DecimalLiteral type definitions
* update parser typings
* add generator support
* add syntax-decimal plugin
* Add syntax-decimal to babel-standalone
* add syntax-decimal to missing plugin helpers
* fix incorrect test macro
2020-07-29 16:43:15 -04:00
Huáng Jùnliàng
2bf38fb914
fix: disallow \8, \9 in strict mode string ( #11852 )
2020-07-21 09:44:56 -04:00
Huáng Jùnliàng
3680f019d7
fix: allow 09.1_1 and 09e1_1 in sloppy mode ( #11854 )
...
* fix: allow 09.1_1 and 09e1_1 in sloppy mode
* polish: avoid extra input source scanning
* chore: move comment [skip ci]
2020-07-21 09:44:28 -04:00
Kai Cataldo
75c2300c28
Add @babel/eslint-plugin-development-internal ( #11376 )
...
* Add @babel/eslint-plugin-internal
* Add dry-error-messages rule
* Address feedback
* Enable new rule
* fix author field
* Fix errors
* Add readme
* Add example configuration
* Handle directories
* run make bootstrap
* More updates!
* Fix errors
* Update tests
* Fix CI race condition
2020-06-22 19:43:29 -04:00
Bogdan Savluk
4108524856
Update prettier to v2 ( #11579 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-06-07 22:21:33 +02:00
Huáng Jùnliàng
71d3527ef5
Properly parse export default from when exportDefaultFrom is not enabled ( #11676 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-06-05 09:08:21 -05:00
Huáng Jùnliàng
b5c4a46a69
refactor: split locationParser into ParserErrors and error message ( #11653 )
2020-05-30 15:05:42 -04:00
Nicolò Ribaudo
31b361b736
Use ?. where it represents the intended semantics ( #11512 )
2020-05-09 23:31:50 +02:00
Nicolò Ribaudo
90a9103e55
Update Flow to 0.123.0 ( #11500 )
2020-04-30 15:26:03 +02:00