@@ -10,84 +10,101 @@ import {
1010export const _pattern = < RuleName extends string > (
1111 $ : GrammarSymbols < RuleName > ,
1212) =>
13- choice (
14- $ . wildcard_pattern ,
15- $ . binding_pattern ,
16- $ . _assignable_pattern ,
17- $ . _literal_pattern ,
13+ prec (
14+ 'base' ,
15+ choice (
16+ $ . wildcard_pattern ,
17+ $ . binding_pattern ,
18+ $ . _assignable_pattern ,
19+ $ . _literal_pattern ,
20+ ) ,
1821 )
1922
2023export const _assignable_pattern = < RuleName extends string > (
2124 $ : GrammarSymbols < RuleName > ,
2225) =>
23- choice (
24- alias ( $ . root_binding_pattern , $ . binding_pattern ) ,
25- $ . destructuring_pattern ,
26- $ . pattern_group ,
26+ prec (
27+ 'base' ,
28+ choice (
29+ alias ( $ . root_binding_pattern , $ . binding_pattern ) ,
30+ $ . destructuring_pattern ,
31+ $ . pattern_group ,
32+ ) ,
2733 )
2834
2935export const destructuring_pattern = < RuleName extends string > (
3036 $ : GrammarSymbols < RuleName > ,
3137) =>
32- seq (
33- optional (
34- seq (
35- field (
36- 'alias' ,
37- choice (
38- alias ( $ . identifier , $ . identifier_pattern ) ,
39- alias ( $ . type , $ . type_pattern ) ,
38+ prec (
39+ 'base' ,
40+ seq (
41+ optional (
42+ seq (
43+ field (
44+ 'alias' ,
45+ choice (
46+ alias ( $ . identifier , $ . identifier_pattern ) ,
47+ alias ( $ . type , $ . type_pattern ) ,
48+ ) ,
4049 ) ,
50+ '@' ,
51+ ) ,
52+ ) ,
53+ field (
54+ 'pattern' ,
55+ choice (
56+ $ . struct_pattern ,
57+ $ . tuple_pattern ,
58+ $ . list_pattern ,
59+ $ . tag_pattern ,
4160 ) ,
42- '@' ,
4361 ) ,
44- ) ,
45- field (
46- 'pattern' ,
47- choice ( $ . struct_pattern , $ . tuple_pattern , $ . list_pattern , $ . tag_pattern ) ,
4862 ) ,
4963 )
5064
5165export const struct_pattern = < RuleName extends string > (
5266 $ : GrammarSymbols < RuleName > ,
5367) =>
54- buildStruct (
55- $ ,
56- 'member' ,
57- choice (
58- $ . member_pattern ,
59- alias ( $ . binding_pattern , $ . shorthand_member_pattern ) ,
68+ prec (
69+ 'base' ,
70+ buildStruct (
71+ $ ,
72+ 'member' ,
73+ choice (
74+ $ . member_pattern ,
75+ alias ( $ . binding_pattern , $ . shorthand_member_pattern ) ,
76+ ) ,
77+ true ,
6078 ) ,
61- true ,
6279 )
6380
6481export const member_pattern = < RuleName extends string > (
6582 $ : GrammarSymbols < RuleName > ,
66- ) => buildMember ( $ , $ . _term , $ . _pattern )
83+ ) => prec ( 'base' , buildMember ( $ , $ . _term , $ . _pattern ) )
6784
6885export const tuple_pattern = < RuleName extends string > (
6986 $ : GrammarSymbols < RuleName > ,
70- ) => buildTuple ( $ , 'element' , $ . _pattern , true , false )
87+ ) => prec ( 'base' , buildTuple ( $ , 'element' , $ . _pattern , true , false ) )
7188
7289export const list_pattern = < RuleName extends string > (
7390 $ : GrammarSymbols < RuleName > ,
74- ) => buildList ( $ , 'element' , $ . _pattern , true )
91+ ) => prec ( 'base' , buildList ( $ , 'element' , $ . _pattern , true ) )
7592
7693export const binding_pattern = < RuleName extends string > (
7794 $ : GrammarSymbols < RuleName > ,
78- ) => buildBindingPattern ( $ , true )
95+ ) => prec ( 'base' , buildBindingPattern ( $ , true ) )
7996
8097export const root_binding_pattern = < RuleName extends string > (
8198 $ : GrammarSymbols < RuleName > ,
82- ) => choice ( buildBindingPattern ( $ , false ) )
99+ ) => prec ( 'base' , choice ( buildBindingPattern ( $ , false ) ) )
83100
84101export const wildcard_pattern = ( ) => '_'
85102
86103export const tag_pattern = < RuleName extends string > (
87104 $ : GrammarSymbols < RuleName > ,
88105) =>
89106 prec (
90- Prec . Pattern ,
107+ 'application' ,
91108 seq (
92109 field ( 'name' , alias ( $ . _identifier_without_operators , $ . identifier ) ) ,
93110 field ( 'pattern' , $ . _pattern ) ,
@@ -96,8 +113,9 @@ export const tag_pattern = <RuleName extends string>(
96113
97114export const _literal_pattern = < RuleName extends string > (
98115 $ : GrammarSymbols < RuleName > ,
99- ) => choice ( $ . boolean , $ . decimal , $ . integer , $ . raw_string , $ . regex )
116+ ) =>
117+ prec ( 'base' , choice ( $ . boolean , $ . decimal , $ . integer , $ . raw_string , $ . regex ) )
100118
101119export const pattern_group = < RuleName extends string > (
102120 $ : GrammarSymbols < RuleName > ,
103- ) => seq ( '(' , field ( 'pattern' , $ . _pattern ) , ')' )
121+ ) => prec ( 'base' , seq ( '(' , field ( 'pattern' , $ . _pattern ) , ')' ) )
0 commit comments