lex->flags.preprocessing causes the lexer to parse the unary number if it is one
authorWolfgang Bumiller <blub@speed.at>
Wed, 2 Jan 2013 16:38:24 +0000 (17:38 +0100)
committerWolfgang Bumiller <blub@speed.at>
Wed, 2 Jan 2013 16:38:24 +0000 (17:38 +0100)
lexer.c

diff --git a/lexer.c b/lexer.c
index 5e0414b5b9f075868ed9cf45852977e7240b6ed1..64cdb3d3cff06b7212c7caf4cc44472ebe700d1e 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -1299,6 +1299,17 @@ int lex_do(lex_file *lex)
                 lex_tokench(lex, nextch);
                 lex_tokench(lex, thirdch);
             }
+        }
+        else if (lex->flags.preprocessing &&
+                 ch == '-' && isdigit(nextch))
+        {
+            lex->tok.ttype = lex_finish_digit(lex, nextch);
+            if (lex->tok.ttype == TOKEN_INTCONST)
+                lex->tok.constval.i = -lex->tok.constval.i;
+            else
+                lex->tok.constval.f = -lex->tok.constval.f;
+            lex_endtoken(lex);
+            return lex->tok.ttype;
         } else
             lex_ungetch(lex, nextch);