mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
the 'local' keyword now also introduces the declaration of a local variable
This commit is contained in:
parent
5064554b76
commit
2d9623cbe8
1 changed files with 16 additions and 1 deletions
17
parser.c
17
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;
|
||||
|
|
Loading…
Reference in a new issue