From: Wolfgang Bumiller <wolfgang.linux@bumiller.com>
Date: Thu, 26 Jul 2012 21:26:34 +0000 (+0200)
Subject: parse ahead into the return expression as expected
X-Git-Tag: 0.1-rc1~392
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5d766f60b28c32e14674ca1c7124c97d5efa48b4;p=xonotic%2Fgmqcc.git

parse ahead into the return expression as expected
---

diff --git a/parser.c b/parser.c
index 3ee206e..f644433 100644
--- a/parser.c
+++ b/parser.c
@@ -560,8 +560,15 @@ static bool parser_body_do(parser_t *parser, ast_block *block)
     {
         if (!strcmp(parser_tokval(parser), "return"))
         {
-            ast_expression *exp = parser_expression(parser);
+            ast_expression *exp;
             ast_return *ret;
+
+            if (!parser_next(parser)) {
+                parseerror(parser, "expected return expression");
+                return false;
+            }
+
+            exp = parser_expression(parser);
             if (!exp)
                 return false;
             ret = ast_return_new(exp->expression.node.context, exp);