Semicolon after do...while statement is optional

This commit is contained in:
Anthony Van de Gejuchte
2015-12-17 23:02:35 +01:00
parent 9e2f9f7910
commit bd99b00413

View File

@@ -724,9 +724,9 @@ function parse($TEXT, options) {
); );
}; };
function semicolon() { function semicolon(optional) {
if (is("punc", ";")) next(); if (is("punc", ";")) next();
else if (!can_insert_semicolon()) unexpected(); else if (!optional && !can_insert_semicolon()) unexpected();
}; };
function parenthesised() { function parenthesised() {
@@ -814,7 +814,7 @@ function parse($TEXT, options) {
case "do": case "do":
return new AST_Do({ return new AST_Do({
body : in_loop(statement), body : in_loop(statement),
condition : (expect_token("keyword", "while"), tmp = parenthesised(), semicolon(), tmp) condition : (expect_token("keyword", "while"), tmp = parenthesised(), semicolon(true), tmp)
}); });
case "while": case "while":