glsl: Remove integer matrix support from ir_dereference_array::constant_expression_value
[mesa.git] / src / compiler / glsl / glsl_lexer.ll
index 5492045f7c3ab57a74c387630c13fe2a6c97c685..7d7ee0c00ff780d593352f88f573d9a2a1c130c2 100644 (file)
 #include "ast.h"
 #include "glsl_parser_extras.h"
 #include "glsl_parser.h"
+#include "main/mtypes.h"
 
-static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
+static int classify_identifier(struct _mesa_glsl_parse_state *, const char *,
+                              unsigned name_len, YYSTYPE *output);
 
 #ifdef _MSC_VER
 #define YY_NO_UNISTD_H
 #endif
 
+#define YY_NO_INPUT
 #define YY_USER_ACTION                                         \
    do {                                                                \
       yylloc->first_column = yycolumn + 1;                     \
@@ -42,7 +45,8 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
       yylloc->last_column = yycolumn + 1;                      \
    } while(0);
 
-#define YY_USER_INIT yylineno = 0; yycolumn = 0; yylloc->source = 0;
+#define YY_USER_INIT yylineno = 0; yycolumn = 0; yylloc->source = 0; \
+   yylloc->path = NULL;
 
 /* A macro for handling reserved words and keywords across language versions.
  *
@@ -80,12 +84,38 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
                          "illegal use of reserved word `%s'", yytext); \
         return ERROR_TOK;                                              \
       } else {                                                         \
-        void *mem_ctx = yyextra;                                       \
-        yylval->identifier = ralloc_strdup(mem_ctx, yytext);           \
-        return classify_identifier(yyextra, yytext);                   \
+        return classify_identifier(yyextra, yytext, yyleng, yylval);   \
       }                                                                        \
    } while (0)
 
+/**
+ * Like KEYWORD_WITH_ALT, but used for built-in GLSL types
+ */
+#define TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es,                 \
+                     allowed_glsl, allowed_glsl_es,                    \
+                     alt_expr, gtype)                                  \
+   do {                                                                        \
+      if (yyextra->is_version(allowed_glsl, allowed_glsl_es)           \
+          || (alt_expr)) {                                             \
+        yylval->type = gtype;                                          \
+        return BASIC_TYPE_TOK;                                         \
+      } else if (yyextra->is_version(reserved_glsl,                    \
+                                     reserved_glsl_es)) {              \
+        _mesa_glsl_error(yylloc, yyextra,                              \
+                         "illegal use of reserved word `%s'", yytext); \
+        return ERROR_TOK;                                              \
+      } else {                                                         \
+        return classify_identifier(yyextra, yytext, yyleng, yylval);   \
+      }                                                                        \
+   } while (0)
+
+#define TYPE(reserved_glsl, reserved_glsl_es,                          \
+             allowed_glsl, allowed_glsl_es,                            \
+             gtype)                                                    \
+   TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es,                      \
+                 allowed_glsl, allowed_glsl_es,                                \
+                 false, gtype)
+
 /**
  * A macro for handling keywords that have been present in GLSL since
  * its origin, but were changed into reserved words in GLSL 3.00 ES.
@@ -101,23 +131,55 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
       }                                                                        \
    } while (0)
 
+/**
+ * Like DEPRECATED_ES_KEYWORD, but for types
+ */
+#define DEPRECATED_ES_TYPE_WITH_ALT(alt_expr, gtype)                   \
+   do {                                                                        \
+      if (yyextra->is_version(0, 300)) {                               \
+         _mesa_glsl_error(yylloc, yyextra,                             \
+                          "illegal use of reserved word `%s'", yytext);        \
+         return ERROR_TOK;                                             \
+      } else if (alt_expr) {                                           \
+         yylval->type = gtype;                                         \
+         return BASIC_TYPE_TOK;                                                \
+      } else {                                                         \
+         return classify_identifier(yyextra, yytext, yyleng, yylval);  \
+      }                                                                        \
+   } while (0)
+
+#define DEPRECATED_ES_TYPE(gtype)                                      \
+   DEPRECATED_ES_TYPE_WITH_ALT(true, gtype)
+
 static int
 literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
                YYSTYPE *lval, YYLTYPE *lloc, int base)
 {
    bool is_uint = (text[len - 1] == 'u' ||
                   text[len - 1] == 'U');
+   bool is_long = (text[len - 1] == 'l' || text[len - 1] == 'L');
    const char *digits = text;
 
+   if (is_long)
+      is_uint = (text[len - 2] == 'u' && text[len - 1] == 'l') ||
+                (text[len - 2] == 'U' && text[len - 1] == 'L');
    /* Skip "0x" */
    if (base == 16)
       digits += 2;
 
    unsigned long long value = strtoull(digits, NULL, base);
 
-   lval->n = (int)value;
+   if (is_long)
+      lval->n64 = (int64_t)value;
+   else
+      lval->n = (int)value;
 
-   if (value > UINT_MAX) {
+   if (is_long && !is_uint && base == 10 && value > (uint64_t)LLONG_MAX + 1) {
+      /* Tries to catch unintentionally providing a negative value. */
+      _mesa_glsl_warning(lloc, state,
+                         "signed literal value `%s' is interpreted as %lld",
+                         text, lval->n64);
+   } else if (!is_long && value > UINT_MAX) {
       /* Note that signed 0xffffffff is valid, not out of range! */
       if (state->is_version(130, 300)) {
         _mesa_glsl_error(lloc, state,
@@ -135,7 +197,10 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
                         "signed literal value `%s' is interpreted as %d",
                         text, lval->n);
    }
-   return is_uint ? UINTCONSTANT : INTCONSTANT;
+   if (is_long)
+      return is_uint ? UINT64CONSTANT : INT64CONSTANT;
+   else
+      return is_uint ? UINTCONSTANT : INTCONSTANT;
 }
 
 #define LITERAL_INTEGER(base) \
@@ -162,6 +227,7 @@ INT         ({DEC_INT}|{HEX_INT}|{OCT_INT})
 SPC            [ \t]*
 SPCP           [ \t]+
 HASH           ^{SPC}#{SPC}
+PATH           ["][./ _A-Za-z0-9]*["]
 %%
 
 [ \r\t]+               ;
@@ -170,6 +236,14 @@ HASH               ^{SPC}#{SPC}
 ^[ \t]*#[ \t]*$                        ;
 ^[ \t]*#[ \t]*version          { BEGIN PP; return VERSION_TOK; }
 ^[ \t]*#[ \t]*extension                { BEGIN PP; return EXTENSION; }
+{HASH}include {
+                                  if (!yyextra->ARB_shading_language_include_enable) {
+                                     struct _mesa_glsl_parse_state *state = yyextra;
+                                     _mesa_glsl_error(yylloc, state,
+                                                      "ARB_shading_language_include required "
+                                                      "to use #include");
+                                   }
+}
 {HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ {
                                   /* Eat characters until the first digit is
                                    * encountered
@@ -193,7 +267,50 @@ HASH               ^{SPC}#{SPC}
                                       yylineno--;
 
                                   yylloc->source = strtol(ptr, NULL, 0);
+                                   yylloc->path = NULL;
                                }
+{HASH}line{SPCP}{INT}{SPCP}{PATH}{SPC}$ {
+                                   if (!yyextra->ARB_shading_language_include_enable) {
+                                      struct _mesa_glsl_parse_state *state = yyextra;
+                                      _mesa_glsl_error(yylloc, state,
+                                                       "ARB_shading_language_include required "
+                                                       "to use #line <line> \"<path>\"");
+                                   }
+
+                                   /* Eat characters until the first digit is
+                                    * encountered
+                                    */
+                                   char *ptr = yytext;
+                                   while (!isdigit(*ptr))
+                                      ptr++;
+
+                                   /* Subtract one from the line number because
+                                    * yylineno is zero-based instead of
+                                    * one-based.
+                                    */
+                                   yylineno = strtol(ptr, &ptr, 0) - 1;
+
+                                   /* From GLSL 3.30 and GLSL ES on, after processing the
+                                    * line directive (including its new-line), the implementation
+                                    * will behave as if it is compiling at the line number passed
+                                    * as argument. It was line number + 1 in older specifications.
+                                    */
+                                   if (yyextra->is_version(330, 100))
+                                      yylineno--;
+
+                                   while (isspace(*ptr))
+                                      ptr++;
+
+                                   /* Skip over leading " */
+                                   ptr++;
+
+                                   char *end = strrchr(ptr, '"');
+                                   int path_len = (end - ptr) + 1;
+                                   void *mem_ctx = yyextra->linalloc;
+                                   yylloc->path = (char *) linear_alloc_child(mem_ctx, path_len);
+                                   memcpy(yylloc->path, ptr, path_len);
+                                   yylloc->path[path_len - 1] = '\0';
+                                }
 {HASH}line{SPCP}{INT}{SPC}$    {
                                   /* Eat characters until the first digit is
                                    * encountered
@@ -232,6 +349,14 @@ HASH               ^{SPC}#{SPC}
                                  BEGIN PP;
                                  return PRAGMA_OPTIMIZE_OFF;
                                }
+^{SPC}#{SPC}pragma{SPCP}warning{SPC}\({SPC}on{SPC}\) {
+                                 BEGIN PP;
+                                 return PRAGMA_WARNING_ON;
+                               }
+^{SPC}#{SPC}pragma{SPCP}warning{SPC}\({SPC}off{SPC}\) {
+                                 BEGIN PP;
+                                 return PRAGMA_WARNING_OFF;
+                               }
 ^{SPC}#{SPC}pragma{SPCP}STDGL{SPCP}invariant{SPC}\({SPC}all{SPC}\) {
                                  BEGIN PP;
                                  return PRAGMA_INVARIANT_ALL;
@@ -245,14 +370,24 @@ HASH              ^{SPC}#{SPC}
 <PP>[ \t\r]*                   { }
 <PP>:                          return COLON;
 <PP>[_a-zA-Z][_a-zA-Z0-9]*     {
-                                  void *mem_ctx = yyextra;
-                                  yylval->identifier = ralloc_strdup(mem_ctx, yytext);
+                                  /* We're not doing linear_strdup here, to avoid an implicit call
+                                   * on strlen() for the length of the string, as this is already
+                                   * found by flex and stored in yyleng
+                                   */
+                                    void *mem_ctx = yyextra->linalloc;
+                                    char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1);
+                                    memcpy(id, yytext, yyleng + 1);
+                                    yylval->identifier = id;
                                   return IDENTIFIER;
                                }
 <PP>[1-9][0-9]*                        {
                                    yylval->n = strtol(yytext, NULL, 10);
                                    return INTCONSTANT;
                                }
+<PP>0                          {
+                                   yylval->n = 0;
+                                   return INTCONSTANT;
+                               }
 <PP>\n                         { BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
 <PP>.                          { return yytext[0]; }
 
@@ -260,10 +395,10 @@ HASH              ^{SPC}#{SPC}
 
 attribute      DEPRECATED_ES_KEYWORD(ATTRIBUTE);
 const          return CONST_TOK;
-bool           return BOOL_TOK;
-float          return FLOAT_TOK;
-int            return INT_TOK;
-uint           KEYWORD(130, 300, 130, 300, UINT_TOK);
+bool           { yylval->type = glsl_type::bool_type; return BASIC_TYPE_TOK; }
+float          { yylval->type = glsl_type::float_type; return BASIC_TYPE_TOK; }
+int            { yylval->type = glsl_type::int_type; return BASIC_TYPE_TOK; }
+uint           TYPE(130, 300, 130, 300, glsl_type::uint_type);
 
 break          return BREAK;
 continue       return CONTINUE;
@@ -274,89 +409,91 @@ for               return FOR;
 if             return IF;
 discard                return DISCARD;
 return         return RETURN;
-
-bvec2          return BVEC2;
-bvec3          return BVEC3;
-bvec4          return BVEC4;
-ivec2          return IVEC2;
-ivec3          return IVEC3;
-ivec4          return IVEC4;
-uvec2          KEYWORD(130, 300, 130, 300, UVEC2);
-uvec3          KEYWORD(130, 300, 130, 300, UVEC3);
-uvec4          KEYWORD(130, 300, 130, 300, UVEC4);
-vec2           return VEC2;
-vec3           return VEC3;
-vec4           return VEC4;
-mat2           return MAT2X2;
-mat3           return MAT3X3;
-mat4           return MAT4X4;
-mat2x2         KEYWORD(120, 300, 120, 300, MAT2X2);
-mat2x3         KEYWORD(120, 300, 120, 300, MAT2X3);
-mat2x4         KEYWORD(120, 300, 120, 300, MAT2X4);
-mat3x2         KEYWORD(120, 300, 120, 300, MAT3X2);
-mat3x3         KEYWORD(120, 300, 120, 300, MAT3X3);
-mat3x4         KEYWORD(120, 300, 120, 300, MAT3X4);
-mat4x2         KEYWORD(120, 300, 120, 300, MAT4X2);
-mat4x3         KEYWORD(120, 300, 120, 300, MAT4X3);
-mat4x4         KEYWORD(120, 300, 120, 300, MAT4X4);
+demote         KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->EXT_demote_to_helper_invocation_enable, DEMOTE);
+
+bvec2          { yylval->type = glsl_type::bvec2_type; return BASIC_TYPE_TOK; }
+bvec3          { yylval->type = glsl_type::bvec3_type; return BASIC_TYPE_TOK; }
+bvec4          { yylval->type = glsl_type::bvec4_type; return BASIC_TYPE_TOK; }
+ivec2          { yylval->type = glsl_type::ivec2_type; return BASIC_TYPE_TOK; }
+ivec3          { yylval->type = glsl_type::ivec3_type; return BASIC_TYPE_TOK; }
+ivec4          { yylval->type = glsl_type::ivec4_type; return BASIC_TYPE_TOK; }
+uvec2          TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec2_type);
+uvec3          TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec3_type);
+uvec4          TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec4_type);
+vec2           { yylval->type = glsl_type::vec2_type; return BASIC_TYPE_TOK; }
+vec3           { yylval->type = glsl_type::vec3_type; return BASIC_TYPE_TOK; }
+vec4           { yylval->type = glsl_type::vec4_type; return BASIC_TYPE_TOK; }
+mat2           { yylval->type = glsl_type::mat2_type; return BASIC_TYPE_TOK; }
+mat3           { yylval->type = glsl_type::mat3_type; return BASIC_TYPE_TOK; }
+mat4           { yylval->type = glsl_type::mat4_type; return BASIC_TYPE_TOK; }
+mat2x2         TYPE(120, 300, 120, 300, glsl_type::mat2_type);
+mat2x3         TYPE(120, 300, 120, 300, glsl_type::mat2x3_type);
+mat2x4         TYPE(120, 300, 120, 300, glsl_type::mat2x4_type);
+mat3x2         TYPE(120, 300, 120, 300, glsl_type::mat3x2_type);
+mat3x3         TYPE(120, 300, 120, 300, glsl_type::mat3_type);
+mat3x4         TYPE(120, 300, 120, 300, glsl_type::mat3x4_type);
+mat4x2         TYPE(120, 300, 120, 300, glsl_type::mat4x2_type);
+mat4x3         TYPE(120, 300, 120, 300, glsl_type::mat4x3_type);
+mat4x4         TYPE(120, 300, 120, 300, glsl_type::mat4_type);
 
 in             return IN_TOK;
 out            return OUT_TOK;
 inout          return INOUT_TOK;
 uniform                return UNIFORM;
-buffer         return BUFFER;
+buffer         KEYWORD_WITH_ALT(0, 0, 430, 310, yyextra->ARB_shader_storage_buffer_object_enable, BUFFER);
 varying                DEPRECATED_ES_KEYWORD(VARYING);
-centroid       KEYWORD(120, 300, 120, 300, CENTROID);
+centroid       KEYWORD_WITH_ALT(120, 300, 120, 300, yyextra->EXT_gpu_shader4_enable, CENTROID);
 invariant      KEYWORD(120, 100, 120, 100, INVARIANT);
-flat           KEYWORD(130, 100, 130, 300, FLAT);
+flat           KEYWORD_WITH_ALT(130, 100, 130, 300, yyextra->EXT_gpu_shader4_enable, FLAT);
 smooth         KEYWORD(130, 300, 130, 300, SMOOTH);
-noperspective  KEYWORD(130, 300, 130, 0, NOPERSPECTIVE);
-patch          KEYWORD_WITH_ALT(0, 300, 400, 0, yyextra->ARB_tessellation_shader_enable, PATCH);
-
-sampler1D      DEPRECATED_ES_KEYWORD(SAMPLER1D);
-sampler2D      return SAMPLER2D;
-sampler3D      return SAMPLER3D;
-samplerCube    return SAMPLERCUBE;
-sampler1DArray KEYWORD(130, 300, 130, 0, SAMPLER1DARRAY);
-sampler2DArray KEYWORD(130, 300, 130, 300, SAMPLER2DARRAY);
-sampler1DShadow        DEPRECATED_ES_KEYWORD(SAMPLER1DSHADOW);
-sampler2DShadow        return SAMPLER2DSHADOW;
-samplerCubeShadow      KEYWORD(130, 300, 130, 300, SAMPLERCUBESHADOW);
-sampler1DArrayShadow   KEYWORD(130, 300, 130, 0, SAMPLER1DARRAYSHADOW);
-sampler2DArrayShadow   KEYWORD(130, 300, 130, 300, SAMPLER2DARRAYSHADOW);
-isampler1D             KEYWORD(130, 300, 130, 0, ISAMPLER1D);
-isampler2D             KEYWORD(130, 300, 130, 300, ISAMPLER2D);
-isampler3D             KEYWORD(130, 300, 130, 300, ISAMPLER3D);
-isamplerCube           KEYWORD(130, 300, 130, 300, ISAMPLERCUBE);
-isampler1DArray                KEYWORD(130, 300, 130, 0, ISAMPLER1DARRAY);
-isampler2DArray                KEYWORD(130, 300, 130, 300, ISAMPLER2DARRAY);
-usampler1D             KEYWORD(130, 300, 130, 0, USAMPLER1D);
-usampler2D             KEYWORD(130, 300, 130, 300, USAMPLER2D);
-usampler3D             KEYWORD(130, 300, 130, 300, USAMPLER3D);
-usamplerCube           KEYWORD(130, 300, 130, 300, USAMPLERCUBE);
-usampler1DArray                KEYWORD(130, 300, 130, 0, USAMPLER1DARRAY);
-usampler2DArray                KEYWORD(130, 300, 130, 300, USAMPLER2DARRAY);
+noperspective  KEYWORD_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, NOPERSPECTIVE);
+patch          KEYWORD_WITH_ALT(0, 300, 400, 320, yyextra->has_tessellation_shader(), PATCH);
+
+sampler1D      DEPRECATED_ES_TYPE(glsl_type::sampler1D_type);
+sampler2D      { yylval->type = glsl_type::sampler2D_type; return BASIC_TYPE_TOK; }
+sampler3D      { yylval->type = glsl_type::sampler3D_type; return BASIC_TYPE_TOK; }
+samplerCube    { yylval->type = glsl_type::samplerCube_type; return BASIC_TYPE_TOK; }
+sampler1DArray TYPE_WITH_ALT(130, 300, 130, 0,   yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArray_type);
+sampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArray_type);
+sampler1DShadow        DEPRECATED_ES_TYPE(glsl_type::sampler1DShadow_type);
+sampler2DShadow        { yylval->type = glsl_type::sampler2DShadow_type; return BASIC_TYPE_TOK; }
+samplerCubeShadow      TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::samplerCubeShadow_type);
+sampler1DArrayShadow   TYPE_WITH_ALT(130, 300, 130, 0,   yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArrayShadow_type);
+sampler2DArrayShadow   TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArrayShadow_type);
+isampler1D             TYPE_WITH_ALT(130, 300, 130, 0,   yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler1D_type);
+isampler2D             TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler2D_type);
+isampler3D             TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler3D_type);
+isamplerCube           TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isamplerCube_type);
+isampler1DArray                TYPE_WITH_ALT(130, 300, 130, 0,   yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::isampler1DArray_type);
+isampler2DArray                TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::isampler2DArray_type);
+usampler1D             TYPE_WITH_ALT(130, 300, 130, 0,   yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler1D_type);
+usampler2D             TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler2D_type);
+usampler3D             TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler3D_type);
+usamplerCube           TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usamplerCube_type);
+usampler1DArray                TYPE_WITH_ALT(130, 300, 130, 0,   yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::usampler1DArray_type);
+usampler2DArray                TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::usampler2DArray_type);
 
    /* additional keywords in ARB_texture_multisample, included in GLSL 1.50 */
    /* these are reserved but not defined in GLSL 3.00 */
    /* [iu]sampler2DMS are defined in GLSL ES 3.10 */
-sampler2DMS        KEYWORD_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, SAMPLER2DMS);
-isampler2DMS       KEYWORD_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, ISAMPLER2DMS);
-usampler2DMS       KEYWORD_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, USAMPLER2DMS);
-sampler2DMSArray   KEYWORD_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, SAMPLER2DMSARRAY);
-isampler2DMSArray  KEYWORD_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, ISAMPLER2DMSARRAY);
-usampler2DMSArray  KEYWORD_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, USAMPLER2DMSARRAY);
+sampler2DMS        TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::sampler2DMS_type);
+isampler2DMS       TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::isampler2DMS_type);
+usampler2DMS       TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::usampler2DMS_type);
+sampler2DMSArray   TYPE_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, glsl_type::sampler2DMSArray_type);
+isampler2DMSArray  TYPE_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, glsl_type::isampler2DMSArray_type);
+usampler2DMSArray  TYPE_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, glsl_type::usampler2DMSArray_type);
 
    /* keywords available with ARB_texture_cube_map_array_enable extension on desktop GLSL */
-samplerCubeArray   KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAY);
-isamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, ISAMPLERCUBEARRAY);
-usamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, USAMPLERCUBEARRAY);
-samplerCubeArrayShadow   KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAYSHADOW);
+samplerCubeArray   TYPE_WITH_ALT(400, 310, 400, 320, yyextra->ARB_texture_cube_map_array_enable || yyextra->OES_texture_cube_map_array_enable || yyextra->EXT_texture_cube_map_array_enable, glsl_type::samplerCubeArray_type);
+isamplerCubeArray TYPE_WITH_ALT(400, 310, 400, 320, yyextra->ARB_texture_cube_map_array_enable || yyextra->OES_texture_cube_map_array_enable || yyextra->EXT_texture_cube_map_array_enable, glsl_type::isamplerCubeArray_type);
+usamplerCubeArray TYPE_WITH_ALT(400, 310, 400, 320, yyextra->ARB_texture_cube_map_array_enable || yyextra->OES_texture_cube_map_array_enable || yyextra->EXT_texture_cube_map_array_enable, glsl_type::usamplerCubeArray_type);
+samplerCubeArrayShadow   TYPE_WITH_ALT(400, 310, 400, 320, yyextra->ARB_texture_cube_map_array_enable || yyextra->OES_texture_cube_map_array_enable || yyextra->EXT_texture_cube_map_array_enable, glsl_type::samplerCubeArrayShadow_type);
 
 samplerExternalOES             {
-                         if (yyextra->OES_EGL_image_external_enable)
-                            return SAMPLEREXTERNALOES;
-                         else
+                         if (yyextra->OES_EGL_image_external_enable || yyextra->OES_EGL_image_external_essl3_enable) {
+                            yylval->type = glsl_type::samplerExternalOES_type;
+                            return BASIC_TYPE_TOK;
+                         } else
                             return IDENTIFIER;
                }
 
@@ -364,51 +501,51 @@ samplerExternalOES                {
 precise                KEYWORD_WITH_ALT(400, 310, 400, 320, yyextra->ARB_gpu_shader5_enable || yyextra->EXT_gpu_shader5_enable || yyextra->OES_gpu_shader5_enable, PRECISE);
 
    /* keywords available with ARB_shader_image_load_store */
-image1D         KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE1D);
-image2D         KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IMAGE2D);
-image3D         KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IMAGE3D);
-image2DRect     KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2DRECT);
-imageCube       KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IMAGECUBE);
-imageBuffer     KEYWORD_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, IMAGEBUFFER);
-image1DArray    KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE1DARRAY);
-image2DArray    KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IMAGE2DARRAY);
-imageCubeArray  KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGECUBEARRAY);
-image2DMS       KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2DMS);
-image2DMSArray  KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2DMSARRAY);
-iimage1D        KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE1D);
-iimage2D        KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IIMAGE2D);
-iimage3D        KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IIMAGE3D);
-iimage2DRect    KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DRECT);
-iimageCube      KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IIMAGECUBE);
-iimageBuffer    KEYWORD_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, IIMAGEBUFFER);
-iimage1DArray   KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE1DARRAY);
-iimage2DArray   KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DARRAY);
-iimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGECUBEARRAY);
-iimage2DMS      KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DMS);
-iimage2DMSArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DMSARRAY);
-uimage1D        KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE1D);
-uimage2D        KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, UIMAGE2D);
-uimage3D        KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, UIMAGE3D);
-uimage2DRect    KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DRECT);
-uimageCube      KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, UIMAGECUBE);
-uimageBuffer    KEYWORD_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, UIMAGEBUFFER);
-uimage1DArray   KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE1DARRAY);
-uimage2DArray   KEYWORD_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DARRAY);
-uimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGECUBEARRAY);
-uimage2DMS      KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DMS);
-uimage2DMSArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DMSARRAY);
+image1D         TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image1D_type);
+image2D         TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image2D_type);
+image3D         TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image3D_type);
+image2DRect     TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image2DRect_type);
+imageCube       TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::imageCube_type);
+imageBuffer     TYPE_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, glsl_type::imageBuffer_type);
+image1DArray    TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image1DArray_type);
+image2DArray    TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image2DArray_type);
+imageCubeArray  TYPE_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->OES_texture_cube_map_array_enable || yyextra->EXT_texture_cube_map_array_enable, glsl_type::imageCubeArray_type);
+image2DMS       TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image2DMS_type);
+image2DMSArray  TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::image2DMSArray_type);
+iimage1D        TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage1D_type);
+iimage2D        TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage2D_type);
+iimage3D        TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage3D_type);
+iimage2DRect    TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage2DRect_type);
+iimageCube      TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimageCube_type);
+iimageBuffer    TYPE_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, glsl_type::iimageBuffer_type);
+iimage1DArray   TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage1DArray_type);
+iimage2DArray   TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage2DArray_type);
+iimageCubeArray TYPE_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->OES_texture_cube_map_array_enable || yyextra->EXT_texture_cube_map_array_enable, glsl_type::iimageCubeArray_type);
+iimage2DMS      TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage2DMS_type);
+iimage2DMSArray TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::iimage2DMSArray_type);
+uimage1D        TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage1D_type);
+uimage2D        TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage2D_type);
+uimage3D        TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage3D_type);
+uimage2DRect    TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage2DRect_type);
+uimageCube      TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimageCube_type);
+uimageBuffer    TYPE_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, glsl_type::uimageBuffer_type);
+uimage1DArray   TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage1DArray_type);
+uimage2DArray   TYPE_WITH_ALT(130, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage2DArray_type);
+uimageCubeArray TYPE_WITH_ALT(130, 300, 420, 320, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->OES_texture_cube_map_array_enable || yyextra->EXT_texture_cube_map_array_enable, glsl_type::uimageCubeArray_type);
+uimage2DMS      TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage2DMS_type);
+uimage2DMSArray TYPE_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable, glsl_type::uimage2DMSArray_type);
 image1DShadow           KEYWORD(130, 300, 0, 0, IMAGE1DSHADOW);
 image2DShadow           KEYWORD(130, 300, 0, 0, IMAGE2DSHADOW);
 image1DArrayShadow      KEYWORD(130, 300, 0, 0, IMAGE1DARRAYSHADOW);
 image2DArrayShadow      KEYWORD(130, 300, 0, 0, IMAGE2DARRAYSHADOW);
 
-coherent       KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, COHERENT);
-volatile       KEYWORD_WITH_ALT(110, 100, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, VOLATILE);
-restrict       KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, RESTRICT);
+coherent       KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, COHERENT);
+volatile       KEYWORD_WITH_ALT(110, 100, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, VOLATILE);
+restrict       KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->EXT_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, RESTRICT);
 readonly       KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, READONLY);
 writeonly      KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, WRITEONLY);
 
-atomic_uint     KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT);
+atomic_uint     TYPE_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_atomic_counters_enable, glsl_type::atomic_uint_type);
 
 shared          KEYWORD_WITH_ALT(430, 310, 430, 310, yyextra->ARB_compute_shader_enable, SHARED);
 
@@ -417,21 +554,23 @@ void              return VOID_TOK;
 
 layout         {
                  if ((yyextra->is_version(140, 300))
+                     || yyextra->ARB_bindless_texture_enable
+                     || yyextra->KHR_blend_equation_advanced_enable
                      || yyextra->AMD_conservative_depth_enable
                      || yyextra->ARB_conservative_depth_enable
                      || yyextra->ARB_explicit_attrib_location_enable
                      || yyextra->ARB_explicit_uniform_location_enable
+                      || yyextra->ARB_post_depth_coverage_enable
                       || yyextra->has_separate_shader_objects()
                      || yyextra->ARB_uniform_buffer_object_enable
                      || yyextra->ARB_fragment_coord_conventions_enable
                       || yyextra->ARB_shading_language_420pack_enable
                       || yyextra->ARB_compute_shader_enable
-                      || yyextra->ARB_tessellation_shader_enable) {
+                      || yyextra->ARB_tessellation_shader_enable
+                      || yyextra->EXT_shader_framebuffer_fetch_non_coherent_enable) {
                      return LAYOUT_TOK;
                   } else {
-                     void *mem_ctx = yyextra;
-                     yylval->identifier = ralloc_strdup(mem_ctx, yytext);
-                     return classify_identifier(yyextra, yytext);
+                     return classify_identifier(yyextra, yytext, yyleng, yylval);
                   }
                }
 
@@ -458,13 +597,13 @@ layout            {
 \|=            return OR_ASSIGN;
 -=             return SUB_ASSIGN;
 
-[1-9][0-9]*[uU]?       {
+[1-9][0-9]*([uU]|[lL]|ul|UL)?  {
                            return LITERAL_INTEGER(10);
                        }
-0[xX][0-9a-fA-F]+[uU]? {
+0[xX][0-9a-fA-F]+([uU]|[lL]|ul|UL)?    {
                            return LITERAL_INTEGER(16);
                        }
-0[0-7]*[uU]?           {
+0[0-7]*([uU]|[lL]|ul|UL)?              {
                            return LITERAL_INTEGER(8);
                        }
 
@@ -476,8 +615,8 @@ layout              {
                            char suffix = yytext[strlen(yytext) - 1];
                            if (!state->is_version(120, 300) &&
                                (suffix == 'f' || suffix == 'F')) {
-                               _mesa_glsl_error(yylloc, state,
-                                                "Float suffixes are invalid in GLSL 1.10");
+                               _mesa_glsl_warning(yylloc, state,
+                                                  "Float suffixes are invalid in GLSL 1.10");
                            }
                            yylval->real = _mesa_strtof(yytext, NULL);
                            return FLOATCONSTANT;
@@ -525,36 +664,36 @@ external  KEYWORD(110, 100, 0, 0, EXTERNAL);
 interface      KEYWORD(110, 100, 0, 0, INTERFACE);
 long           KEYWORD(110, 100, 0, 0, LONG_TOK);
 short          KEYWORD(110, 100, 0, 0, SHORT_TOK);
-double         KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DOUBLE_TOK);
+double         TYPE_WITH_ALT(130, 100, 130, 300, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::double_type);
 half           KEYWORD(110, 100, 0, 0, HALF);
 fixed          KEYWORD(110, 100, 0, 0, FIXED_TOK);
-unsigned       KEYWORD(110, 100, 0, 0, UNSIGNED);
+unsigned       KEYWORD_WITH_ALT(110, 100, 0, 0, yyextra->EXT_gpu_shader4_enable, UNSIGNED);
 input          KEYWORD(110, 100, 0, 0, INPUT_TOK);
 output         KEYWORD(110, 100, 0, 0, OUTPUT);
 hvec2          KEYWORD(110, 100, 0, 0, HVEC2);
 hvec3          KEYWORD(110, 100, 0, 0, HVEC3);
 hvec4          KEYWORD(110, 100, 0, 0, HVEC4);
-dvec2          KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DVEC2);
-dvec3          KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DVEC3);
-dvec4          KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DVEC4);
-dmat2          KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X2);
-dmat3          KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X3);
-dmat4          KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X4);
-dmat2x2                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X2);
-dmat2x3                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X3);
-dmat2x4                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X4);
-dmat3x2                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X2);
-dmat3x3                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X3);
-dmat3x4                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X4);
-dmat4x2                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X2);
-dmat4x3                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X3);
-dmat4x4                KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X4);
+dvec2          TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec2_type);
+dvec3          TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec3_type);
+dvec4          TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec4_type);
+dmat2          TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2_type);
+dmat3          TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3_type);
+dmat4          TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4_type);
+dmat2x2                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2_type);
+dmat2x3                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2x3_type);
+dmat2x4                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2x4_type);
+dmat3x2                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3x2_type);
+dmat3x3                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3_type);
+dmat3x4                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3x4_type);
+dmat4x2                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4x2_type);
+dmat4x3                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4x3_type);
+dmat4x4                TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4_type);
 fvec2          KEYWORD(110, 100, 0, 0, FVEC2);
 fvec3          KEYWORD(110, 100, 0, 0, FVEC3);
 fvec4          KEYWORD(110, 100, 0, 0, FVEC4);
-sampler2DRect          DEPRECATED_ES_KEYWORD(SAMPLER2DRECT);
+sampler2DRect          TYPE_WITH_ALT(110, 100, 0, 0, yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRect_type);
 sampler3DRect          KEYWORD(110, 100, 0, 0, SAMPLER3DRECT);
-sampler2DRectShadow    DEPRECATED_ES_KEYWORD(SAMPLER2DRECTSHADOW);
+sampler2DRectShadow    TYPE_WITH_ALT(110, 100, 0, 0, yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRectShadow_type);
 sizeof         KEYWORD(110, 100, 0, 0, SIZEOF);
 cast           KEYWORD(110, 100, 0, 0, CAST);
 namespace      KEYWORD(110, 100, 0, 0, NAMESPACE);
@@ -572,33 +711,40 @@ common            KEYWORD(130, 300, 0, 0, COMMON);
 partition      KEYWORD(130, 300, 0, 0, PARTITION);
 active         KEYWORD(130, 300, 0, 0, ACTIVE);
 superp         KEYWORD(130, 100, 0, 0, SUPERP);
-samplerBuffer  KEYWORD_WITH_ALT(130, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, SAMPLERBUFFER);
+samplerBuffer  TYPE_WITH_ALT(130, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || (yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_buffer_object), glsl_type::samplerBuffer_type);
 filter         KEYWORD(130, 300, 0, 0, FILTER);
 row_major      KEYWORD_WITH_ALT(130, 0, 140, 0, yyextra->ARB_uniform_buffer_object_enable && !yyextra->es_shader, ROW_MAJOR);
 
     /* Additional reserved words in GLSL 1.40 */
-isampler2DRect KEYWORD(140, 300, 140, 0, ISAMPLER2DRECT);
-usampler2DRect KEYWORD(140, 300, 140, 0, USAMPLER2DRECT);
-isamplerBuffer KEYWORD_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, ISAMPLERBUFFER);
-usamplerBuffer KEYWORD_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, USAMPLERBUFFER);
+isampler2DRect TYPE_WITH_ALT(140, 300, 140, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.NV_texture_rectangle && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler2DRect_type);
+usampler2DRect TYPE_WITH_ALT(140, 300, 140, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.NV_texture_rectangle && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler2DRect_type);
+isamplerBuffer TYPE_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || (yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_buffer_object && yyextra->ctx->Extensions.EXT_texture_integer), glsl_type::isamplerBuffer_type);
+usamplerBuffer TYPE_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || (yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_buffer_object && yyextra->ctx->Extensions.EXT_texture_integer), glsl_type::usamplerBuffer_type);
 
     /* Additional reserved words in GLSL ES 3.00 */
-resource       KEYWORD(0, 300, 0, 0, RESOURCE);
-sample         KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_gpu_shader5_enable, SAMPLE);
+resource       KEYWORD(420, 300, 0, 0, RESOURCE);
+sample         KEYWORD_WITH_ALT(400, 300, 400, 320, yyextra->ARB_gpu_shader5_enable || yyextra->OES_shader_multisample_interpolation_enable, SAMPLE);
 subroutine     KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_shader_subroutine_enable, SUBROUTINE);
 
+    /* Additional words for ARB_gpu_shader_int64 */
+int64_t                TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::int64_t_type);
+i64vec2                TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec2_type);
+i64vec3                TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec3_type);
+i64vec4                TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec4_type);
+
+uint64_t       TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::uint64_t_type);
+u64vec2                TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec2_type);
+u64vec3                TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec3_type);
+u64vec4                TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec4_type);
 
 [_a-zA-Z][_a-zA-Z0-9]* {
                            struct _mesa_glsl_parse_state *state = yyextra;
-                           void *ctx = state;  
-                           if (state->es_shader && strlen(yytext) > 1024) {
+                           if (state->es_shader && yyleng > 1024) {
                               _mesa_glsl_error(yylloc, state,
                                                "Identifier `%s' exceeds 1024 characters",
                                                yytext);
-                           } else {
-                             yylval->identifier = ralloc_strdup(ctx, yytext);
                            }
-                           return classify_identifier(state, yytext);
+                           return classify_identifier(state, yytext, yyleng, yylval);
                        }
 
 \.                     { struct _mesa_glsl_parse_state *state = yyextra;
@@ -610,8 +756,17 @@ subroutine KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_shader_subroutine_ena
 %%
 
 int
-classify_identifier(struct _mesa_glsl_parse_state *state, const char *name)
+classify_identifier(struct _mesa_glsl_parse_state *state, const char *name,
+                    unsigned name_len, YYSTYPE *output)
 {
+   /* We're not doing linear_strdup here, to avoid an implicit call on
+    * strlen() for the length of the string, as this is already found by flex
+    * and stored in yyleng
+    */
+   char *id = (char *) linear_alloc_child(state->linalloc, name_len + 1);
+   memcpy(id, name, name_len + 1);
+   output->identifier = id;
+
    if (state->is_field) {
       state->is_field = false;
       return FIELD_SELECTION;