]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
lexer now turns '(' into an operator if noops=false
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 12:26:25 +0000 (14:26 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 12:26:25 +0000 (14:26 +0200)
lexer.c
lexer.h

diff --git a/lexer.c b/lexer.c
index 9bf460ac950041e140289455b6bc2beb8024295d..1adedc2ee5fcb14563857eba926cae87c05dcb8d 100644 (file)
--- 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 7389ba3f8a4b3856974340da3f1f31e86afac835..5bd15f65a1e3fd0cddc64a8da394055fe960761d 100644 (file)
--- 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 },