From 5867167a70c1fce8575b632aeefbd368051f0827 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Fri, 23 Nov 2012 12:32:07 +0100 Subject: [PATCH] Fixing operator precedence of suffices --- lexer.h | 10 ++++------ tests/operators.qc | 4 ++++ tests/operators.tmpl | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) 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 -- 2.39.2