]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
fixup do-while parsing, expect a semicolon afterwards
authorWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 14 Aug 2012 14:42:29 +0000 (16:42 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 14 Aug 2012 14:42:29 +0000 (16:42 +0200)
parser.c

index ee5c76da4df170b18cab98fd9b2cf40c44a1ee1f..6330b79cd41e734c9817d3156314c04205209d80 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1122,7 +1122,7 @@ static bool parser_parse_dowhile(parser_t *parser, ast_block *block, ast_express
     lex_ctx ctx = parser_ctx(parser);
 
     /* skip the 'do' and get the body */
-    if (!parser_next(parser) || parser->tok != '(') {
+    if (!parser_next(parser)) {
         parseerror(parser, "expected loop body");
         return false;
     }
@@ -1132,7 +1132,7 @@ static bool parser_parse_dowhile(parser_t *parser, ast_block *block, ast_express
 
     /* expect the "while" */
     if (parser->tok != TOKEN_KEYWORD ||
-        !strcmp(parser_tokval(parser), "while"))
+        strcmp(parser_tokval(parser), "while"))
     {
         parseerror(parser, "expected 'while' and condition");
         ast_delete(ontrue);
@@ -1163,6 +1163,13 @@ static bool parser_parse_dowhile(parser_t *parser, ast_block *block, ast_express
         return false;
     }
     /* parse on */
+    if (!parser_next(parser) || parser->tok != ';') {
+        parseerror(parser, "expected semicolon after condition");
+        ast_delete(ontrue);
+        ast_delete(cond);
+        return false;
+    }
+
     if (!parser_next(parser)) {
         parseerror(parser, "parse error");
         ast_delete(ontrue);