From bc94d3f5b8be21a94847aab9d14e3e32d474b9e9 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sat, 18 Aug 2012 14:26:25 +0200 Subject: [PATCH] lexer now turns '(' into an operator if noops=false --- lexer.c | 11 ++++++++++- lexer.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) 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 }, -- 2.39.2