X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=lexer.c;h=42b21a1a6cd7de46bd45aa21b227cc412a4fbdec;hb=06ff6eb054b877642e66bac57ad858c5a176476a;hp=abb3e33ef27f054eb40cfe3ad1ddcba5ca50a7fc;hpb=e149551744569b16237b7220970ec2a8d40f9935;p=xonotic%2Fgmqcc.git diff --git a/lexer.c b/lexer.c index abb3e33..42b21a1 100644 --- a/lexer.c +++ b/lexer.c @@ -291,12 +291,16 @@ static int lex_try_trigraph(lex_file *lex, int old) { int c2, c3; c2 = lex_fgetc(lex); + if (!lex->push_line && c2 == '\n') + lex->line++; if (c2 != '?') { lex_ungetch(lex, c2); return old; } c3 = lex_fgetc(lex); + if (!lex->push_line && c3 == '\n') + lex->line++; switch (c3) { case '=': return '#'; case '/': return '\\'; @@ -1284,10 +1288,11 @@ int lex_do(lex_file *lex) } if (ch == '+' || ch == '-' || /* ++, --, +=, -= and -> as well! */ - ch == '>' || ch == '<' || /* <<, >>, <=, >= */ - ch == '=' || ch == '!' || /* ==, != */ - ch == '&' || ch == '|') /* &&, ||, &=, |= */ - { + ch == '>' || ch == '<' || /* <<, >>, <=, >= */ + ch == '=' || ch == '!' || /* ==, != */ + ch == '&' || ch == '|' || /* &&, ||, &=, |= */ + ch == '~' /* ~=, ~ */ + ) { lex_tokench(lex, ch); nextch = lex_getch(lex); @@ -1383,7 +1388,7 @@ int lex_do(lex_file *lex) if (!strcmp(v, keywords_qc[kw])) return (lex->tok.ttype = TOKEN_KEYWORD); } - if (opts.standard != COMPILER_QCC) { + if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_QCC) { for (kw = 0; kw < num_keywords_fg; ++kw) { if (!strcmp(v, keywords_fg[kw])) return (lex->tok.ttype = TOKEN_KEYWORD); @@ -1480,6 +1485,6 @@ int lex_do(lex_file *lex) return (lex->tok.ttype = ch); } - lexerror(lex, "unknown token"); + lexerror(lex, "unknown token: `%s`", lex->tok.value); return (lex->tok.ttype = TOKEN_ERROR); }