From 16093adb0914a7c1cd0fe8d37e501b15061e8905 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Tue, 14 Aug 2012 16:42:29 +0200 Subject: [PATCH] fixup do-while parsing, expect a semicolon afterwards --- parser.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/parser.c b/parser.c index ee5c76d..6330b79 100644 --- 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); -- 2.39.2