@@ -40,6 +40,7 @@ module.exports = grammar({
4040 $ . spread_element ,
4141 $ . await_expression ,
4242 $ . pipe_expression ,
43+ $ . lazy_expression ,
4344 'binary_times' ,
4445 'binary_pow' ,
4546 'binary_plus' ,
@@ -72,6 +73,7 @@ module.exports = grammar({
7273 [ $ . primary_expression , $ . record_pattern ] ,
7374 [ $ . primary_expression , $ . spread_pattern ] ,
7475 [ $ . primary_expression , $ . _literal_pattern ] ,
76+ [ $ . primary_expression , $ . lazy_pattern ] ,
7577 [ $ . primary_expression , $ . _jsx_child ] ,
7678 [ $ . tuple_pattern , $ . parameter ] ,
7779 [ $ . primary_expression , $ . parameter ] ,
@@ -437,7 +439,7 @@ module.exports = grammar({
437439 ) ,
438440
439441 _let_binding : $ => seq (
440- $ . _binding_pattern ,
442+ $ . _pattern ,
441443 optional ( $ . type_annotation ) ,
442444 optional ( seq (
443445 '=' ,
@@ -456,16 +458,6 @@ module.exports = grammar({
456458 $ . _let_binding ,
457459 ) ,
458460
459- _binding_pattern : $ => choice (
460- $ . value_identifier ,
461- $ . tuple_pattern ,
462- $ . record_pattern ,
463- $ . array_pattern ,
464- $ . list_pattern ,
465- $ . module_unpack_pattern ,
466- $ . unit
467- ) ,
468-
469461 expression_statement : $ => $ . expression ,
470462
471463 expression : $ => choice (
@@ -512,6 +504,7 @@ module.exports = grammar({
512504 $ . member_expression ,
513505 $ . module_pack ,
514506 $ . extension_expression ,
507+ $ . lazy_expression ,
515508 ) ,
516509
517510 parenthesized_expression : $ => seq (
@@ -837,6 +830,7 @@ module.exports = grammar({
837830 $ . polyvar_type_pattern ,
838831 $ . unit ,
839832 $ . module_pack ,
833+ $ . lazy_pattern ,
840834 $ . _parenthesized_pattern ,
841835 ) ) ,
842836 optional ( $ . type_annotation ) ,
@@ -930,8 +924,15 @@ module.exports = grammar({
930924 choice ( $ . value_identifier , $ . list_pattern , $ . array_pattern ) ,
931925 ) ,
932926
933- module_unpack_pattern : $ => seq (
934- 'module' , '(' , $ . module_identifier , ')' ,
927+ lazy_pattern : $ => seq (
928+ 'lazy' ,
929+ choice (
930+ $ . value_identifier ,
931+ $ . _literal_pattern ,
932+ $ . _destructuring_pattern ,
933+ $ . polyvar_type_pattern ,
934+ $ . _parenthesized_pattern ,
935+ )
935936 ) ,
936937
937938 _jsx_element : $ => choice ( $ . jsx_element , $ . jsx_self_closing_element ) ,
@@ -1092,6 +1093,11 @@ module.exports = grammar({
10921093 $ . block ,
10931094 ) ,
10941095
1096+ lazy_expression : $ => seq (
1097+ 'lazy' ,
1098+ $ . expression ,
1099+ ) ,
1100+
10951101 binary_expression : $ => choice (
10961102 ...[
10971103 [ '&&' , 'binary_and' ] ,
0 commit comments