]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Fixing operator precedence of suffices
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 23 Nov 2012 11:32:07 +0000 (12:32 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 23 Nov 2012 11:32:07 +0000 (12:32 +0100)
lexer.h
tests/operators.qc
tests/operators.tmpl

diff --git a/lexer.h b/lexer.h
index eaddb03c8044de35588d6f85698e98ef71c9850f..f2933455723b0075e01ddf43c2c0619abc5ceb9b 100644 (file)
--- a/lexer.h
+++ b/lexer.h
@@ -139,9 +139,8 @@ typedef struct {
 static const oper_info c_operators[] = {
     { "(",   0, opid1('('),         ASSOC_LEFT,  99, OP_PREFIX}, /* paren expression - non function call */
 
-    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  16, OP_SUFFIX},
-    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  16, OP_SUFFIX},
-
+    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  15, OP_SUFFIX},
+    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  15, OP_SUFFIX},
     { ".",   2, opid1('.'),         ASSOC_LEFT,  15, 0 },
     { "(",   0, opid1('('),         ASSOC_LEFT,  15, 0 }, /* function call */
     { "[",   2, opid1('['),         ASSOC_LEFT,  15, 0 }, /* array subscript */
@@ -204,9 +203,8 @@ static const size_t c_operator_count = (sizeof(c_operators) / sizeof(c_operators
 static const oper_info fte_operators[] = {
     { "(",   0, opid1('('),         ASSOC_LEFT,  99, OP_PREFIX}, /* paren expression - non function call */
 
-    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  16, OP_SUFFIX},
-    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  16, OP_SUFFIX},
-
+    { "++",  1, opid3('S','+','+'), ASSOC_LEFT,  15, OP_SUFFIX},
+    { "--",  1, opid3('S','-','-'), ASSOC_LEFT,  15, OP_SUFFIX},
     { ".",   2, opid1('.'),         ASSOC_LEFT,  15, 0 },
     { "(",   0, opid1('('),         ASSOC_LEFT,  15, 0 }, /* function call */
     { "[",   2, opid1('['),         ASSOC_LEFT,  15, 0 }, /* array subscript */
index ed617e92b3e8f6031e483a76b541b8c1414ae177..1c23e7aa5dada59fc3ab6494fabbc165a9470f53 100644 (file)
@@ -35,4 +35,8 @@ void main() {
        // check if minus translates
        print(ftos(a--), "\n");
        print(ftos(--a), "\n");
+
+       // postfix on members
+       print(ftos(e.mem--), " = ");
+       print(ftos(e.mem+1), "\n");
 }
index c0accefcbccbdc48c7c028fb08748fafafc44f7e..1e12706468f2baf789ce35f0648cc3c898fb7db9 100644 (file)
@@ -11,3 +11,4 @@ M: 6 = 6
 M: 11 = 11
 M: 4
 M: 2
+M: 12 = 12