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.
---
 src/glsl/glsl_lexer.ll | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 419a07b..57c46be 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -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;
-- 
1.9.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to