@@ -146,7 +146,7 @@ module.exports = grammar({
146146 [ $ . _bodyless_function_declaration , $ . property_modifier ] ,
147147 [ $ . init_declaration , $ . property_modifier ] ,
148148 // Patterns, man
149- [ $ . _navigable_type_expression , $ . _case_pattern ] ,
149+ [ $ . _navigable_type_expression , $ . case_pattern ] ,
150150 [ $ . _no_expr_pattern_already_bound , $ . _binding_pattern_no_expr ] ,
151151
152152 // On encountering a closure starting with `{ @Foo ...`, we don't yet know if that attribute applies to the closure
@@ -1865,38 +1865,38 @@ module.exports = grammar({
18651865 _universally_allowed_pattern : ( $ ) =>
18661866 choice (
18671867 $ . wildcard_pattern ,
1868- $ . _tuple_pattern ,
1869- $ . _type_casting_pattern ,
1870- $ . _case_pattern
1868+ $ . tuple_pattern ,
1869+ $ . type_casting_pattern ,
1870+ $ . case_pattern
18711871 ) ,
18721872 _bound_identifier : ( $ ) => field ( "bound_identifier" , $ . simple_identifier ) ,
18731873
18741874 _binding_pattern_no_expr : ( $ ) =>
18751875 seq (
1876- choice (
1876+ field ( "kind" , choice (
18771877 $ . _universally_allowed_pattern ,
1878- $ . _binding_pattern ,
1878+ $ . binding_pattern ,
18791879 $ . _bound_identifier
1880- ) ,
1880+ ) ) ,
18811881 optional ( $ . _quest )
18821882 ) ,
18831883 _no_expr_pattern_already_bound : ( $ ) =>
18841884 seq (
1885- choice ( $ . _universally_allowed_pattern , $ . _bound_identifier ) ,
1885+ field ( "kind" , choice ( $ . _universally_allowed_pattern , $ . _bound_identifier ) ) ,
18861886 optional ( $ . _quest )
18871887 ) ,
18881888 _binding_pattern_with_expr : ( $ ) =>
18891889 seq (
1890- choice (
1890+ field ( "kind" , choice (
18911891 $ . _universally_allowed_pattern ,
1892- $ . _binding_pattern ,
1892+ $ . binding_pattern ,
18931893 $ . expression
1894- ) ,
1894+ ) ) ,
18951895 optional ( $ . _quest )
18961896 ) ,
18971897 _non_binding_pattern_with_expr : ( $ ) =>
18981898 seq (
1899- choice ( $ . _universally_allowed_pattern , $ . expression ) ,
1899+ field ( "kind" , choice ( $ . _universally_allowed_pattern , $ . expression ) ) ,
19001900 optional ( $ . _quest )
19011901 ) ,
19021902 _direct_or_indirect_binding : ( $ ) =>
@@ -1916,32 +1916,33 @@ module.exports = grammar({
19161916 $ . _no_expr_pattern_already_bound
19171917 ) ,
19181918 wildcard_pattern : ( $ ) => "_" ,
1919- _tuple_pattern_item : ( $ ) =>
1919+ tuple_pattern_item : ( $ ) =>
19201920 choice (
19211921 seq (
1922- $ . simple_identifier ,
1923- seq ( ":" , alias ( $ . _binding_pattern_with_expr , $ . pattern ) )
1922+ field ( "name" , $ . simple_identifier ) ,
1923+ ":" ,
1924+ field ( "pattern" , alias ( $ . _binding_pattern_with_expr , $ . pattern ) )
19241925 ) ,
1925- alias ( $ . _binding_pattern_with_expr , $ . pattern )
1926+ field ( "pattern" , alias ( $ . _binding_pattern_with_expr , $ . pattern ) )
19261927 ) ,
1927- _tuple_pattern : ( $ ) => seq ( "(" , sep1Opt ( $ . _tuple_pattern_item , "," ) , ")" ) ,
1928- _case_pattern : ( $ ) =>
1928+ tuple_pattern : ( $ ) => seq ( "(" , sep1Opt ( field ( "item" , $ . tuple_pattern_item ) , "," ) , ")" ) ,
1929+ case_pattern : ( $ ) =>
19291930 seq (
19301931 optional ( "case" ) ,
1931- optional ( $ . user_type ) , // XXX this should just be _type but that creates ambiguity
1932+ optional ( field ( "type" , $ . user_type ) ) , // XXX this should just be _type but that creates ambiguity
19321933 $ . _dot ,
1933- $ . simple_identifier ,
1934- optional ( $ . _tuple_pattern )
1934+ field ( "name" , $ . simple_identifier ) ,
1935+ optional ( field ( "arguments" , $ . tuple_pattern ) )
19351936 ) ,
1936- _type_casting_pattern : ( $ ) =>
1937+ type_casting_pattern : ( $ ) =>
19371938 choice (
1938- seq ( "is" , $ . type ) ,
1939- seq ( alias ( $ . _binding_pattern_no_expr , $ . pattern ) , $ . _as , $ . type )
1939+ seq ( "is" , field ( "type" , $ . type ) ) ,
1940+ seq ( field ( "pattern" , alias ( $ . _binding_pattern_no_expr , $ . pattern ) ) , $ . _as , field ( "type" , $ . type ) )
19401941 ) ,
1941- _binding_pattern : ( $ ) =>
1942+ binding_pattern : ( $ ) =>
19421943 seq (
1943- seq ( optional ( "case" ) , $ . value_binding_pattern ) ,
1944- $ . _no_expr_pattern_already_bound
1944+ seq ( optional ( "case" ) , field ( "binding" , $ . value_binding_pattern ) ) ,
1945+ field ( "pattern" , alias ( $ . _no_expr_pattern_already_bound , $ . pattern ) )
19451946 ) ,
19461947
19471948 // ==========
0 commit comments