mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-22 20:40:39 +01:00
Add support for octal and hexadecimal integer literals.
In addition to the decimal literals which we already support. Note that we use strtoll here to get the large-width integers demanded by the specification.
This commit is contained in:
parent
35419095f8
commit
03f6d5d2d4
1 changed files with 16 additions and 3 deletions
19
glcpp-lex.l
19
glcpp-lex.l
|
|
@ -45,10 +45,13 @@ NONSPACE [^[:space:]]
|
|||
NEWLINE [\n]
|
||||
HSPACE [ \t]
|
||||
HASH ^{HSPACE}*#{HSPACE}*
|
||||
INTEGER [0-9]+
|
||||
IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
|
||||
TOKEN [^[:space:](),]+
|
||||
|
||||
DECIMAL_INTEGER [1-9][0-9]*[uU]?
|
||||
OCTAL_INTEGER 0[0-7]*[uU]?
|
||||
HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
||||
|
||||
%%
|
||||
|
||||
{HASH}if{HSPACE}* {
|
||||
|
|
@ -61,8 +64,18 @@ TOKEN [^[:space:](),]+
|
|||
return ELIF;
|
||||
}
|
||||
|
||||
<ST_IF>{INTEGER} {
|
||||
yylval.ival = atoi (yytext);
|
||||
<ST_IF>{DECIMAL_INTEGER} {
|
||||
yylval.ival = strtoll (yytext, NULL, 10);
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
<ST_IF>{OCTAL_INTEGER} {
|
||||
yylval.ival = strtoll (yytext + 1, NULL, 8);
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
<ST_IF>{HEXADECIMAL_INTEGER} {
|
||||
yylval.ival = strtoll (yytext + 2, NULL, 16);
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue