X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=lexer.h;h=e419794eda9f867e150e9f26064cd3ef849c9ec6;hb=2cc51b8eb060e6efab5b56cf471594911a79c5c1;hp=49c7762081454933216aac4e3d902dfa956f6e59;hpb=ca033e5acd2c69ee2b4a96046605e0e41f5f597b;p=xonotic%2Fgmqcc.git diff --git a/lexer.h b/lexer.h index 49c7762..e419794 100644 --- a/lexer.h +++ b/lexer.h @@ -150,7 +150,7 @@ typedef struct { unsigned int operands; unsigned int id; unsigned int assoc; - unsigned int prec; + signed int prec; unsigned int flags; } oper_info; @@ -204,7 +204,6 @@ static const oper_info c_operators[] = { { "||", 2, opid2('|','|'), ASSOC_LEFT, 4, 0 }, { "?", 3, opid2('?',':'), ASSOC_RIGHT, 3, 0 }, - { ":", 3, opid2(':','?'), ASSOC_RIGHT, 3, 0 }, { "=", 2, opid1('='), ASSOC_RIGHT, 2, 0 }, { "+=", 2, opid2('+','='), ASSOC_RIGHT, 2, 0 }, @@ -218,7 +217,9 @@ static const oper_info c_operators[] = { { "^=", 2, opid2('^','='), ASSOC_RIGHT, 2, 0 }, { "|=", 2, opid2('|','='), ASSOC_RIGHT, 2, 0 }, - { ",", 2, opid1(','), ASSOC_LEFT, 1, 0 } + { ":", 0, opid2(':','?'), ASSOC_RIGHT, 1, 0 }, + + { ",", 2, opid1(','), ASSOC_LEFT, 0, 0 } }; static const size_t c_operator_count = (sizeof(c_operators) / sizeof(c_operators[0])); @@ -253,7 +254,6 @@ static const oper_info fte_operators[] = { { "!=", 2, opid2('!','='), ASSOC_LEFT, 10, 0 }, { "?", 3, opid2('?',':'), ASSOC_RIGHT, 9, 0 }, - { ":", 3, opid2(':','?'), ASSOC_RIGHT, 9, 0 }, { "=", 2, opid1('='), ASSOC_RIGHT, 8, 0 }, { "+=", 2, opid2('+','='), ASSOC_RIGHT, 8, 0 }, @@ -268,7 +268,9 @@ static const oper_info fte_operators[] = { { "&&", 2, opid2('&','&'), ASSOC_LEFT, 5, 0 }, { "||", 2, opid2('|','|'), ASSOC_LEFT, 5, 0 }, - { ",", 2, opid1(','), ASSOC_LEFT, 2, 0 } + /* Leave precedence 3 for : with -fcorrect-ternary */ + { ",", 2, opid1(','), ASSOC_LEFT, 2, 0 }, + { ":", 0, opid2(':','?'), ASSOC_RIGHT, 1, 0 } }; static const size_t fte_operator_count = (sizeof(fte_operators) / sizeof(fte_operators[0])); @@ -311,9 +313,6 @@ static const oper_info qcc_operators[] = { { "||", 2, opid2('|','|'), ASSOC_LEFT, 5, 0 }, { ",", 2, opid1(','), ASSOC_LEFT, 2, 0 }, - - { "?", 3, opid2('?',':'), ASSOC_RIGHT, 1, 0 }, - { ":", 3, opid2(':','?'), ASSOC_RIGHT, 1, 0 } }; static const size_t qcc_operator_count = (sizeof(qcc_operators) / sizeof(qcc_operators[0]));