mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-25 20:51:38 +00:00
relax parse_close_paren to allow values in parenthesis with no operators... duh
This commit is contained in:
parent
a93ed6ae80
commit
481baeeedc
2 changed files with 10 additions and 2 deletions
|
@ -68,3 +68,9 @@ void() main = {
|
||||||
print3("memb = ", ftos(pawn.memb), "\n");
|
print3("memb = ", ftos(pawn.memb), "\n");
|
||||||
print3("Frame stand3 is ", ftos($stand3), " wooh\n");
|
print3("Frame stand3 is ", ftos($stand3), " wooh\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float() exprtest = {
|
||||||
|
local float x;
|
||||||
|
x = 3;
|
||||||
|
return (x); /* parens */
|
||||||
|
}
|
||||||
|
|
6
parser.c
6
parser.c
|
@ -977,10 +977,12 @@ static bool parser_close_paren(parser_t *parser, shunt *sy, bool functions_only)
|
||||||
parseerror(parser, "unmatched closing paren");
|
parseerror(parser, "unmatched closing paren");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/* this would for bit a + (x) because there are no operators inside (x)
|
||||||
if (sy->ops[sy->ops_count-1].paren == 1) {
|
if (sy->ops[sy->ops_count-1].paren == 1) {
|
||||||
parseerror(parser, "empty parenthesis expression");
|
parseerror(parser, "empty parenthesis expression");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
while (sy->ops_count) {
|
while (sy->ops_count) {
|
||||||
if (sy->ops[sy->ops_count-1].paren == 'f') {
|
if (sy->ops[sy->ops_count-1].paren == 'f') {
|
||||||
if (!parser_close_call(parser, sy))
|
if (!parser_close_call(parser, sy))
|
||||||
|
@ -1240,7 +1242,7 @@ static ast_expression* parser_expression_leave(parser_t *parser, bool stopatcomm
|
||||||
|
|
||||||
if (op->id == opid1('(')) {
|
if (op->id == opid1('(')) {
|
||||||
if (wantop) {
|
if (wantop) {
|
||||||
DEBUGSHUNTDO(printf("push (\n"));
|
DEBUGSHUNTDO(printf("push [op] (\n"));
|
||||||
++parens;
|
++parens;
|
||||||
/* we expected an operator, this is the function-call operator */
|
/* we expected an operator, this is the function-call operator */
|
||||||
if (!shunt_ops_add(&sy, syparen(parser_ctx(parser), 'f', sy.out_count-1))) {
|
if (!shunt_ops_add(&sy, syparen(parser_ctx(parser), 'f', sy.out_count-1))) {
|
||||||
|
@ -1253,7 +1255,7 @@ static ast_expression* parser_expression_leave(parser_t *parser, bool stopatcomm
|
||||||
parseerror(parser, "out of memory");
|
parseerror(parser, "out of memory");
|
||||||
goto onerr;
|
goto onerr;
|
||||||
}
|
}
|
||||||
DEBUGSHUNTDO(printf("push (\n"));
|
DEBUGSHUNTDO(printf("push [nop] (\n"));
|
||||||
}
|
}
|
||||||
wantop = false;
|
wantop = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue