From: Wolfgang (Blub) Bumiller Date: Tue, 14 Aug 2012 14:22:38 +0000 (+0200) Subject: the 'local' keyword now also introduces the declaration of a local variable X-Git-Tag: 0.1-rc1~303 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2d9623cbe8ebf988c7bd5060315c6d8b465b5c30;p=xonotic%2Fgmqcc.git the 'local' keyword now also introduces the declaration of a local variable --- diff --git a/parser.c b/parser.c index 65ec05d..85640e9 100644 --- a/parser.c +++ b/parser.c @@ -1244,7 +1244,22 @@ static bool parser_parse_statement(parser_t *parser, ast_block *block, ast_expre } else if (parser->tok == TOKEN_KEYWORD) { - if (!strcmp(parser_tokval(parser), "return")) + if (!strcmp(parser_tokval(parser), "local")) + { + if (!block) { + parseerror(parser, "cannot declare a local variable here"); + return false; + } + if (!parser_next(parser)) { + parseerror(parser, "expected variable declaration"); + return false; + } + if (!parser_variable(parser, block)) + return false; + *out = NULL; + return true; + } + else if (!strcmp(parser_tokval(parser), "return")) { ast_expression *exp = NULL; ast_return *ret = NULL;