mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-30 15:41:12 +00:00
Handling [ in the SYA
This commit is contained in:
parent
2edc7ce822
commit
d5b95f0412
1 changed files with 12 additions and 4 deletions
16
parser.c
16
parser.c
|
@ -1000,7 +1000,13 @@ static bool parser_close_paren(parser_t *parser, shunt *sy, bool functions_only)
|
||||||
return !functions_only;
|
return !functions_only;
|
||||||
}
|
}
|
||||||
if (sy->ops[sy->ops_count-1].paren == SY_PAREN_INDEX) {
|
if (sy->ops[sy->ops_count-1].paren == SY_PAREN_INDEX) {
|
||||||
|
if (functions_only)
|
||||||
|
return false;
|
||||||
|
/* pop off the parenthesis */
|
||||||
sy->ops_count--;
|
sy->ops_count--;
|
||||||
|
/* then apply the index operator */
|
||||||
|
if (!parser_sy_pop(parser, sy))
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!parser_sy_pop(parser, sy))
|
if (!parser_sy_pop(parser, sy))
|
||||||
|
@ -1290,10 +1296,12 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
|
||||||
goto onerr;
|
goto onerr;
|
||||||
}
|
}
|
||||||
++parens;
|
++parens;
|
||||||
if (!shunt_ops_add(&sy, syparen(parser_ctx(parser), SY_PAREN_INDEX, 0))) {
|
/* push both the operator and the paren, this makes life easier */
|
||||||
parseerror(parser, "out of memory");
|
if (!shunt_ops_add(&sy, syop(parser_ctx(parser), op)))
|
||||||
goto onerr;
|
goto onerr;
|
||||||
}
|
if (!shunt_ops_add(&sy, syparen(parser_ctx(parser), SY_PAREN_INDEX, 0)))
|
||||||
|
goto onerr;
|
||||||
|
wantop = false;
|
||||||
} else {
|
} else {
|
||||||
DEBUGSHUNTDO(printf("push operator %s\n", op->op));
|
DEBUGSHUNTDO(printf("push operator %s\n", op->op));
|
||||||
if (!shunt_ops_add(&sy, syop(parser_ctx(parser), op)))
|
if (!shunt_ops_add(&sy, syop(parser_ctx(parser), op)))
|
||||||
|
@ -1304,7 +1312,7 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
|
||||||
if (!parser_next(parser)) {
|
if (!parser_next(parser)) {
|
||||||
goto onerr;
|
goto onerr;
|
||||||
}
|
}
|
||||||
if (parser->tok == ';' || parser->tok == ']') {
|
if (parser->tok == ';' || (!parens && parser->tok == ']')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue