Skip to content

Commit 9c494a5

Browse files
authored
Various fixes (#226)
* Remove label_name not in official grammar" * Add some missing fields * Fix lambda modifiers
1 parent 49716ff commit 9c494a5

File tree

10 files changed

+390726
-361146
lines changed

10 files changed

+390726
-361146
lines changed

corpus/expressions.txt

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,17 @@ void a()
568568
(block
569569
(expression_statement (invocation_expression (identifier)
570570
(argument_list
571-
(argument (lambda_expression (parameter_list) (initializer_expression))))))))))
571+
(argument (lambda_expression (modifier) (parameter_list) (initializer_expression))))))))))
572572

573573
============================
574-
Lambda expression with qualifiers
574+
Lambda expression with modifiers
575575
============================
576576

577577
void a() {
578578
var lam = static x => x + 1;
579579
var bda = async x => x + 1;
580+
var syn = async static x => x + 1;
581+
var txt = static async x => x + 1;
580582
}
581583

582584
---
@@ -591,8 +593,7 @@ void a() {
591593
(variable_declarator
592594
(identifier)
593595
(equals_value_clause
594-
(lambda_expression
595-
(identifier)
596+
(lambda_expression (modifier) (identifier)
596597
(binary_expression
597598
(identifier)
598599
(integer_literal)))))))
@@ -602,8 +603,27 @@ void a() {
602603
(variable_declarator
603604
(identifier)
604605
(equals_value_clause
605-
(lambda_expression
606-
(identifier)
606+
(lambda_expression (modifier) (identifier)
607+
(binary_expression
608+
(identifier)
609+
(integer_literal)))))))
610+
(local_declaration_statement
611+
(variable_declaration
612+
(implicit_type)
613+
(variable_declarator
614+
(identifier)
615+
(equals_value_clause
616+
(lambda_expression (modifier) (modifier) (identifier)
617+
(binary_expression
618+
(identifier)
619+
(integer_literal)))))))
620+
(local_declaration_statement
621+
(variable_declaration
622+
(implicit_type)
623+
(variable_declarator
624+
(identifier)
625+
(equals_value_clause
626+
(lambda_expression (modifier) (modifier) (identifier)
607627
(binary_expression
608628
(identifier)
609629
(integer_literal)))))))))))

corpus/statements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ class A {
181181
(identifier)
182182
(parameter_list)
183183
(block
184-
(goto_statement (label_name))
184+
(goto_statement (identifier))
185185
(labeled_statement
186-
(label_name) (return_statement)))))))
186+
(identifier) (return_statement)))))))
187187

188188
=====================================
189189
If statement

grammar.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ module.exports = grammar({
343343
repeat($.attribute_list),
344344
'params',
345345
choice($.array_type, $.nullable_type),
346-
$.identifier
346+
field('name', $.identifier),
347347
),
348348

349349
constructor_initializer: $ => seq(
@@ -381,8 +381,8 @@ module.exports = grammar({
381381
repeat($.attribute_list),
382382
optional('extern'),
383383
'~',
384-
$.identifier,
385-
$.parameter_list,
384+
field('name', $.identifier),
385+
field('parameters', $.parameter_list),
386386
$._function_body
387387
),
388388

@@ -405,7 +405,7 @@ module.exports = grammar({
405405
type_parameter: $ => seq(
406406
repeat($.attribute_list),
407407
optional(choice('in', 'out')),
408-
$.identifier
408+
field('name', $.identifier),
409409
),
410410

411411
type_parameter_constraints_clause: $ => seq(
@@ -830,14 +830,10 @@ module.exports = grammar({
830830
field('body', $._statement)
831831
),
832832

833-
// grammar.txt one doesn't seem to make sense so we do this instead
834833
goto_statement: $ => seq(
835834
'goto',
836-
choice(
837-
alias($.identifier, $.label_name),
838-
seq('case', $._expression),
839-
'default'
840-
),
835+
optional(choice('case', 'default')),
836+
optional($._expression),
841837
';'
842838
),
843839

@@ -854,7 +850,7 @@ module.exports = grammar({
854850
)),
855851

856852
labeled_statement: $ => seq(
857-
alias($.identifier, $.label_name),
853+
$.identifier,
858854
':',
859855
$._statement
860856
),
@@ -983,7 +979,7 @@ module.exports = grammar({
983979
_variable_designation: $ => prec(1, choice(
984980
$.discard,
985981
$.parenthesized_variable_designation,
986-
$.identifier
982+
field('name', $.identifier),
987983
)),
988984

989985
discard: $ => '_',
@@ -1053,7 +1049,7 @@ module.exports = grammar({
10531049
catch_declaration: $ => seq(
10541050
'(',
10551051
field('type', $._type),
1056-
field('name', optional($.identifier)),
1052+
optional(field('name', $.identifier)),
10571053
')'
10581054
),
10591055

@@ -1086,14 +1082,13 @@ module.exports = grammar({
10861082
anonymous_method_expression: $ => seq(
10871083
optional('async'),
10881084
'delegate',
1089-
optional($.parameter_list),
1085+
optional(field('parameters', $.parameter_list)),
10901086
$.block
10911087
),
10921088

10931089
lambda_expression: $ => prec(-1, seq(
1094-
optional('async'),
1095-
optional('static'),
1096-
choice($.parameter_list, $.identifier),
1090+
optional(alias(choice('async', 'static', seq('async', 'static'), seq('static', 'async')), $.modifier)),
1091+
choice(field('parameters', $.parameter_list), $.identifier),
10971092
'=>',
10981093
field('body', choice($.block, $._expression))
10991094
)),

index.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

queries/highlights.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
(namespace_declaration name: (identifier) @type)
1111

1212
(constructor_declaration name: (identifier) @type)
13+
(destructor_declaration name: (identifier) @type)
1314

1415
[
1516
(implicit_type)

src/binding.cc

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)