]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
relax parse_close_paren to allow values in parenthesis with no operators... duh
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 19 Aug 2012 17:35:45 +0000 (19:35 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 19 Aug 2012 17:35:45 +0000 (19:35 +0200)
data/parsing.qc
parser.c

index d106a1cf2f728d313d06f724dcd62de955225fb9..b0bcfc12cab53add3269096c361166f9667acf4a 100644 (file)
@@ -68,3 +68,9 @@ void() main = {
     print3("memb = ", ftos(pawn.memb), "\n");
     print3("Frame stand3 is ", ftos($stand3), " wooh\n");
 };
+
+float() exprtest = {
+    local float x;
+    x = 3;
+    return (x); /* parens */
+}
index 294fca13c8a39408c4ed9430643771b5a94378ba..a70b9071869f9b1d81412653207f47675b78a416 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -977,10 +977,12 @@ static bool parser_close_paren(parser_t *parser, shunt *sy, bool functions_only)
         parseerror(parser, "unmatched closing paren");
         return false;
     }
+    /* this would for bit a + (x) because there are no operators inside (x)
     if (sy->ops[sy->ops_count-1].paren == 1) {
         parseerror(parser, "empty parenthesis expression");
         return false;
     }
+    */
     while (sy->ops_count) {
         if (sy->ops[sy->ops_count-1].paren == 'f') {
             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 (wantop) {
-                    DEBUGSHUNTDO(printf("push (\n"));
+                    DEBUGSHUNTDO(printf("push [op] (\n"));
                     ++parens;
                     /* we expected an operator, this is the function-call operator */
                     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");
                         goto onerr;
                     }
-                    DEBUGSHUNTDO(printf("push (\n"));
+                    DEBUGSHUNTDO(printf("push [nop] (\n"));
                 }
                 wantop = false;
             } else {