mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-20 18:32:01 +00:00
Allow float constants which start with a dot
This commit is contained in:
parent
42bd37a2e8
commit
089e490c69
1 changed files with 17 additions and 2 deletions
19
lexer.c
19
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
|
||||
|
|
Loading…
Reference in a new issue