Skip to content

Commit

Permalink
Use new grammar API for reserved words
Browse files Browse the repository at this point in the history
Co-authored-by: Amaan <[email protected]>
  • Loading branch information
maxbrunsfeld and amaanq committed Nov 23, 2024
1 parent 88b4235 commit ca6cc97
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 224 deletions.
16 changes: 8 additions & 8 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = grammar({
],

reserved: {
global: [
global: $ => [
'const',
'do',
'else',
Expand All @@ -45,7 +45,7 @@ module.exports = grammar({
'var',
'while',
],
properties: [],
properties: $ => [],
},

supertypes: $ => [
Expand Down Expand Up @@ -550,7 +550,7 @@ module.exports = grammar({
$.method_definition,
alias(
choice($.identifier, $._reserved_identifier),
$.shorthand_property_identifier
$.shorthand_property_identifier,
),
))),
'}',
Expand All @@ -564,7 +564,7 @@ module.exports = grammar({
$.object_assignment_pattern,
alias(
choice($.identifier, $._reserved_identifier),
$.shorthand_property_identifier_pattern
$.shorthand_property_identifier_pattern,
),
))),
'}',
Expand All @@ -581,7 +581,7 @@ module.exports = grammar({
$._destructuring_pattern,
alias(
choice($._reserved_identifier, $.identifier),
$.shorthand_property_identifier_pattern
$.shorthand_property_identifier_pattern,
),
)),
'=',
Expand Down Expand Up @@ -1217,15 +1217,15 @@ module.exports = grammar({
field('value', choice($.pattern, $.assignment_pattern)),
),

_property_name: $ => reserved([], choice(
_property_name: $ => reserved('properties', choice(
alias(choice(
$.identifier,
$._reserved_identifier
$._reserved_identifier,
), $.property_identifier),
$.private_property_identifier,
$.string,
$.number,
$.computed_property_name
$.computed_property_name,
)),

computed_property_name: $ => seq(
Expand Down
107 changes: 55 additions & 52 deletions src/grammar.json

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

Loading

0 comments on commit ca6cc97

Please sign in to comment.