From: Wolfgang (Blub) Bumiller Date: Fri, 23 Nov 2012 11:32:07 +0000 (+0100) Subject: Fixing operator precedence of suffices X-Git-Tag: 0.1.9~314 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5867167a70c1fce8575b632aeefbd368051f0827;p=xonotic%2Fgmqcc.git Fixing operator precedence of suffices --- diff --git a/lexer.h b/lexer.h index eaddb03..f293345 100644 --- 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 */ diff --git a/tests/operators.qc b/tests/operators.qc index ed617e9..1c23e7a 100644 --- a/tests/operators.qc +++ b/tests/operators.qc @@ -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"); } diff --git a/tests/operators.tmpl b/tests/operators.tmpl index c0accef..1e12706 100644 --- a/tests/operators.tmpl +++ b/tests/operators.tmpl @@ -11,3 +11,4 @@ M: 6 = 6 M: 11 = 11 M: 4 M: 2 +M: 12 = 12