Skip to content

Commit

Permalink
fix: for in / of statements containing new lines
Browse files Browse the repository at this point in the history
Co-authored-by: Amaan Qureshi <[email protected]>
  • Loading branch information
jackschu and amaanq authored Aug 17, 2024
1 parent a92640f commit d8f277f
Show file tree
Hide file tree
Showing 5 changed files with 44,398 additions and 40,791 deletions.
15 changes: 8 additions & 7 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ module.exports = grammar({
[$.primary_expression, $.rest_pattern],
[$.primary_expression, $.pattern],
[$.primary_expression, $._for_header],
[$.variable_declarator, $._for_header],
[$.array, $.array_pattern],
[$.object, $.object_pattern],
[$.assignment_expression, $.pattern],
Expand Down Expand Up @@ -313,14 +314,13 @@ module.exports = grammar({
for_statement: $ => seq(
'for',
'(',
field('initializer', choice(
$.lexical_declaration,
$.variable_declaration,
$.expression_statement,
$.empty_statement,
)),
choice(
field('initializer', choice($.lexical_declaration, $.variable_declaration)),
seq(field('initializer', $._expressions), ';'),
field('initializer', $.empty_statement),
),
field('condition', choice(
$.expression_statement,
seq($._expressions, ';'),
$.empty_statement,
)),
field('increment', optional($._expressions)),
Expand Down Expand Up @@ -356,6 +356,7 @@ module.exports = grammar({
$.identifier,
$._destructuring_pattern,
)),
optional($._automatic_semicolon),
),
),
field('operator', choice('in', 'of')),
Expand Down
91 changes: 69 additions & 22 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d8f277f

Please sign in to comment.