[cexpr] Use ` to allow identifiers to start with a number

The generated short names for a lot of Vulkan enums start with a number
(eg VK_IMAGE_TYPE_2D -> 2d). Having to prefix the short name with ` is a
tiny cost for the convenience.
This commit is contained in:
Bill Currie 2021-12-02 13:40:52 +09:00
parent a6703c95cf
commit 614c744693

View file

@ -108,7 +108,8 @@ m [\-+]
D [0-9] D [0-9]
B [01] B [01]
X [0-9a-fA-F] X [0-9a-fA-F]
ID [a-zA-Z_][a-zA-Z_0-9]* id [a-zA-Z_0-9]*
ID [a-zA-Z_]{id}
FLOAT ({D}+|{D}*\.{D}+|{D}+\.{D}*)([eE]{m}?{D}+)? FLOAT ({D}+|{D}*\.{D}+|{D}+\.{D}*)([eE]{m}?{D}+)?
FLOATf {FLOAT}[fF] FLOATf {FLOAT}[fF]
FLOATd {FLOAT}[dD] FLOATd {FLOAT}[dD]
@ -153,6 +154,11 @@ STRING \"(\\.|[^"\\])*\"
return NAME; return NAME;
} }
`{id} {
yylval->symbol = parse_name (yytext + 1, context);
return NAME;
}
\${ID} { \${ID} {
yylval->value = parse_variable (yytext + 1, context); yylval->value = parse_variable (yytext + 1, context);
return VALUE; return VALUE;