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

Commit a3d1b6b

Browse files
committed
grammar: support begin blocks
1 parent bb7b77d commit a3d1b6b

File tree

8 files changed

+8823
-7715
lines changed

8 files changed

+8823
-7715
lines changed

grammar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ module.exports = grammar({
176176

177177
_expression: ($) =>
178178
choice(
179+
$.expr_begin_block,
179180
$.expr_list_comprehension,
180181
$.expr_operator,
181182
$.expr_receive,
@@ -192,6 +193,8 @@ module.exports = grammar({
192193
$.match
193194
),
194195

196+
expr_begin_block: ($) => seq("begin", sepBy(COMMA, $.expression), "end"),
197+
195198
expr_list_comprehension: ($) =>
196199
seq(
197200
BRACKET_LEFT,

src/grammar.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@
505505
"_expression": {
506506
"type": "CHOICE",
507507
"members": [
508+
{
509+
"type": "SYMBOL",
510+
"name": "expr_begin_block"
511+
},
508512
{
509513
"type": "SYMBOL",
510514
"name": "expr_list_comprehension"
@@ -563,6 +567,44 @@
563567
}
564568
]
565569
},
570+
"expr_begin_block": {
571+
"type": "SEQ",
572+
"members": [
573+
{
574+
"type": "STRING",
575+
"value": "begin"
576+
},
577+
{
578+
"type": "SEQ",
579+
"members": [
580+
{
581+
"type": "SYMBOL",
582+
"name": "expression"
583+
},
584+
{
585+
"type": "REPEAT",
586+
"content": {
587+
"type": "SEQ",
588+
"members": [
589+
{
590+
"type": "STRING",
591+
"value": ","
592+
},
593+
{
594+
"type": "SYMBOL",
595+
"name": "expression"
596+
}
597+
]
598+
}
599+
}
600+
]
601+
},
602+
{
603+
"type": "STRING",
604+
"value": "end"
605+
}
606+
]
607+
},
566608
"expr_list_comprehension": {
567609
"type": "SEQ",
568610
"members": [

src/node-types.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,21 @@
191191
]
192192
}
193193
},
194+
{
195+
"type": "expr_begin_block",
196+
"named": true,
197+
"fields": {},
198+
"children": {
199+
"multiple": true,
200+
"required": true,
201+
"types": [
202+
{
203+
"type": "expression",
204+
"named": true
205+
}
206+
]
207+
}
208+
},
194209
{
195210
"type": "expr_bitstring_comprehension",
196211
"named": true,
@@ -630,6 +645,10 @@
630645
"type": "case",
631646
"named": true
632647
},
648+
{
649+
"type": "expr_begin_block",
650+
"named": true
651+
},
633652
{
634653
"type": "expr_bitstring_comprehension",
635654
"named": true
@@ -1507,6 +1526,10 @@
15071526
"type": "band",
15081527
"named": false
15091528
},
1529+
{
1530+
"type": "begin",
1531+
"named": false
1532+
},
15101533
{
15111534
"type": "big",
15121535
"named": false
@@ -1573,11 +1596,11 @@
15731596
},
15741597
{
15751598
"type": "float",
1576-
"named": false
1599+
"named": true
15771600
},
15781601
{
15791602
"type": "float",
1580-
"named": true
1603+
"named": false
15811604
},
15821605
{
15831606
"type": "fun",

0 commit comments

Comments
 (0)