From: Wolfgang Bumiller Date: Fri, 18 Jan 2013 14:22:03 +0000 (+0100) Subject: adding missing wantop flag and some related parentheses code X-Git-Tag: before-library~227 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dca9dd56d17bae739525d9e0a914077d22d3e84d;p=xonotic%2Fgmqcc.git adding missing wantop flag and some related parentheses code --- diff --git a/parser.c b/parser.c index cef5985..159c7a8 100644 --- a/parser.c +++ b/parser.c @@ -1991,9 +1991,13 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma } } else if (parser->tok == ')') { + while (vec_size(sy.paren) && vec_last(sy.paren) == PAREN_TERNARY2) { + if (!parser_sy_apply_operator(parser, &sy)) + goto onerr; + } + if (!vec_size(sy.paren)) + break; if (wantop) { - if (!vec_size(sy.paren)) - break; if (vec_last(sy.paren) == PAREN_TERNARY1) { parseerror(parser, "mismatched parentheses (closing paren in ternary expression?)"); goto onerr; @@ -2002,8 +2006,6 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma goto onerr; } else { /* must be a function call without parameters */ - if (!vec_size(sy.paren)) - break; if (vec_last(sy.paren) != PAREN_FUNC) { parseerror(parser, "closing paren in invalid position"); goto onerr; @@ -2022,14 +2024,19 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma goto onerr; } else if (parser->tok == ']') { + while (vec_size(sy.paren) && vec_last(sy.paren) == PAREN_TERNARY2) { + if (!parser_sy_apply_operator(parser, &sy)) + goto onerr; + } if (!vec_size(sy.paren)) break; - if (!vec_size(sy.paren) || vec_last(sy.paren) != PAREN_INDEX) { + if (vec_last(sy.paren) != PAREN_INDEX) { parseerror(parser, "mismatched parentheses, unexpected ']'"); goto onerr; } if (!parser_close_paren(parser, &sy)) goto onerr; + wantop = true; } else if (!wantop) { if (!parse_sya_operand(parser, &sy, with_labels))