1%{ 2/* 3 * Copyright © 2008, 2009 Intel Corporation 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 */ 24#include <ctype.h> 25#include <limits.h> 26#include "util/strtod.h" 27#include "ast.h" 28#include "glsl_parser_extras.h" 29#include "glsl_parser.h" 30#include "main/mtypes.h" 31 32static int classify_identifier(struct _mesa_glsl_parse_state *, const char *, 33 unsigned name_len, YYSTYPE *output); 34 35#ifdef _MSC_VER 36#define YY_NO_UNISTD_H 37#endif 38 39#define YY_NO_INPUT 40#define YY_USER_ACTION \ 41 do { \ 42 yylloc->first_column = yycolumn + 1; \ 43 yylloc->first_line = yylloc->last_line = yylineno + 1; \ 44 yycolumn += yyleng; \ 45 yylloc->last_column = yycolumn + 1; \ 46 } while(0); 47 48#define YY_USER_INIT yylineno = 0; yycolumn = 0; yylloc->source = 0; \ 49 yylloc->path = NULL; 50 51/* A macro for handling reserved words and keywords across language versions. 52 * 53 * Certain words start out as identifiers, become reserved words in 54 * later language revisions, and finally become language keywords. 55 * This may happen at different times in desktop GLSL and GLSL ES. 56 * 57 * For example, consider the following lexer rule: 58 * samplerBuffer KEYWORD(130, 0, 140, 0, SAMPLERBUFFER) 59 * 60 * This means that "samplerBuffer" will be treated as: 61 * - a keyword (SAMPLERBUFFER token) ...in GLSL >= 1.40 62 * - a reserved word - error ...in GLSL >= 1.30 63 * - an identifier ...in GLSL < 1.30 or GLSL ES 64 */ 65#define KEYWORD(reserved_glsl, reserved_glsl_es, \ 66 allowed_glsl, allowed_glsl_es, token) \ 67 KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es, \ 68 allowed_glsl, allowed_glsl_es, false, token) 69 70/** 71 * Like the KEYWORD macro, but the word is also treated as a keyword 72 * if the given boolean expression is true. 73 */ 74#define KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es, \ 75 allowed_glsl, allowed_glsl_es, \ 76 alt_expr, token) \ 77 do { \ 78 if (yyextra->is_version(allowed_glsl, allowed_glsl_es) \ 79 || (alt_expr)) { \ 80 return token; \ 81 } else if (yyextra->is_version(reserved_glsl, \ 82 reserved_glsl_es)) { \ 83 _mesa_glsl_error(yylloc, yyextra, \ 84 "illegal use of reserved word `%s'", yytext); \ 85 return ERROR_TOK; \ 86 } else { \ 87 return classify_identifier(yyextra, yytext, yyleng, yylval); \ 88 } \ 89 } while (0) 90 91/** 92 * Like KEYWORD_WITH_ALT, but used for built-in GLSL types 93 */ 94#define TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es, \ 95 allowed_glsl, allowed_glsl_es, \ 96 alt_expr, gtype) \ 97 do { \ 98 if (yyextra->is_version(allowed_glsl, allowed_glsl_es) \ 99 || (alt_expr)) { \ 100 yylval->type = gtype; \ 101 return BASIC_TYPE_TOK; \ 102 } else if (yyextra->is_version(reserved_glsl, \ 103 reserved_glsl_es)) { \ 104 _mesa_glsl_error(yylloc, yyextra, \ 105 "illegal use of reserved word `%s'", yytext); \ 106 return ERROR_TOK; \ 107 } else { \ 108 return classify_identifier(yyextra, yytext, yyleng, yylval); \ 109 } \ 110 } while (0) 111 112#define TYPE(reserved_glsl, reserved_glsl_es, \ 113 allowed_glsl, allowed_glsl_es, \ 114 gtype) \ 115 TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es, \ 116 allowed_glsl, allowed_glsl_es, \ 117 false, gtype) 118 119/** 120 * A macro for handling keywords that have been present in GLSL since 121 * its origin, but were changed into reserved words in GLSL 3.00 ES. 122 */ 123#define DEPRECATED_ES_KEYWORD(token) \ 124 do { \ 125 if (yyextra->is_version(0, 300)) { \ 126 _mesa_glsl_error(yylloc, yyextra, \ 127 "illegal use of reserved word `%s'", yytext); \ 128 return ERROR_TOK; \ 129 } else { \ 130 return token; \ 131 } \ 132 } while (0) 133 134/** 135 * Like DEPRECATED_ES_KEYWORD, but for types 136 */ 137#define DEPRECATED_ES_TYPE_WITH_ALT(alt_expr, gtype) \ 138 do { \ 139 if (yyextra->is_version(0, 300)) { \ 140 _mesa_glsl_error(yylloc, yyextra, \ 141 "illegal use of reserved word `%s'", yytext); \ 142 return ERROR_TOK; \ 143 } else if (alt_expr) { \ 144 yylval->type = gtype; \ 145 return BASIC_TYPE_TOK; \ 146 } else { \ 147 return classify_identifier(yyextra, yytext, yyleng, yylval); \ 148 } \ 149 } while (0) 150 151#define DEPRECATED_ES_TYPE(gtype) \ 152 DEPRECATED_ES_TYPE_WITH_ALT(true, gtype) 153 154static int 155literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, 156 YYSTYPE *lval, YYLTYPE *lloc, int base) 157{ 158 bool is_uint = (text[len - 1] == 'u' || 159 text[len - 1] == 'U'); 160 bool is_long = (text[len - 1] == 'l' || text[len - 1] == 'L'); 161 const char *digits = text; 162 163 if (is_long) 164 is_uint = (text[len - 2] == 'u' && text[len - 1] == 'l') || 165 (text[len - 2] == 'U' && text[len - 1] == 'L'); 166 /* Skip "0x" */ 167 if (base == 16) 168 digits += 2; 169 170 unsigned long long value = strtoull(digits, NULL, base); 171 172 if (is_long) 173 lval->n64 = (int64_t)value; 174 else 175 lval->n = (int)value; 176 177 if (is_long && !is_uint && base == 10 && value > (uint64_t)LLONG_MAX + 1) { 178 /* Tries to catch unintentionally providing a negative value. */ 179 _mesa_glsl_warning(lloc, state, 180 "signed literal value `%s' is interpreted as %lld", 181 text, lval->n64); 182 } else if (!is_long && value > UINT_MAX) { 183 /* Note that signed 0xffffffff is valid, not out of range! */ 184 if (state->is_version(130, 300)) { 185 _mesa_glsl_error(lloc, state, 186 "literal value `%s' out of range", text); 187 } else { 188 _mesa_glsl_warning(lloc, state, 189 "literal value `%s' out of range", text); 190 } 191 } else if (base == 10 && !is_uint && (unsigned)value > (unsigned)INT_MAX + 1) { 192 /* Tries to catch unintentionally providing a negative value. 193 * Note that -2147483648 is parsed as -(2147483648), so we don't 194 * want to warn for INT_MAX. 195 */ 196 _mesa_glsl_warning(lloc, state, 197 "signed literal value `%s' is interpreted as %d", 198 text, lval->n); 199 } 200 if (is_long) 201 return is_uint ? UINT64CONSTANT : INT64CONSTANT; 202 else 203 return is_uint ? UINTCONSTANT : INTCONSTANT; 204} 205 206#define LITERAL_INTEGER(base) \ 207 literal_integer(yytext, yyleng, yyextra, yylval, yylloc, base) 208 209%} 210 211%option bison-bridge bison-locations reentrant noyywrap 212%option nounput noyy_top_state 213%option never-interactive 214%option prefix="_mesa_glsl_lexer_" 215%option extra-type="struct _mesa_glsl_parse_state *" 216%option warn nodefault 217 218 /* Note: When adding any start conditions to this list, you must also 219 * update the "Internal compiler error" catch-all rule near the end of 220 * this file. */ 221%x PP PRAGMA 222 223DEC_INT [1-9][0-9]* 224HEX_INT 0[xX][0-9a-fA-F]+ 225OCT_INT 0[0-7]* 226INT ({DEC_INT}|{HEX_INT}|{OCT_INT}) 227SPC [ \t]* 228SPCP [ \t]+ 229HASH ^{SPC}#{SPC} 230PATH ["][./ _A-Za-z0-9]*["] 231%% 232 233[ \r\t]+ ; 234 235 /* Preprocessor tokens. */ 236^[ \t]*#[ \t]*$ ; 237^[ \t]*#[ \t]*version { BEGIN PP; return VERSION_TOK; } 238^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } 239{HASH}include { 240 if (!yyextra->ARB_shading_language_include_enable) { 241 struct _mesa_glsl_parse_state *state = yyextra; 242 _mesa_glsl_error(yylloc, state, 243 "ARB_shading_language_include required " 244 "to use #include"); 245 } 246} 247{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ { 248 /* Eat characters until the first digit is 249 * encountered 250 */ 251 char *ptr = yytext; 252 while (!isdigit(*ptr)) 253 ptr++; 254 255 /* Subtract one from the line number because 256 * yylineno is zero-based instead of 257 * one-based. 258 */ 259 yylineno = strtol(ptr, &ptr, 0) - 1; 260 261 /* From GLSL 3.30 and GLSL ES on, after processing the 262 * line directive (including its new-line), the implementation 263 * will behave as if it is compiling at the line number passed 264 * as argument. It was line number + 1 in older specifications. 265 */ 266 if (yyextra->is_version(330, 100)) 267 yylineno--; 268 269 yylloc->source = strtol(ptr, NULL, 0); 270 yylloc->path = NULL; 271 } 272{HASH}line{SPCP}{INT}{SPCP}{PATH}{SPC}$ { 273 if (!yyextra->ARB_shading_language_include_enable) { 274 struct _mesa_glsl_parse_state *state = yyextra; 275 _mesa_glsl_error(yylloc, state, 276 "ARB_shading_language_include required " 277 "to use #line <line> \"<path>\""); 278 } 279 280 /* Eat characters until the first digit is 281 * encountered 282 */ 283 char *ptr = yytext; 284 while (!isdigit(*ptr)) 285 ptr++; 286 287 /* Subtract one from the line number because 288 * yylineno is zero-based instead of 289 * one-based. 290 */ 291 yylineno = strtol(ptr, &ptr, 0) - 1; 292 293 /* From GLSL 3.30 and GLSL ES on, after processing the 294 * line directive (including its new-line), the implementation 295 * will behave as if it is compiling at the line number passed 296 * as argument. It was line number + 1 in older specifications. 297 */ 298 if (yyextra->is_version(330, 100)) 299 yylineno--; 300 301 while (isspace(*ptr)) 302 ptr++; 303 304 /* Skip over leading " */ 305 ptr++; 306 307 char *end = strrchr(ptr, '"'); 308 int path_len = (end - ptr) + 1; 309 void *mem_ctx = yyextra->linalloc; 310 yylloc->path = (char *) linear_alloc_child(mem_ctx, path_len); 311 memcpy(yylloc->path, ptr, path_len); 312 yylloc->path[path_len - 1] = '\0'; 313 } 314{HASH}line{SPCP}{INT}{SPC}$ { 315 /* Eat characters until the first digit is 316 * encountered 317 */ 318 char *ptr = yytext; 319 while (!isdigit(*ptr)) 320 ptr++; 321 322 /* Subtract one from the line number because 323 * yylineno is zero-based instead of 324 * one-based. 325 */ 326 yylineno = strtol(ptr, &ptr, 0) - 1; 327 328 /* From GLSL 3.30 and GLSL ES on, after processing the 329 * line directive (including its new-line), the implementation 330 * will behave as if it is compiling at the line number passed 331 * as argument. It was line number + 1 in older specifications. 332 */ 333 if (yyextra->is_version(330, 100)) 334 yylineno--; 335 } 336^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}on{SPC}\) { 337 BEGIN PP; 338 return PRAGMA_DEBUG_ON; 339 } 340^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}off{SPC}\) { 341 BEGIN PP; 342 return PRAGMA_DEBUG_OFF; 343 } 344^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}on{SPC}\) { 345 BEGIN PP; 346 return PRAGMA_OPTIMIZE_ON; 347 } 348^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}off{SPC}\) { 349 BEGIN PP; 350 return PRAGMA_OPTIMIZE_OFF; 351 } 352^{SPC}#{SPC}pragma{SPCP}warning{SPC}\({SPC}on{SPC}\) { 353 BEGIN PP; 354 return PRAGMA_WARNING_ON; 355 } 356^{SPC}#{SPC}pragma{SPCP}warning{SPC}\({SPC}off{SPC}\) { 357 BEGIN PP; 358 return PRAGMA_WARNING_OFF; 359 } 360^{SPC}#{SPC}pragma{SPCP}STDGL{SPCP}invariant{SPC}\({SPC}all{SPC}\) { 361 BEGIN PP; 362 return PRAGMA_INVARIANT_ALL; 363 } 364^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; } 365 366<PRAGMA>\n { BEGIN 0; yylineno++; yycolumn = 0; } 367<PRAGMA>. { } 368 369<PP>\/\/[^\n]* { } 370<PP>[ \t\r]* { } 371<PP>: return COLON; 372<PP>[_a-zA-Z][_a-zA-Z0-9]* { 373 /* We're not doing linear_strdup here, to avoid an implicit call 374 * on strlen() for the length of the string, as this is already 375 * found by flex and stored in yyleng 376 */ 377 void *mem_ctx = yyextra->linalloc; 378 char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1); 379 memcpy(id, yytext, yyleng + 1); 380 yylval->identifier = id; 381 return IDENTIFIER; 382 } 383<PP>[1-9][0-9]* { 384 yylval->n = strtol(yytext, NULL, 10); 385 return INTCONSTANT; 386 } 387<PP>0 { 388 yylval->n = 0; 389 return INTCONSTANT; 390 } 391<PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } 392<PP>. { return yytext[0]; } 393 394\n { yylineno++; yycolumn = 0; } 395 396attribute DEPRECATED_ES_KEYWORD(ATTRIBUTE); 397const return CONST_TOK; 398bool { yylval->type = glsl_type::bool_type; return BASIC_TYPE_TOK; } 399float { yylval->type = glsl_type::float_type; return BASIC_TYPE_TOK; } 400int { yylval->type = glsl_type::int_type; return BASIC_TYPE_TOK; } 401uint TYPE(130, 300, 130, 300, glsl_type::uint_type); 402 403break return BREAK; 404continue return CONTINUE; 405do return DO; 406while return WHILE; 407else return ELSE; 408for return FOR; 409if return IF; 410discard return DISCARD; 411return return RETURN; 412demote KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->EXT_demote_to_helper_invocation_enable, DEMOTE); 413 414bvec2 { yylval->type = glsl_type::bvec2_type; return BASIC_TYPE_TOK; } 415bvec3 { yylval->type = glsl_type::bvec3_type; return BASIC_TYPE_TOK; } 416bvec4 { yylval->type = glsl_type::bvec4_type; return BASIC_TYPE_TOK; } 417ivec2 { yylval->type = glsl_type::ivec2_type; return BASIC_TYPE_TOK; } 418ivec3 { yylval->type = glsl_type::ivec3_type; return BASIC_TYPE_TOK; } 419ivec4 { yylval->type = glsl_type::ivec4_type; return BASIC_TYPE_TOK; } 420uvec2 TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec2_type); 421uvec3 TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec3_type); 422uvec4 TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec4_type); 423vec2 { yylval->type = glsl_type::vec2_type; return BASIC_TYPE_TOK; } 424vec3 { yylval->type = glsl_type::vec3_type; return BASIC_TYPE_TOK; } 425vec4 { yylval->type = glsl_type::vec4_type; return BASIC_TYPE_TOK; } 426mat2 { yylval->type = glsl_type::mat2_type; return BASIC_TYPE_TOK; } 427mat3 { yylval->type = glsl_type::mat3_type; return BASIC_TYPE_TOK; } 428mat4 { yylval->type = glsl_type::mat4_type; return BASIC_TYPE_TOK; } 429mat2x2 TYPE(120, 300, 120, 300, glsl_type::mat2_type); 430mat2x3 TYPE(120, 300, 120, 300, glsl_type::mat2x3_type); 431mat2x4 TYPE(120, 300, 120, 300, glsl_type::mat2x4_type); 432mat3x2 TYPE(120, 300, 120, 300, glsl_type::mat3x2_type); 433mat3x3 TYPE(120, 300, 120, 300, glsl_type::mat3_type); 434mat3x4 TYPE(120, 300, 120, 300, glsl_type::mat3x4_type); 435mat4x2 TYPE(120, 300, 120, 300, glsl_type::mat4x2_type); 436mat4x3 TYPE(120, 300, 120, 300, glsl_type::mat4x3_type); 437mat4x4 TYPE(120, 300, 120, 300, glsl_type::mat4_type); 438 439in return IN_TOK; 440out return OUT_TOK; 441inout return INOUT_TOK; 442uniform return UNIFORM; 443buffer KEYWORD_WITH_ALT(0, 0, 430, 310, yyextra->ARB_shader_storage_buffer_object_enable, BUFFER); 444varying DEPRECATED_ES_KEYWORD(VARYING); 445centroid KEYWORD_WITH_ALT(120, 300, 120, 300, yyextra->EXT_gpu_shader4_enable, CENTROID); 446invariant KEYWORD(120, 100, 120, 100, INVARIANT); 447flat KEYWORD_WITH_ALT(130, 100, 130, 300, yyextra->EXT_gpu_shader4_enable, FLAT); 448smooth KEYWORD(130, 300, 130, 300, SMOOTH); 449noperspective KEYWORD_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, NOPERSPECTIVE); 450patch KEYWORD_WITH_ALT(0, 300, 400, 320, yyextra->has_tessellation_shader(), PATCH); 451 452sampler1D DEPRECATED_ES_TYPE(glsl_type::sampler1D_type); 453sampler2D { yylval->type = glsl_type::sampler2D_type; return BASIC_TYPE_TOK; } 454sampler3D { yylval->type = glsl_type::sampler3D_type; return BASIC_TYPE_TOK; } 455samplerCube { yylval->type = glsl_type::samplerCube_type; return BASIC_TYPE_TOK; } 456sampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArray_type); 457sampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArray_type); 458sampler1DShadow DEPRECATED_ES_TYPE(glsl_type::sampler1DShadow_type); 459sampler2DShadow { yylval->type = glsl_type::sampler2DShadow_type; return BASIC_TYPE_TOK; } 460samplerCubeShadow TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::samplerCubeShadow_type); 461sampler1DArrayShadow TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArrayShadow_type); 462sampler2DArrayShadow TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArrayShadow_type); 463isampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler1D_type); 464isampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler2D_type); 465isampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler3D_type); 466isamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isamplerCube_type); 467isampler1DArray 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); 468isampler2DArray 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); 469usampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler1D_type); 470usampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler2D_type); 471usampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler3D_type); 472usamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usamplerCube_type); 473usampler1DArray 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); 474usampler2DArray 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); 475 476 /* additional keywords in ARB_texture_multisample, included in GLSL 1.50 */ 477 /* these are reserved but not defined in GLSL 3.00 */ 478 /* [iu]sampler2DMS are defined in GLSL ES 3.10 */ 479sampler2DMS TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::sampler2DMS_type); 480isampler2DMS TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::isampler2DMS_type); 481usampler2DMS TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::usampler2DMS_type); 482sampler2DMSArray TYPE_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, glsl_type::sampler2DMSArray_type); 483isampler2DMSArray TYPE_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, glsl_type::isampler2DMSArray_type); 484usampler2DMSArray TYPE_WITH_ALT(150, 300, 150, 320, yyextra->ARB_texture_multisample_enable || yyextra->OES_texture_storage_multisample_2d_array_enable, glsl_type::usampler2DMSArray_type); 485 486 /* keywords available with ARB_texture_cube_map_array_enable extension on desktop GLSL */ 487samplerCubeArray 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); 488isamplerCubeArray 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); 489usamplerCubeArray 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); 490samplerCubeArrayShadow 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); 491 492samplerExternalOES { 493 if (yyextra->OES_EGL_image_external_enable || yyextra->OES_EGL_image_external_essl3_enable) { 494 yylval->type = glsl_type::samplerExternalOES_type; 495 return BASIC_TYPE_TOK; 496 } else 497 return IDENTIFIER; 498 } 499 500 /* keywords available with ARB_gpu_shader5 */ 501precise KEYWORD_WITH_ALT(400, 310, 400, 320, yyextra->ARB_gpu_shader5_enable || yyextra->EXT_gpu_shader5_enable || yyextra->OES_gpu_shader5_enable, PRECISE); 502 503 /* keywords available with ARB_shader_image_load_store */ 504image1D 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); 505image2D 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); 506image3D 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); 507image2DRect 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); 508imageCube 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); 509imageBuffer 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); 510image1DArray 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); 511image2DArray 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); 512imageCubeArray 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); 513image2DMS 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); 514image2DMSArray 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); 515iimage1D 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); 516iimage2D 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); 517iimage3D 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); 518iimage2DRect 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); 519iimageCube 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); 520iimageBuffer 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); 521iimage1DArray 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); 522iimage2DArray 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); 523iimageCubeArray 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); 524iimage2DMS 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); 525iimage2DMSArray 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); 526uimage1D 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); 527uimage2D 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); 528uimage3D 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); 529uimage2DRect 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); 530uimageCube 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); 531uimageBuffer 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); 532uimage1DArray 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); 533uimage2DArray 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); 534uimageCubeArray 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); 535uimage2DMS 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); 536uimage2DMSArray 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); 537image1DShadow KEYWORD(130, 300, 0, 0, IMAGE1DSHADOW); 538image2DShadow KEYWORD(130, 300, 0, 0, IMAGE2DSHADOW); 539image1DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE1DARRAYSHADOW); 540image2DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE2DARRAYSHADOW); 541 542coherent 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); 543volatile 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); 544restrict 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); 545readonly KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, READONLY); 546writeonly KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, WRITEONLY); 547 548atomic_uint TYPE_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_atomic_counters_enable, glsl_type::atomic_uint_type); 549 550shared KEYWORD_WITH_ALT(430, 310, 430, 310, yyextra->ARB_compute_shader_enable, SHARED); 551 552struct return STRUCT; 553void return VOID_TOK; 554 555layout { 556 if ((yyextra->is_version(140, 300)) 557 || yyextra->ARB_bindless_texture_enable 558 || yyextra->KHR_blend_equation_advanced_enable 559 || yyextra->AMD_conservative_depth_enable 560 || yyextra->ARB_conservative_depth_enable 561 || yyextra->ARB_explicit_attrib_location_enable 562 || yyextra->ARB_explicit_uniform_location_enable 563 || yyextra->ARB_post_depth_coverage_enable 564 || yyextra->has_separate_shader_objects() 565 || yyextra->ARB_uniform_buffer_object_enable 566 || yyextra->ARB_fragment_coord_conventions_enable 567 || yyextra->ARB_shading_language_420pack_enable 568 || yyextra->ARB_compute_shader_enable 569 || yyextra->ARB_tessellation_shader_enable 570 || yyextra->EXT_shader_framebuffer_fetch_non_coherent_enable) { 571 return LAYOUT_TOK; 572 } else { 573 return classify_identifier(yyextra, yytext, yyleng, yylval); 574 } 575 } 576 577\+\+ return INC_OP; 578-- return DEC_OP; 579\<= return LE_OP; 580>= return GE_OP; 581== return EQ_OP; 582!= return NE_OP; 583&& return AND_OP; 584\|\| return OR_OP; 585"^^" return XOR_OP; 586"<<" return LEFT_OP; 587">>" return RIGHT_OP; 588 589\*= return MUL_ASSIGN; 590\/= return DIV_ASSIGN; 591\+= return ADD_ASSIGN; 592\%= return MOD_ASSIGN; 593\<\<= return LEFT_ASSIGN; 594>>= return RIGHT_ASSIGN; 595&= return AND_ASSIGN; 596"^=" return XOR_ASSIGN; 597\|= return OR_ASSIGN; 598-= return SUB_ASSIGN; 599 600[1-9][0-9]*([uU]|[lL]|ul|UL)? { 601 return LITERAL_INTEGER(10); 602 } 6030[xX][0-9a-fA-F]+([uU]|[lL]|ul|UL)? { 604 return LITERAL_INTEGER(16); 605 } 6060[0-7]*([uU]|[lL]|ul|UL)? { 607 return LITERAL_INTEGER(8); 608 } 609 610[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? | 611\.[0-9]+([eE][+-]?[0-9]+)?[fF]? | 612[0-9]+\.([eE][+-]?[0-9]+)?[fF]? | 613[0-9]+[eE][+-]?[0-9]+[fF]? { 614 struct _mesa_glsl_parse_state *state = yyextra; 615 char suffix = yytext[strlen(yytext) - 1]; 616 if (!state->is_version(120, 300) && 617 (suffix == 'f' || suffix == 'F')) { 618 _mesa_glsl_warning(yylloc, state, 619 "Float suffixes are invalid in GLSL 1.10"); 620 } 621 yylval->real = _mesa_strtof(yytext, NULL); 622 return FLOATCONSTANT; 623 } 624 625[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?(lf|LF) | 626\.[0-9]+([eE][+-]?[0-9]+)?(lf|LF) | 627[0-9]+\.([eE][+-]?[0-9]+)?(lf|LF) | 628[0-9]+[eE][+-]?[0-9]+(lf|LF) { 629 if (!yyextra->is_version(400, 0) && 630 !yyextra->ARB_gpu_shader_fp64_enable) 631 return ERROR_TOK; 632 yylval->dreal = _mesa_strtod(yytext, NULL); 633 return DOUBLECONSTANT; 634 } 635 636true { 637 yylval->n = 1; 638 return BOOLCONSTANT; 639 } 640false { 641 yylval->n = 0; 642 return BOOLCONSTANT; 643 } 644 645 646 /* Reserved words in GLSL 1.10. */ 647asm KEYWORD(110, 100, 0, 0, ASM); 648class KEYWORD(110, 100, 0, 0, CLASS); 649union KEYWORD(110, 100, 0, 0, UNION); 650enum KEYWORD(110, 100, 0, 0, ENUM); 651typedef KEYWORD(110, 100, 0, 0, TYPEDEF); 652template KEYWORD(110, 100, 0, 0, TEMPLATE); 653this KEYWORD(110, 100, 0, 0, THIS); 654packed KEYWORD_WITH_ALT(110, 100, 140, 300, yyextra->ARB_uniform_buffer_object_enable, PACKED_TOK); 655goto KEYWORD(110, 100, 0, 0, GOTO); 656switch KEYWORD(110, 100, 130, 300, SWITCH); 657default KEYWORD(110, 100, 130, 300, DEFAULT); 658inline KEYWORD(110, 100, 0, 0, INLINE_TOK); 659noinline KEYWORD(110, 100, 0, 0, NOINLINE); 660public KEYWORD(110, 100, 0, 0, PUBLIC_TOK); 661static KEYWORD(110, 100, 0, 0, STATIC); 662extern KEYWORD(110, 100, 0, 0, EXTERN); 663external KEYWORD(110, 100, 0, 0, EXTERNAL); 664interface KEYWORD(110, 100, 0, 0, INTERFACE); 665long KEYWORD(110, 100, 0, 0, LONG_TOK); 666short KEYWORD(110, 100, 0, 0, SHORT_TOK); 667double TYPE_WITH_ALT(130, 100, 130, 300, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::double_type); 668half KEYWORD(110, 100, 0, 0, HALF); 669fixed KEYWORD(110, 100, 0, 0, FIXED_TOK); 670unsigned KEYWORD_WITH_ALT(110, 100, 0, 0, yyextra->EXT_gpu_shader4_enable, UNSIGNED); 671input KEYWORD(110, 100, 0, 0, INPUT_TOK); 672output KEYWORD(110, 100, 0, 0, OUTPUT); 673hvec2 KEYWORD(110, 100, 0, 0, HVEC2); 674hvec3 KEYWORD(110, 100, 0, 0, HVEC3); 675hvec4 KEYWORD(110, 100, 0, 0, HVEC4); 676dvec2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec2_type); 677dvec3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec3_type); 678dvec4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec4_type); 679dmat2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2_type); 680dmat3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3_type); 681dmat4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4_type); 682dmat2x2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2_type); 683dmat2x3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2x3_type); 684dmat2x4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2x4_type); 685dmat3x2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3x2_type); 686dmat3x3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3_type); 687dmat3x4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3x4_type); 688dmat4x2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4x2_type); 689dmat4x3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4x3_type); 690dmat4x4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4_type); 691fvec2 KEYWORD(110, 100, 0, 0, FVEC2); 692fvec3 KEYWORD(110, 100, 0, 0, FVEC3); 693fvec4 KEYWORD(110, 100, 0, 0, FVEC4); 694sampler2DRect TYPE_WITH_ALT(110, 100, 0, 0, yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRect_type); 695sampler3DRect KEYWORD(110, 100, 0, 0, SAMPLER3DRECT); 696sampler2DRectShadow TYPE_WITH_ALT(110, 100, 0, 0, yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRectShadow_type); 697sizeof KEYWORD(110, 100, 0, 0, SIZEOF); 698cast KEYWORD(110, 100, 0, 0, CAST); 699namespace KEYWORD(110, 100, 0, 0, NAMESPACE); 700using KEYWORD(110, 100, 0, 0, USING); 701 702 /* Additional reserved words in GLSL 1.20. */ 703lowp KEYWORD(120, 100, 130, 100, LOWP); 704mediump KEYWORD(120, 100, 130, 100, MEDIUMP); 705highp KEYWORD(120, 100, 130, 100, HIGHP); 706precision KEYWORD(120, 100, 130, 100, PRECISION); 707 708 /* Additional reserved words in GLSL 1.30. */ 709case KEYWORD(130, 300, 130, 300, CASE); 710common KEYWORD(130, 300, 0, 0, COMMON); 711partition KEYWORD(130, 300, 0, 0, PARTITION); 712active KEYWORD(130, 300, 0, 0, ACTIVE); 713superp KEYWORD(130, 100, 0, 0, SUPERP); 714samplerBuffer 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); 715filter KEYWORD(130, 300, 0, 0, FILTER); 716row_major KEYWORD_WITH_ALT(130, 0, 140, 0, yyextra->ARB_uniform_buffer_object_enable && !yyextra->es_shader, ROW_MAJOR); 717 718 /* Additional reserved words in GLSL 1.40 */ 719isampler2DRect 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); 720usampler2DRect 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); 721isamplerBuffer 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); 722usamplerBuffer 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); 723 724 /* Additional reserved words in GLSL ES 3.00 */ 725resource KEYWORD(420, 300, 0, 0, RESOURCE); 726sample KEYWORD_WITH_ALT(400, 300, 400, 320, yyextra->ARB_gpu_shader5_enable || yyextra->OES_shader_multisample_interpolation_enable, SAMPLE); 727subroutine KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_shader_subroutine_enable, SUBROUTINE); 728 729 /* Additional words for ARB_gpu_shader_int64 */ 730int64_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); 731i64vec2 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec2_type); 732i64vec3 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec3_type); 733i64vec4 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec4_type); 734 735uint64_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); 736u64vec2 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec2_type); 737u64vec3 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec3_type); 738u64vec4 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec4_type); 739 740[_a-zA-Z][_a-zA-Z0-9]* { 741 struct _mesa_glsl_parse_state *state = yyextra; 742 if (state->es_shader && yyleng > 1024) { 743 _mesa_glsl_error(yylloc, state, 744 "Identifier `%s' exceeds 1024 characters", 745 yytext); 746 } 747 return classify_identifier(state, yytext, yyleng, yylval); 748 } 749 750\. { struct _mesa_glsl_parse_state *state = yyextra; 751 state->is_field = true; 752 return DOT_TOK; } 753 754. { return yytext[0]; } 755 756%% 757 758int 759classify_identifier(struct _mesa_glsl_parse_state *state, const char *name, 760 unsigned name_len, YYSTYPE *output) 761{ 762 /* We're not doing linear_strdup here, to avoid an implicit call on 763 * strlen() for the length of the string, as this is already found by flex 764 * and stored in yyleng 765 */ 766 char *id = (char *) linear_alloc_child(state->linalloc, name_len + 1); 767 memcpy(id, name, name_len + 1); 768 output->identifier = id; 769 770 if (state->is_field) { 771 state->is_field = false; 772 return FIELD_SELECTION; 773 } 774 if (state->symbols->get_variable(name) || state->symbols->get_function(name)) 775 return IDENTIFIER; 776 else if (state->symbols->get_type(name)) 777 return TYPE_IDENTIFIER; 778 else 779 return NEW_IDENTIFIER; 780} 781 782void 783_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) 784{ 785 yylex_init_extra(state, & state->scanner); 786 yy_scan_string(string, state->scanner); 787} 788 789void 790_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) 791{ 792 yylex_destroy(state->scanner); 793} 794