From: Wolfgang (Blub) Bumiller Date: Sat, 18 Aug 2012 12:26:25 +0000 (+0200) Subject: lexer now turns '(' into an operator if noops=false X-Git-Tag: 0.1-rc1~230 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bc94d3f5b8be21a94847aab9d14e3e32d474b9e9;p=xonotic%2Fgmqcc.git lexer now turns '(' into an operator if noops=false --- diff --git a/lexer.c b/lexer.c index 9bf460a..1adedc2 100644 --- a/lexer.c +++ b/lexer.c @@ -701,9 +701,18 @@ int lex_do(lex_file *lex) /* single-character tokens */ switch (ch) { - case ';': case '(': + if (!lex_tokench(lex, ch) || + !lex_endtoken(lex)) + { + return (lex->tok->ttype = TOKEN_FATAL); + } + if (lex->flags.noops) + return (lex->tok->ttype = ch); + else + return (lex->tok->ttype = TOKEN_OPERATOR); case ')': + case ';': case '{': case '}': case '[': diff --git a/lexer.h b/lexer.h index 7389ba3..5bd15f6 100644 --- a/lexer.h +++ b/lexer.h @@ -142,6 +142,7 @@ static const oper_info operators[] = { { "--", 1, opid3('S','-','-'), ASSOC_LEFT, 16, OP_SUFFIX}, { ".", 2, opid1('.'), ASSOC_LEFT, 15, 0 }, + { "(", 0, opid1('('), ASSOC_LEFT, 15, OP_SUFFIX }, { "!", 1, opid2('!', 'P'), ASSOC_RIGHT, 14, OP_PREFIX }, { "~", 1, opid2('~', 'P'), ASSOC_RIGHT, 14, OP_PREFIX },