Semicolon after do...while statement is optional
authorAnthony Van de Gejuchte <anthonyvdgent@gmail.com>
Thu, 17 Dec 2015 22:02:35 +0000 (23:02 +0100)
committerAnthony Van de Gejuchte <anthonyvdgent@gmail.com>
Thu, 17 Dec 2015 22:02:35 +0000 (23:02 +0100)
lib/parse.js

index de27d98..4d06ae0 100644 (file)
@@ -724,9 +724,9 @@ function parse($TEXT, options) {
         );
     };
 
-    function semicolon() {
+    function semicolon(optional) {
         if (is("punc", ";")) next();
-        else if (!can_insert_semicolon()) unexpected();
+        else if (!optional && !can_insert_semicolon()) unexpected();
     };
 
     function parenthesised() {
@@ -814,7 +814,7 @@ function parse($TEXT, options) {
               case "do":
                 return new AST_Do({
                     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":