Skip to content

Commit 160f350

Browse files
committed
one-line module/class without ; after name
1 parent ec993c8 commit 160f350

4 files changed

Lines changed: 308122 additions & 305866 deletions

File tree

grammar.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ module.exports = grammar({
262262
class: $ => seq(
263263
'class',
264264
field('name', choice($.constant, $.scope_resolution)),
265-
field('superclass', optional($.superclass)),
266-
$._terminator,
265+
choice(
266+
seq(field('superclass', $.superclass), $._terminator),
267+
optional($._terminator)
268+
),
267269
$._body_statement
268270
),
269271

@@ -280,10 +282,7 @@ module.exports = grammar({
280282
module: $ => seq(
281283
'module',
282284
field('name', choice($.constant, $.scope_resolution)),
283-
choice(
284-
seq($._terminator, $._body_statement),
285-
'end'
286-
)
285+
seq(optional($._terminator), $._body_statement),
287286
),
288287

289288
return_command: $ => prec.left(seq('return', alias($.command_argument_list, $.argument_list))),

src/grammar.json

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -913,24 +913,38 @@
913913
}
914914
},
915915
{
916-
"type": "FIELD",
917-
"name": "superclass",
918-
"content": {
919-
"type": "CHOICE",
920-
"members": [
921-
{
922-
"type": "SYMBOL",
923-
"name": "superclass"
924-
},
925-
{
926-
"type": "BLANK"
927-
}
928-
]
929-
}
930-
},
931-
{
932-
"type": "SYMBOL",
933-
"name": "_terminator"
916+
"type": "CHOICE",
917+
"members": [
918+
{
919+
"type": "SEQ",
920+
"members": [
921+
{
922+
"type": "FIELD",
923+
"name": "superclass",
924+
"content": {
925+
"type": "SYMBOL",
926+
"name": "superclass"
927+
}
928+
},
929+
{
930+
"type": "SYMBOL",
931+
"name": "_terminator"
932+
}
933+
]
934+
},
935+
{
936+
"type": "CHOICE",
937+
"members": [
938+
{
939+
"type": "SYMBOL",
940+
"name": "_terminator"
941+
},
942+
{
943+
"type": "BLANK"
944+
}
945+
]
946+
}
947+
]
934948
},
935949
{
936950
"type": "SYMBOL",
@@ -1010,24 +1024,23 @@
10101024
}
10111025
},
10121026
{
1013-
"type": "CHOICE",
1027+
"type": "SEQ",
10141028
"members": [
10151029
{
1016-
"type": "SEQ",
1030+
"type": "CHOICE",
10171031
"members": [
10181032
{
10191033
"type": "SYMBOL",
10201034
"name": "_terminator"
10211035
},
10221036
{
1023-
"type": "SYMBOL",
1024-
"name": "_body_statement"
1037+
"type": "BLANK"
10251038
}
10261039
]
10271040
},
10281041
{
1029-
"type": "STRING",
1030-
"value": "end"
1042+
"type": "SYMBOL",
1043+
"name": "_body_statement"
10311044
}
10321045
]
10331046
}

0 commit comments

Comments
 (0)