X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=lexer.h;h=e5493734881d6240d3796b4b7a5f41332b46a79d;hp=7cc1c7f4dc25cc04cac4c9e0112774e1d83e8f8b;hb=26a80e08682a1d8d855cbb0222755bb7f36ada16;hpb=5c0a62be9616fd96bafc422b7fcd2105e4b445e5 diff --git a/lexer.h b/lexer.h index 7cc1c7f..e549373 100644 --- a/lexer.h +++ b/lexer.h @@ -73,6 +73,9 @@ enum { TOKEN_DOTS, /* 3 dots, ... */ + TOKEN_ATTRIBUTE_OPEN, /* [[ */ + TOKEN_ATTRIBUTE_CLOSE, /* ]] */ + TOKEN_STRINGCONST, /* not the typename but an actual "string" */ TOKEN_CHARCONST, TOKEN_VECTORCONST, @@ -150,7 +153,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 +207,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 +220,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])); @@ -252,6 +256,8 @@ static const oper_info fte_operators[] = { { "==", 2, opid2('=','='), ASSOC_LEFT, 10, 0 }, { "!=", 2, opid2('!','='), ASSOC_LEFT, 10, 0 }, + { "?", 3, opid2('?',':'), ASSOC_RIGHT, 9, 0 }, + { "=", 2, opid1('='), ASSOC_RIGHT, 8, 0 }, { "+=", 2, opid2('+','='), ASSOC_RIGHT, 8, 0 }, { "-=", 2, opid2('-','='), ASSOC_RIGHT, 8, 0 }, @@ -265,10 +271,9 @@ static const oper_info fte_operators[] = { { "&&", 2, opid2('&','&'), ASSOC_LEFT, 5, 0 }, { "||", 2, opid2('|','|'), ASSOC_LEFT, 5, 0 }, + /* Leave precedence 3 for : with -fcorrect-ternary */ { ",", 2, opid1(','), ASSOC_LEFT, 2, 0 }, - - { "?", 3, opid2('?',':'), ASSOC_RIGHT, 1, 0 }, - { ":", 3, opid2(':','?'), ASSOC_RIGHT, 1, 0 } + { ":", 0, opid2(':','?'), ASSOC_RIGHT, 1, 0 } }; static const size_t fte_operator_count = (sizeof(fte_operators) / sizeof(fte_operators[0])); @@ -311,9 +316,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]));