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