From: Wolfgang (Blub) Bumiller Date: Sun, 25 Nov 2012 21:35:41 +0000 (+0100) Subject: Allow float constants which start with a dot X-Git-Tag: 0.1.9~223 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=089e490c69071ecbe40492912070b7a7a891a8bb;p=xonotic%2Fgmqcc.git Allow float constants which start with a dot --- diff --git a/lexer.c b/lexer.c index 6bd47b0..6fbe41d 100644 --- a/lexer.c +++ b/lexer.c @@ -800,7 +800,10 @@ static int GMQCC_WARN lex_finish_digit(lex_file *lex, int lastch) int ch = lastch; /* parse a number... */ - lex->tok.ttype = TOKEN_INTCONST; + if (ch == '.') + lex->tok.ttype = TOKEN_FLOATCONST; + else + lex->tok.ttype = TOKEN_INTCONST; lex_tokench(lex, ch); @@ -833,7 +836,7 @@ static int GMQCC_WARN lex_finish_digit(lex_file *lex, int lastch) } } /* NOT else, '.' can come from above as well */ - if (ch == '.' && !ishex) + if (lex->tok.ttype != TOKEN_FLOATCONST && ch == '.' && !ishex) { /* Allow floating comma in non-hex mode */ lex->tok.ttype = TOKEN_FLOATCONST; @@ -1078,6 +1081,18 @@ int lex_do(lex_file *lex) break; } + if (ch == '.') { + nextch = lex_getch(lex); + /* digits starting with a dot */ + if (isdigit(nextch)) { + lex_ungetch(lex, nextch); + lex->tok.ttype = lex_finish_digit(lex, ch); + lex_endtoken(lex); + return lex->tok.ttype; + } + lex_ungetch(lex, nextch); + } + if (lex->flags.noops) { /* Detect characters early which are normally