@@ -4,7 +4,6 @@ const PREC = {
44 // https://introcs.cs.princeton.edu/java/11precedence/
55 COMMENT : 0 , // // /* */
66 ASSIGN : 1 , // = += -= *= /= %= &= ^= |= <<= >>= >>>=
7- SWITCH_EXP : 1 , // always prefer to parse switch as expression over statement
87 DECL : 2 ,
98 ELEMENT_VAL : 2 ,
109 TERNARY : 3 , // ?:
@@ -66,8 +65,10 @@ module.exports = grammar({
6665 [ $ . _unannotated_type , $ . scoped_type_identifier ] ,
6766 [ $ . _unannotated_type , $ . generic_type ] ,
6867 [ $ . generic_type , $ . primary_expression ] ,
68+ [ $ . expression , $ . statement ] ,
6969 // Only conflicts in switch expressions
7070 [ $ . lambda_expression , $ . primary_expression ] ,
71+ [ $ . inferred_parameters , $ . primary_expression ] ,
7172 ] ,
7273
7374 word : $ => $ . identifier ,
@@ -174,7 +175,7 @@ module.exports = grammar({
174175 $ . primary_expression ,
175176 $ . unary_expression ,
176177 $ . cast_expression ,
177- prec ( PREC . SWITCH_EXP , $ . switch_expression ) ,
178+ $ . switch_expression ,
178179 ) ,
179180
180181 cast_expression : $ => prec ( PREC . CAST , seq (
@@ -233,15 +234,15 @@ module.exports = grammar({
233234
234235 lambda_expression : $ => seq (
235236 field ( 'parameters' , choice (
236- $ . identifier , $ . formal_parameters , $ . inferred_parameters
237+ $ . identifier , $ . formal_parameters , $ . inferred_parameters , $ . _reserved_identifier
237238 ) ) ,
238239 '->' ,
239240 field ( 'body' , choice ( $ . expression , $ . block ) )
240241 ) ,
241242
242243 inferred_parameters : $ => seq (
243244 '(' ,
244- commaSep1 ( $ . identifier ) ,
245+ commaSep1 ( choice ( $ . identifier , $ . _reserved_identifier ) ) ,
245246 ')'
246247 ) ,
247248
@@ -290,6 +291,7 @@ module.exports = grammar({
290291
291292 array_creation_expression : $ => prec . right ( seq (
292293 'new' ,
294+ repeat ( $ . _annotation ) ,
293295 field ( 'type' , $ . _simple_type ) ,
294296 choice (
295297 seq (
@@ -922,6 +924,7 @@ module.exports = grammar({
922924 $ . constant_declaration ,
923925 $ . class_declaration ,
924926 $ . interface_declaration ,
927+ $ . enum_declaration ,
925928 $ . annotation_type_declaration
926929 ) ) ,
927930 '}'
0 commit comments