glsl: Use | action in the lexer source to avoid duplicating the float action
authorNeil Roberts <neil@linux.intel.com>
Wed, 26 Nov 2014 17:57:42 +0000 (17:57 +0000)
committerNeil Roberts <neil@linux.intel.com>
Thu, 27 Nov 2014 11:43:59 +0000 (11:43 +0000)
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>
src/glsl/glsl_lexer.ll

index 419a07b1daf8c92fc256b8084df5bc67974aec80..57c46be84ca537feebf4d205d8687dda87df1f2c 100644 (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;