Skip to content

Commit c828867

Browse files
committed
Add continue statements
1 parent 27bee8a commit c828867

File tree

4 files changed

+115377
-114622
lines changed

4 files changed

+115377
-114622
lines changed

grammar.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ module.exports = grammar({
155155
$.try_statement,
156156

157157
$.break_statement,
158+
$.continue_statement,
158159
$.return_statement,
159160
$.yield_statement,
160161
$.throw_statement,
@@ -262,6 +263,11 @@ module.exports = grammar({
262263
terminator()
263264
),
264265

266+
continue_statement: $ => seq(
267+
'continue',
268+
terminator()
269+
),
270+
265271
trailing_break_statement: $ => 'break',
266272

267273
return_statement: $ => seq(

grammar_test/statements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ for (i = 0, init(); i < 10; i++)
141141

142142
for (;;) {
143143
z;
144+
continue;
144145
}
145146

146147
---
@@ -161,7 +162,8 @@ for (;;) {
161162

162163
(for_statement
163164
(statement_block
164-
(expression_statement (identifier)))))
165+
(expression_statement (identifier))
166+
(continue_statement))))
165167

166168
============================================
167169
For-in statements

src/grammar.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@
568568
"type": "SYMBOL",
569569
"name": "break_statement"
570570
},
571+
{
572+
"type": "SYMBOL",
573+
"name": "continue_statement"
574+
},
571575
{
572576
"type": "SYMBOL",
573577
"name": "return_statement"
@@ -1155,6 +1159,28 @@
11551159
}
11561160
]
11571161
},
1162+
"continue_statement": {
1163+
"type": "SEQ",
1164+
"members": [
1165+
{
1166+
"type": "STRING",
1167+
"value": "continue"
1168+
},
1169+
{
1170+
"type": "CHOICE",
1171+
"members": [
1172+
{
1173+
"type": "STRING",
1174+
"value": ";"
1175+
},
1176+
{
1177+
"type": "SYMBOL",
1178+
"name": "_line_break"
1179+
}
1180+
]
1181+
}
1182+
]
1183+
},
11581184
"trailing_break_statement": {
11591185
"type": "STRING",
11601186
"value": "break"

0 commit comments

Comments
 (0)