Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit 946cef2

Browse files
committed
grammar: reuse parens combinator
1 parent 223e949 commit 946cef2

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

grammar.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,15 @@ module.exports = grammar({
149149
$.module_export
150150
),
151151

152-
module_attribute: ($) =>
153-
seq(DASH, $.atom, delim(PARENS_LEFT, $.expression, PARENS_RIGHT), DOT),
152+
module_attribute: ($) => seq(DASH, $.atom, parens($.expression), DOT),
154153

155-
module_name: ($) =>
156-
seq(DASH, "module", delim(PARENS_LEFT, $.atom, PARENS_RIGHT), DOT),
154+
module_name: ($) => seq(DASH, "module", parens($.atom), DOT),
157155

158156
module_export: ($) =>
159157
seq(
160158
DASH,
161159
choice("export", "export_type"),
162-
delim(PARENS_LEFT, list(seq($.atom, SLASH, $.integer)), PARENS_RIGHT),
160+
parens(list(seq($.atom, SLASH, $.integer))),
163161
DOT
164162
),
165163

@@ -593,13 +591,7 @@ module.exports = grammar({
593591
opt($.bin_sized),
594592
opt($.bin_type_list)
595593
),
596-
seq(
597-
PARENS_LEFT,
598-
$.expression,
599-
PARENS_RIGHT,
600-
opt($.bin_sized),
601-
opt($.bin_type_list)
602-
)
594+
seq(parens($.expression), opt($.bin_sized), opt($.bin_type_list))
603595
),
604596
bin_sized: ($) => seq(/:/, $.integer),
605597
bin_type_list: ($) => seq(/\//, sepBy(DASH, $.bin_type)),

src/grammar.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,16 +3613,21 @@
36133613
"type": "SEQ",
36143614
"members": [
36153615
{
3616-
"type": "STRING",
3617-
"value": "("
3618-
},
3619-
{
3620-
"type": "SYMBOL",
3621-
"name": "expression"
3622-
},
3623-
{
3624-
"type": "STRING",
3625-
"value": ")"
3616+
"type": "SEQ",
3617+
"members": [
3618+
{
3619+
"type": "STRING",
3620+
"value": "("
3621+
},
3622+
{
3623+
"type": "SYMBOL",
3624+
"name": "expression"
3625+
},
3626+
{
3627+
"type": "STRING",
3628+
"value": ")"
3629+
}
3630+
]
36263631
},
36273632
{
36283633
"type": "CHOICE",

0 commit comments

Comments
 (0)