X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=lexer.h;h=ae8812b261c5be6e68252a78704e2e32438b59c7;hb=0d9435d326c6a01f615fd6cb86432db75193d9bf;hp=8715b652e83ea18edc6aacef560ea6877328efa4;hpb=5d6767f3378c6619fcb9cc3b16b02f6e589369e0;p=xonotic%2Fgmqcc.git diff --git a/lexer.h b/lexer.h index 8715b65..ae8812b 100644 --- a/lexer.h +++ b/lexer.h @@ -117,6 +117,7 @@ enum { typedef struct { const char *op; + unsigned int operands; unsigned int id; unsigned int assoc; unsigned int prec; @@ -128,62 +129,64 @@ typedef struct { #define opid3(a,b,c) ((a<<16)|(b<<8)|c) static const oper_info operators[] = { - { "++", opid3('S','+','+'), ASSOC_LEFT, 16, OP_SUFFIX}, - { "--", opid3('S','-','-'), ASSOC_LEFT, 16, OP_SUFFIX}, + { "++", 1, opid3('S','+','+'), ASSOC_LEFT, 16, OP_SUFFIX}, + { "--", 1, opid3('S','-','-'), ASSOC_LEFT, 16, OP_SUFFIX}, - { ".", opid1('.'), ASSOC_LEFT, 15, 0 }, + { ".", 2, opid1('.'), ASSOC_LEFT, 15, 0 }, - { "!", opid2('!', 'P'), ASSOC_RIGHT, 14, 0 }, - { "~", opid2('~', 'P'), ASSOC_RIGHT, 14, 0 }, - { "+", opid2('+','P'), ASSOC_RIGHT, 14, OP_PREFIX }, - { "-", opid2('-','P'), ASSOC_RIGHT, 14, OP_PREFIX }, - { "++", opid3('+','+','P'), ASSOC_RIGHT, 14, OP_PREFIX }, - { "--", opid3('-','-','P'), ASSOC_RIGHT, 14, OP_PREFIX }, -/* { "&", opid2('&','P'), ASSOC_RIGHT, 14, OP_PREFIX }, */ + { "!", 1, opid2('!', 'P'), ASSOC_RIGHT, 14, 0 }, + { "~", 1, opid2('~', 'P'), ASSOC_RIGHT, 14, 0 }, + { "+", 1, opid2('+','P'), ASSOC_RIGHT, 14, OP_PREFIX }, + { "-", 1, opid2('-','P'), ASSOC_RIGHT, 14, OP_PREFIX }, + { "++", 1, opid3('+','+','P'), ASSOC_RIGHT, 14, OP_PREFIX }, + { "--", 1, opid3('-','-','P'), ASSOC_RIGHT, 14, OP_PREFIX }, +/* { "&", 1, opid2('&','P'), ASSOC_RIGHT, 14, OP_PREFIX }, */ - { "*", opid1('*'), ASSOC_LEFT, 13, 0 }, - { "/", opid1('/'), ASSOC_LEFT, 13, 0 }, - { "%", opid1('%'), ASSOC_LEFT, 13, 0 }, + { "*", 2, opid1('*'), ASSOC_LEFT, 13, 0 }, + { "/", 2, opid1('/'), ASSOC_LEFT, 13, 0 }, + { "%", 2, opid1('%'), ASSOC_LEFT, 13, 0 }, - { "+", opid1('+'), ASSOC_LEFT, 12, 0 }, - { "-", opid1('-'), ASSOC_LEFT, 12, 0 }, + { "+", 2, opid1('+'), ASSOC_LEFT, 12, 0 }, + { "-", 2, opid1('-'), ASSOC_LEFT, 12, 0 }, - { "<<", opid2('<','<'), ASSOC_LEFT, 11, 0 }, - { ">>", opid2('>','>'), ASSOC_LEFT, 11, 0 }, + { "<<", 2, opid2('<','<'), ASSOC_LEFT, 11, 0 }, + { ">>", 2, opid2('>','>'), ASSOC_LEFT, 11, 0 }, - { "<", opid1('<'), ASSOC_LEFT, 10, 0 }, - { ">", opid1('>'), ASSOC_LEFT, 10, 0 }, - { "<=", opid2('<','='), ASSOC_LEFT, 10, 0 }, - { ">=", opid2('>','='), ASSOC_LEFT, 10, 0 }, + { "<", 2, opid1('<'), ASSOC_LEFT, 10, 0 }, + { ">", 2, opid1('>'), ASSOC_LEFT, 10, 0 }, + { "<=", 2, opid2('<','='), ASSOC_LEFT, 10, 0 }, + { ">=", 2, opid2('>','='), ASSOC_LEFT, 10, 0 }, - { "==", opid2('=','='), ASSOC_LEFT, 9, 0 }, - { "!=", opid2('!','='), ASSOC_LEFT, 9, 0 }, + { "==", 2, opid2('=','='), ASSOC_LEFT, 9, 0 }, + { "!=", 2, opid2('!','='), ASSOC_LEFT, 9, 0 }, - { "&", opid1('&'), ASSOC_LEFT, 8, 0 }, + { "&", 2, opid1('&'), ASSOC_LEFT, 8, 0 }, - { "^", opid1('^'), ASSOC_LEFT, 7, 0 }, + { "^", 2, opid1('^'), ASSOC_LEFT, 7, 0 }, - { "|", opid1('|'), ASSOC_LEFT, 6, 0 }, + { "|", 2, opid1('|'), ASSOC_LEFT, 6, 0 }, - { "&&", opid2('&','&'), ASSOC_LEFT, 5, 0 }, + { "&&", 2, opid2('&','&'), ASSOC_LEFT, 5, 0 }, - { "||", opid2('|','|'), ASSOC_LEFT, 4, 0 }, + { "||", 2, opid2('|','|'), ASSOC_LEFT, 4, 0 }, - { "?", opid2('?',':'), ASSOC_RIGHT, 3, 0 }, + { "?", 3, opid2('?',':'), ASSOC_RIGHT, 3, 0 }, - { "=", opid1('='), ASSOC_RIGHT, 2, 0 }, - { "+=", opid2('+','='), ASSOC_RIGHT, 2, 0 }, - { "-=", opid2('-','='), ASSOC_RIGHT, 2, 0 }, - { "*=", opid2('*','='), ASSOC_RIGHT, 2, 0 }, - { "/=", opid2('/','='), ASSOC_RIGHT, 2, 0 }, - { "%=", opid2('%','='), ASSOC_RIGHT, 2, 0 }, - { ">>=", opid3('>','>','='), ASSOC_RIGHT, 2, 0 }, - { "<<=", opid3('<','<','='), ASSOC_RIGHT, 2, 0 }, - { "&=", opid2('&','='), ASSOC_RIGHT, 2, 0 }, - { "^=", opid2('^','='), ASSOC_RIGHT, 2, 0 }, - { "|=", opid2('|','='), ASSOC_RIGHT, 2, 0 }, + { "=", 2, opid1('='), ASSOC_RIGHT, 2, 0 }, + { "+=", 2, opid2('+','='), ASSOC_RIGHT, 2, 0 }, + { "-=", 2, opid2('-','='), ASSOC_RIGHT, 2, 0 }, + { "*=", 2, opid2('*','='), ASSOC_RIGHT, 2, 0 }, + { "/=", 2, opid2('/','='), ASSOC_RIGHT, 2, 0 }, + { "%=", 2, opid2('%','='), ASSOC_RIGHT, 2, 0 }, + { ">>=", 2, opid3('>','>','='), ASSOC_RIGHT, 2, 0 }, + { "<<=", 2, opid3('<','<','='), ASSOC_RIGHT, 2, 0 }, + { "&=", 2, opid2('&','='), ASSOC_RIGHT, 2, 0 }, + { "^=", 2, opid2('^','='), ASSOC_RIGHT, 2, 0 }, + { "|=", 2, opid2('|','='), ASSOC_RIGHT, 2, 0 }, + + { ",", 2, opid1(','), ASSOC_LEFT, 1, 0 } }; -const size_t operator_count = (sizeof(operators) / sizeof(operators[0])); +static const size_t operator_count = (sizeof(operators) / sizeof(operators[0])); typedef struct {