nir/opcodes: Use fpclassify() instead of isnormal() for ldexp
[mesa.git] / src / glsl / glsl_lexer.ll
index 1cadf1f9b5802ec735b896a97a38ee5cabb45021..57c46be84ca537feebf4d205d8687dda87df1f2c 100644 (file)
@@ -23,7 +23,7 @@
  */
 #include <ctype.h>
 #include <limits.h>
-#include "strtod.h"
+#include "util/strtod.h"
 #include "ast.h"
 #include "glsl_parser_extras.h"
 #include "glsl_parser.h"
@@ -81,7 +81,8 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
                          "illegal use of reserved word `%s'", yytext); \
         return ERROR_TOK;                                              \
       } else {                                                         \
-        yylval->identifier = strdup(yytext);                           \
+        void *mem_ctx = yyextra;                                       \
+        yylval->identifier = ralloc_strdup(mem_ctx, yytext);           \
         return classify_identifier(yyextra, yytext);                   \
       }                                                                        \
    } while (0)
@@ -152,6 +153,7 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
 %option never-interactive
 %option prefix="_mesa_glsl_lexer_"
 %option extra-type="struct _mesa_glsl_parse_state *"
+%option warn nodefault
 
        /* Note: When adding any start conditions to this list, you must also
         * update the "Internal compiler error" catch-all rule near the end of
@@ -231,7 +233,8 @@ HASH                ^{SPC}#{SPC}
 <PP>[ \t\r]*                   { }
 <PP>:                          return COLON;
 <PP>[_a-zA-Z][_a-zA-Z0-9]*     {
-                                  yylval->identifier = strdup(yytext);
+                                  void *mem_ctx = yyextra;
+                                  yylval->identifier = ralloc_strdup(mem_ctx, yytext);
                                   return IDENTIFIER;
                                }
 <PP>[1-9][0-9]*                        {
@@ -239,6 +242,7 @@ HASH                ^{SPC}#{SPC}
                                    return INTCONSTANT;
                                }
 <PP>\n                         { BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
+<PP>.                          { return yytext[0]; }
 
 \n             { yylineno++; yycolumn = 0; }
 
@@ -407,7 +411,8 @@ layout              {
                       || yyextra->ARB_compute_shader_enable) {
                      return LAYOUT_TOK;
                   } else {
-                     yylval->identifier = strdup(yytext);
+                     void *mem_ctx = yyextra;
+                     yylval->identifier = ralloc_strdup(mem_ctx, yytext);
                      return classify_identifier(yyextra, yytext);
                   }
                }
@@ -445,24 +450,11 @@ layout            {
                            return LITERAL_INTEGER(8);
                        }
 
-[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]?  {
-                           yylval->real = glsl_strtof(yytext, NULL);
-                           return FLOATCONSTANT;
-                       }
-\.[0-9]+([eE][+-]?[0-9]+)?[fF]?                {
-                           yylval->real = glsl_strtof(yytext, NULL);
-                           return FLOATCONSTANT;
-                       }
-[0-9]+\.([eE][+-]?[0-9]+)?[fF]?                {
-                           yylval->real = glsl_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 = glsl_strtof(yytext, NULL);
-                           return FLOATCONSTANT;
-                       }
-[0-9]+[fF]             {
-                           yylval->real = glsl_strtof(yytext, NULL);
+                           yylval->real = _mesa_strtof(yytext, NULL);
                            return FLOATCONSTANT;
                        }
 
@@ -558,16 +550,6 @@ subroutine KEYWORD(0, 300, 0, 0, SUBROUTINE);
 
 .                      { return yytext[0]; }
 
-       /* This is a catch-all to avoid the annoying default flex action which
-        * matches any character and prints it. If any input ever matches this
-        * rule, then we have made a mistake above and need to fix one or more
-        * of the preceding patterns to match that input. */
-<PP,PRAGMA>. {
-       _mesa_glsl_error(yylloc, yyextra,
-                         "Internal compiler error: Unexpected character: %s", yytext);
-}
-
-
 %%
 
 int