X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=lexer.h;h=24ac39a63f7f574d1e9a8a7dfc1f8236cc51612a;hp=4368cf1cf69923d48ffaf33c2c73769cc6b768f6;hb=c3f4b7153b3815daf271829148f40d545a6140ef;hpb=29db4a44edb5cce12197ae1e25129d38f70e0225 diff --git a/lexer.h b/lexer.h index 4368cf1..24ac39a 100644 --- a/lexer.h +++ b/lexer.h @@ -25,8 +25,6 @@ typedef struct token_s token; -#include "ast.h" - struct token_s { int ttype; @@ -76,6 +74,10 @@ enum { TOKEN_ATTRIBUTE_OPEN, /* [[ */ TOKEN_ATTRIBUTE_CLOSE, /* ]] */ + TOKEN_VA_ARGS, /* for the ftepp only */ + TOKEN_VA_ARGS_ARRAY, /* for the ftepp only */ + TOKEN_VA_COUNT, /* to get the count of vaargs */ + TOKEN_STRINGCONST, /* not the typename but an actual "string" */ TOKEN_CHARCONST, TOKEN_VECTORCONST, @@ -85,7 +87,11 @@ enum { TOKEN_WHITE, TOKEN_EOL, - TOKEN_EOF, + /* if we add additional tokens before this, the exposed API + * should not be broken anyway, but EOF/ERROR/... should + * still be at the bottom + */ + TOKEN_EOF = 1024, /* We use '< TOKEN_ERROR', so TOKEN_FATAL must come after it and any * other error related tokens as well @@ -99,7 +105,7 @@ typedef struct { int value; } frame_macro; -typedef struct { +typedef struct lex_file_s { FILE *file; const char *open_string; size_t open_string_length; @@ -109,7 +115,7 @@ typedef struct { size_t line; size_t sline; /* line at the start of a token */ - char peek[256]; + int peek[256]; size_t peekpos; bool eof; @@ -164,18 +170,21 @@ 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, 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 */ + { "++", 1, opid3('S','+','+'), ASSOC_LEFT, 17, OP_SUFFIX}, + { "--", 1, opid3('S','-','-'), ASSOC_LEFT, 17, OP_SUFFIX}, + { ".", 2, opid1('.'), ASSOC_LEFT, 17, 0 }, + { "(", 0, opid1('('), ASSOC_LEFT, 17, 0 }, /* function call */ + { "[", 2, opid1('['), ASSOC_LEFT, 17, 0 }, /* array subscript */ + + { "++", 1, opid3('+','+','P'), ASSOC_RIGHT, 16, OP_PREFIX }, + { "--", 1, opid3('-','-','P'), ASSOC_RIGHT, 16, OP_PREFIX }, + + { "**", 2, opid2('*', '*'), ASSOC_RIGHT, 15, 0 }, { "!", 1, opid2('!', 'P'), ASSOC_RIGHT, 14, OP_PREFIX }, { "~", 1, opid2('~', 'P'), ASSOC_RIGHT, 14, OP_PREFIX }, { "+", 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 }, */ { "*", 2, opid1('*'), ASSOC_LEFT, 13, 0 }, @@ -190,6 +199,7 @@ static const oper_info c_operators[] = { { "<", 2, opid1('<'), ASSOC_LEFT, 10, 0 }, { ">", 2, opid1('>'), ASSOC_LEFT, 10, 0 }, + { "<=>", 2, opid3('<','=','>'), ASSOC_LEFT, 10, 0 }, { "<=", 2, opid2('<','='), ASSOC_LEFT, 10, 0 }, { ">=", 2, opid2('>','='), ASSOC_LEFT, 10, 0 }, @@ -250,6 +260,9 @@ static const oper_info fte_operators[] = { { "+", 2, opid1('+'), ASSOC_LEFT, 12, 0 }, { "-", 2, opid1('-'), ASSOC_LEFT, 12, 0 }, + { "<<", 2, opid2('<','<'), ASSOC_LEFT, 11, 0 }, + { ">>", 2, opid2('>','>'), ASSOC_LEFT, 11, 0 }, + { "<", 2, opid1('<'), ASSOC_LEFT, 10, 0 }, { ">", 2, opid1('>'), ASSOC_LEFT, 10, 0 }, { "<=", 2, opid2('<','='), ASSOC_LEFT, 10, 0 },