glsl: Use | action in the lexer source to avoid duplicating the float action

Flex and lex have a special action ‘|’ which means to use the same action as
the next rule. We can use this to reduce a bit of code duplication in the
rules for the various float literal formats.

Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Neil Roberts 2014-11-26 17:57:42 +00:00
parent 9d8aa88693
commit c97cbd7e3d
1 changed files with 3 additions and 12 deletions

View File

@ -450,18 +450,9 @@ layout {
return LITERAL_INTEGER(8);
}
[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
yylval->real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
yylval->real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
[0-9]+\.([eE][+-]?[0-9]+)?[fF]? {
yylval->real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? |
\.[0-9]+([eE][+-]?[0-9]+)?[fF]? |
[0-9]+\.([eE][+-]?[0-9]+)?[fF]? |
[0-9]+[eE][+-]?[0-9]+[fF]? {
yylval->real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;