Skip to content

Commit 9726c78

Browse files
committed
add or patterns
1 parent 98fc7f5 commit 9726c78

File tree

5 files changed

+568782
-505796
lines changed

5 files changed

+568782
-505796
lines changed

grammar/pat.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {parens} = require('./util.js')
1+
const {parens, braces, layouted} = require('./util.js')
22

33
module.exports = {
44
pat_field: $ => choice(
@@ -70,13 +70,20 @@ module.exports = {
7070
$.pat_apply,
7171
),
7272

73+
pat_or: $ => sep2('or', $._lpat),
74+
7375
pat_infix: $ => seq($._lpat, $._qconop, $._pat),
7476

77+
_pat_infix: $ => choice(
78+
$.pat_or,
79+
$.pat_infix,
80+
),
81+
7582
/**
7683
* Without the precs, a conflict is needed.
7784
*/
7885
_pat: $ => choice(
79-
prec(2, $.pat_infix),
86+
prec(2, $._pat_infix),
8087
prec(1, $._lpat),
8188
),
8289

src/grammar.json

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5637,6 +5637,31 @@
56375637
}
56385638
]
56395639
},
5640+
"pat_or": {
5641+
"type": "SEQ",
5642+
"members": [
5643+
{
5644+
"type": "SYMBOL",
5645+
"name": "_lpat"
5646+
},
5647+
{
5648+
"type": "REPEAT1",
5649+
"content": {
5650+
"type": "SEQ",
5651+
"members": [
5652+
{
5653+
"type": "STRING",
5654+
"value": "or"
5655+
},
5656+
{
5657+
"type": "SYMBOL",
5658+
"name": "_lpat"
5659+
}
5660+
]
5661+
}
5662+
}
5663+
]
5664+
},
56405665
"pat_infix": {
56415666
"type": "SEQ",
56425667
"members": [
@@ -5654,6 +5679,19 @@
56545679
}
56555680
]
56565681
},
5682+
"_pat_infix": {
5683+
"type": "CHOICE",
5684+
"members": [
5685+
{
5686+
"type": "SYMBOL",
5687+
"name": "pat_or"
5688+
},
5689+
{
5690+
"type": "SYMBOL",
5691+
"name": "pat_infix"
5692+
}
5693+
]
5694+
},
56575695
"_pat": {
56585696
"type": "CHOICE",
56595697
"members": [
@@ -5662,7 +5700,7 @@
56625700
"value": 2,
56635701
"content": {
56645702
"type": "SYMBOL",
5665-
"name": "pat_infix"
5703+
"name": "_pat_infix"
56665704
}
56675705
},
56685706
{

0 commit comments

Comments
 (0)