nir: Use a single list for all shader variables
[mesa.git] / src / compiler / glsl / glsl_lexer.ll
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
32 static 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
154 static int
155 literal_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
223 DEC_INT [1-9][0-9]*
224 HEX_INT 0[xX][0-9a-fA-F]+
225 OCT_INT 0[0-7]*
226 INT ({DEC_INT}|{HEX_INT}|{OCT_INT})
227 SPC [ \t]*
228 SPCP [ \t]+
229 HASH ^{SPC}#{SPC}
230 PATH ["][./ _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
396 attribute DEPRECATED_ES_KEYWORD(ATTRIBUTE);
397 const return CONST_TOK;
398 bool { yylval->type = glsl_type::bool_type; return BASIC_TYPE_TOK; }
399 float { yylval->type = glsl_type::float_type; return BASIC_TYPE_TOK; }
400 int { yylval->type = glsl_type::int_type; return BASIC_TYPE_TOK; }
401 uint TYPE(130, 300, 130, 300, glsl_type::uint_type);
402
403 break return BREAK;
404 continue return CONTINUE;
405 do return DO;
406 while return WHILE;
407 else return ELSE;
408 for return FOR;
409 if return IF;
410 discard return DISCARD;
411 return return RETURN;
412 demote KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->EXT_demote_to_helper_invocation_enable, DEMOTE);
413
414 bvec2 { yylval->type = glsl_type::bvec2_type; return BASIC_TYPE_TOK; }
415 bvec3 { yylval->type = glsl_type::bvec3_type; return BASIC_TYPE_TOK; }
416 bvec4 { yylval->type = glsl_type::bvec4_type; return BASIC_TYPE_TOK; }
417 ivec2 { yylval->type = glsl_type::ivec2_type; return BASIC_TYPE_TOK; }
418 ivec3 { yylval->type = glsl_type::ivec3_type; return BASIC_TYPE_TOK; }
419 ivec4 { yylval->type = glsl_type::ivec4_type; return BASIC_TYPE_TOK; }
420 uvec2 TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec2_type);
421 uvec3 TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec3_type);
422 uvec4 TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::uvec4_type);
423 vec2 { yylval->type = glsl_type::vec2_type; return BASIC_TYPE_TOK; }
424 vec3 { yylval->type = glsl_type::vec3_type; return BASIC_TYPE_TOK; }
425 vec4 { yylval->type = glsl_type::vec4_type; return BASIC_TYPE_TOK; }
426 mat2 { yylval->type = glsl_type::mat2_type; return BASIC_TYPE_TOK; }
427 mat3 { yylval->type = glsl_type::mat3_type; return BASIC_TYPE_TOK; }
428 mat4 { yylval->type = glsl_type::mat4_type; return BASIC_TYPE_TOK; }
429 mat2x2 TYPE(120, 300, 120, 300, glsl_type::mat2_type);
430 mat2x3 TYPE(120, 300, 120, 300, glsl_type::mat2x3_type);
431 mat2x4 TYPE(120, 300, 120, 300, glsl_type::mat2x4_type);
432 mat3x2 TYPE(120, 300, 120, 300, glsl_type::mat3x2_type);
433 mat3x3 TYPE(120, 300, 120, 300, glsl_type::mat3_type);
434 mat3x4 TYPE(120, 300, 120, 300, glsl_type::mat3x4_type);
435 mat4x2 TYPE(120, 300, 120, 300, glsl_type::mat4x2_type);
436 mat4x3 TYPE(120, 300, 120, 300, glsl_type::mat4x3_type);
437 mat4x4 TYPE(120, 300, 120, 300, glsl_type::mat4_type);
438
439 in return IN_TOK;
440 out return OUT_TOK;
441 inout return INOUT_TOK;
442 uniform return UNIFORM;
443 buffer KEYWORD_WITH_ALT(0, 0, 430, 310, yyextra->ARB_shader_storage_buffer_object_enable, BUFFER);
444 varying DEPRECATED_ES_KEYWORD(VARYING);
445 centroid KEYWORD_WITH_ALT(120, 300, 120, 300, yyextra->EXT_gpu_shader4_enable, CENTROID);
446 invariant KEYWORD(120, 100, 120, 100, INVARIANT);
447 flat KEYWORD_WITH_ALT(130, 100, 130, 300, yyextra->EXT_gpu_shader4_enable, FLAT);
448 smooth KEYWORD(130, 300, 130, 300, SMOOTH);
449 noperspective KEYWORD_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, NOPERSPECTIVE);
450 patch KEYWORD_WITH_ALT(0, 300, 400, 320, yyextra->has_tessellation_shader(), PATCH);
451
452 sampler1D DEPRECATED_ES_TYPE(glsl_type::sampler1D_type);
453 sampler2D { yylval->type = glsl_type::sampler2D_type; return BASIC_TYPE_TOK; }
454 sampler3D { yylval->type = glsl_type::sampler3D_type; return BASIC_TYPE_TOK; }
455 samplerCube { yylval->type = glsl_type::samplerCube_type; return BASIC_TYPE_TOK; }
456 sampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArray_type);
457 sampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArray_type);
458 sampler1DShadow DEPRECATED_ES_TYPE(glsl_type::sampler1DShadow_type);
459 sampler2DShadow { yylval->type = glsl_type::sampler2DShadow_type; return BASIC_TYPE_TOK; }
460 samplerCubeShadow TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::samplerCubeShadow_type);
461 sampler1DArrayShadow TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArrayShadow_type);
462 sampler2DArrayShadow TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArrayShadow_type);
463 isampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler1D_type);
464 isampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler2D_type);
465 isampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler3D_type);
466 isamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isamplerCube_type);
467 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);
468 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);
469 usampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler1D_type);
470 usampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler2D_type);
471 usampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler3D_type);
472 usamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usamplerCube_type);
473 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);
474 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);
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 */
479 sampler2DMS TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::sampler2DMS_type);
480 isampler2DMS TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::isampler2DMS_type);
481 usampler2DMS TYPE_WITH_ALT(150, 300, 150, 310, yyextra->ARB_texture_multisample_enable, glsl_type::usampler2DMS_type);
482 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);
483 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);
484 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);
485
486 /* keywords available with ARB_texture_cube_map_array_enable extension on desktop GLSL */
487 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);
488 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);
489 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);
490 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);
491
492 samplerExternalOES {
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 */
501 precise 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 */
504 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);
505 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);
506 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);
507 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);
508 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);
509 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);
510 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);
511 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);
512 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);
513 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);
514 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);
515 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);
516 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);
517 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);
518 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);
519 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);
520 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);
521 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);
522 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);
523 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);
524 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);
525 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);
526 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);
527 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);
528 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);
529 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);
530 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);
531 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);
532 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);
533 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);
534 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);
535 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);
536 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);
537 image1DShadow KEYWORD(130, 300, 0, 0, IMAGE1DSHADOW);
538 image2DShadow KEYWORD(130, 300, 0, 0, IMAGE2DSHADOW);
539 image1DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE1DARRAYSHADOW);
540 image2DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE2DARRAYSHADOW);
541
542 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);
543 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);
544 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);
545 readonly KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, READONLY);
546 writeonly KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_image_load_store_enable || yyextra->ARB_shader_storage_buffer_object_enable, WRITEONLY);
547
548 atomic_uint TYPE_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_atomic_counters_enable, glsl_type::atomic_uint_type);
549
550 shared KEYWORD_WITH_ALT(430, 310, 430, 310, yyextra->ARB_compute_shader_enable, SHARED);
551
552 struct return STRUCT;
553 void return VOID_TOK;
554
555 layout {
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 }
603 0[xX][0-9a-fA-F]+([uU]|[lL]|ul|UL)? {
604 return LITERAL_INTEGER(16);
605 }
606 0[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
636 true {
637 yylval->n = 1;
638 return BOOLCONSTANT;
639 }
640 false {
641 yylval->n = 0;
642 return BOOLCONSTANT;
643 }
644
645
646 /* Reserved words in GLSL 1.10. */
647 asm KEYWORD(110, 100, 0, 0, ASM);
648 class KEYWORD(110, 100, 0, 0, CLASS);
649 union KEYWORD(110, 100, 0, 0, UNION);
650 enum KEYWORD(110, 100, 0, 0, ENUM);
651 typedef KEYWORD(110, 100, 0, 0, TYPEDEF);
652 template KEYWORD(110, 100, 0, 0, TEMPLATE);
653 this KEYWORD(110, 100, 0, 0, THIS);
654 packed KEYWORD_WITH_ALT(110, 100, 140, 300, yyextra->ARB_uniform_buffer_object_enable, PACKED_TOK);
655 goto KEYWORD(110, 100, 0, 0, GOTO);
656 switch KEYWORD(110, 100, 130, 300, SWITCH);
657 default KEYWORD(110, 100, 130, 300, DEFAULT);
658 inline KEYWORD(110, 100, 0, 0, INLINE_TOK);
659 noinline KEYWORD(110, 100, 0, 0, NOINLINE);
660 public KEYWORD(110, 100, 0, 0, PUBLIC_TOK);
661 static KEYWORD(110, 100, 0, 0, STATIC);
662 extern KEYWORD(110, 100, 0, 0, EXTERN);
663 external KEYWORD(110, 100, 0, 0, EXTERNAL);
664 interface KEYWORD(110, 100, 0, 0, INTERFACE);
665 long KEYWORD(110, 100, 0, 0, LONG_TOK);
666 short KEYWORD(110, 100, 0, 0, SHORT_TOK);
667 double TYPE_WITH_ALT(130, 100, 130, 300, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::double_type);
668 half KEYWORD(110, 100, 0, 0, HALF);
669 fixed KEYWORD(110, 100, 0, 0, FIXED_TOK);
670 unsigned KEYWORD_WITH_ALT(110, 100, 0, 0, yyextra->EXT_gpu_shader4_enable, UNSIGNED);
671 input KEYWORD(110, 100, 0, 0, INPUT_TOK);
672 output KEYWORD(110, 100, 0, 0, OUTPUT);
673 hvec2 KEYWORD(110, 100, 0, 0, HVEC2);
674 hvec3 KEYWORD(110, 100, 0, 0, HVEC3);
675 hvec4 KEYWORD(110, 100, 0, 0, HVEC4);
676 dvec2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec2_type);
677 dvec3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec3_type);
678 dvec4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dvec4_type);
679 dmat2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2_type);
680 dmat3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3_type);
681 dmat4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4_type);
682 dmat2x2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2_type);
683 dmat2x3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2x3_type);
684 dmat2x4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat2x4_type);
685 dmat3x2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3x2_type);
686 dmat3x3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3_type);
687 dmat3x4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat3x4_type);
688 dmat4x2 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4x2_type);
689 dmat4x3 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4x3_type);
690 dmat4x4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, glsl_type::dmat4_type);
691 fvec2 KEYWORD(110, 100, 0, 0, FVEC2);
692 fvec3 KEYWORD(110, 100, 0, 0, FVEC3);
693 fvec4 KEYWORD(110, 100, 0, 0, FVEC4);
694 sampler2DRect TYPE_WITH_ALT(110, 100, 0, 0, yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRect_type);
695 sampler3DRect KEYWORD(110, 100, 0, 0, SAMPLER3DRECT);
696 sampler2DRectShadow TYPE_WITH_ALT(110, 100, 0, 0, yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRectShadow_type);
697 sizeof KEYWORD(110, 100, 0, 0, SIZEOF);
698 cast KEYWORD(110, 100, 0, 0, CAST);
699 namespace KEYWORD(110, 100, 0, 0, NAMESPACE);
700 using KEYWORD(110, 100, 0, 0, USING);
701
702 /* Additional reserved words in GLSL 1.20. */
703 lowp KEYWORD(120, 100, 130, 100, LOWP);
704 mediump KEYWORD(120, 100, 130, 100, MEDIUMP);
705 highp KEYWORD(120, 100, 130, 100, HIGHP);
706 precision KEYWORD(120, 100, 130, 100, PRECISION);
707
708 /* Additional reserved words in GLSL 1.30. */
709 case KEYWORD(130, 300, 130, 300, CASE);
710 common KEYWORD(130, 300, 0, 0, COMMON);
711 partition KEYWORD(130, 300, 0, 0, PARTITION);
712 active KEYWORD(130, 300, 0, 0, ACTIVE);
713 superp KEYWORD(130, 100, 0, 0, SUPERP);
714 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);
715 filter KEYWORD(130, 300, 0, 0, FILTER);
716 row_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 */
719 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);
720 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);
721 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);
722 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);
723
724 /* Additional reserved words in GLSL ES 3.00 */
725 resource KEYWORD(420, 300, 0, 0, RESOURCE);
726 sample KEYWORD_WITH_ALT(400, 300, 400, 320, yyextra->ARB_gpu_shader5_enable || yyextra->OES_shader_multisample_interpolation_enable, SAMPLE);
727 subroutine KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_shader_subroutine_enable, SUBROUTINE);
728
729 /* Additional words for ARB_gpu_shader_int64 */
730 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);
731 i64vec2 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec2_type);
732 i64vec3 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec3_type);
733 i64vec4 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::i64vec4_type);
734
735 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);
736 u64vec2 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec2_type);
737 u64vec3 TYPE_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable || yyextra->AMD_gpu_shader_int64_enable, glsl_type::u64vec3_type);
738 u64vec4 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
758 int
759 classify_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
782 void
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
789 void
790 _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state)
791 {
792 yylex_destroy(state->scanner);
793 }