mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
support hex numbers
This commit is contained in:
parent
99e18513f0
commit
99cdcc9bd7
1 changed files with 17 additions and 0 deletions
|
@ -72,6 +72,7 @@ extern int element_flag;
|
|||
%}
|
||||
|
||||
DIGIT [0-9]
|
||||
XDIGIT [0-9a-fA-F]
|
||||
ID [a-zA-Z_][a-zA-Z_0-9]*
|
||||
FLOAT {DIGIT}+"."{DIGIT}*
|
||||
NUM ({DIGIT}+("."{DIGIT}*)?)
|
||||
|
@ -104,6 +105,22 @@ m ([\-+]?)
|
|||
return INT_VAL;
|
||||
}
|
||||
|
||||
0x{XDIGIT}+ {
|
||||
const char *c = yytext + 2;
|
||||
yylval.integer_val = 0;
|
||||
while (*c) {
|
||||
yylval.integer_val *= 16;
|
||||
yylval.integer_val += *c - '0';
|
||||
if (*c > '9')
|
||||
yylval.integer_val -= 'A' - '9' - 1;
|
||||
if (*c > 'F')
|
||||
yylval.integer_val -= 'a' - 'A';
|
||||
c++;
|
||||
}
|
||||
printf ("%x\n", yylval.integer_val);
|
||||
return INT_VAL;
|
||||
}
|
||||
|
||||
{FLOAT}* {
|
||||
yylval.float_val = atof (yytext);
|
||||
return FLOAT_VAL;
|
||||
|
|
Loading…
Reference in a new issue