mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 23:33:00 +00:00
Let the scanner returned unsigned integers
- The scanner already recognized the u suffix for unsigned integers, but otherwise ignored it. Return it as a proper token.
This commit is contained in:
parent
aec6aff7a8
commit
33344201fa
3 changed files with 15 additions and 3 deletions
|
@ -530,9 +530,20 @@ bool FScanner::GetToken ()
|
|||
else if (TokenType == TK_IntConst)
|
||||
{
|
||||
char *stopper;
|
||||
// Check for unsigned
|
||||
if (String[StringLen - 1] == 'u' || String[StringLen - 1] == 'U' ||
|
||||
String[StringLen - 2] == 'u' || String[StringLen - 2] == 'U')
|
||||
{
|
||||
TokenType = TK_UIntConst;
|
||||
Number = strtoul(String, &stopper, 0);
|
||||
Float = (unsigned)Number;
|
||||
}
|
||||
else
|
||||
{
|
||||
Number = strtol(String, &stopper, 0);
|
||||
Float = Number;
|
||||
}
|
||||
}
|
||||
else if (TokenType == TK_FloatConst)
|
||||
{
|
||||
char *stopper;
|
||||
|
|
|
@ -188,7 +188,7 @@ std2:
|
|||
|
||||
L (L|D)* { RET(TK_Identifier); }
|
||||
|
||||
("0" [xX] H+ IS?) | ("0" D+ IS?) | (D+ IS?)
|
||||
("0" [xX] H+ IS?IS?) | ("0" D+ IS?IS?) | (D+ IS?IS?)
|
||||
{ RET(TK_IntConst); }
|
||||
|
||||
(D+ E FS?) | (D* "." D+ E? FS?) | (D+ "." D* E? FS?)
|
||||
|
|
|
@ -2,6 +2,7 @@ xx(TK_Identifier, "identifier")
|
|||
xx(TK_StringConst, "string constant")
|
||||
xx(TK_NameConst, "name constant")
|
||||
xx(TK_IntConst, "integer constant")
|
||||
xx(TK_UIntConst, "unsigned constant")
|
||||
xx(TK_FloatConst, "float constant")
|
||||
xx(TK_NonWhitespace, "non-whitespace")
|
||||
xx(TK_ColonColon, "'::'")
|
||||
|
|
Loading…
Reference in a new issue