3 * Copyright © 2008, 2009 Intel Corporation
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:
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
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.
30 #include "glsl_parser_extras.h"
31 #include "glsl_types.h"
32 #include "main/context.h"
34 #define YYLEX_PARAM state->scanner
38 static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
40 _mesa_glsl_error(loc, st, "%s", msg);
56 %lex-param {void *scanner}
57 %parse-param {struct _mesa_glsl_parse_state *state}
62 const char *identifier;
64 struct ast_type_qualifier type_qualifier;
67 ast_type_specifier *type_specifier;
68 ast_fully_specified_type *fully_specified_type;
69 ast_function *function;
70 ast_parameter_declarator *parameter_declarator;
71 ast_function_definition *function_definition;
72 ast_compound_statement *compound_statement;
73 ast_expression *expression;
74 ast_declarator_list *declarator_list;
75 ast_struct_specifier *struct_specifier;
76 ast_declaration *declaration;
77 ast_switch_body *switch_body;
78 ast_case_label *case_label;
79 ast_case_label_list *case_label_list;
80 ast_case_statement *case_statement;
81 ast_case_statement_list *case_statement_list;
89 ast_node *then_statement;
90 ast_node *else_statement;
91 } selection_rest_statement;
94 %token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK
95 %token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
96 %token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4
97 %token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING
98 %token NOPERSPECTIVE FLAT SMOOTH
99 %token MAT2X2 MAT2X3 MAT2X4
100 %token MAT3X2 MAT3X3 MAT3X4
101 %token MAT4X2 MAT4X3 MAT4X4
102 %token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW
103 %token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW
104 %token SAMPLER2DARRAYSHADOW SAMPLERCUBEARRAY SAMPLERCUBEARRAYSHADOW
105 %token ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
106 %token ISAMPLER1DARRAY ISAMPLER2DARRAY ISAMPLERCUBEARRAY
107 %token USAMPLER1D USAMPLER2D USAMPLER3D USAMPLERCUBE USAMPLER1DARRAY
108 %token USAMPLER2DARRAY USAMPLERCUBEARRAY
109 %token SAMPLER2DRECT ISAMPLER2DRECT USAMPLER2DRECT SAMPLER2DRECTSHADOW
110 %token SAMPLERBUFFER ISAMPLERBUFFER USAMPLERBUFFER
111 %token SAMPLEREXTERNALOES
112 %token STRUCT VOID_TOK WHILE
113 %token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
114 %type <identifier> any_identifier
115 %token <real> FLOATCONSTANT
116 %token <n> INTCONSTANT UINTCONSTANT BOOLCONSTANT
117 %token <identifier> FIELD_SELECTION
118 %token LEFT_OP RIGHT_OP
119 %token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
120 %token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
121 %token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
124 %token LOWP MEDIUMP HIGHP SUPERP PRECISION
126 %token VERSION_TOK EXTENSION LINE COLON EOL INTERFACE OUTPUT
127 %token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF
128 %token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF
129 %token PRAGMA_INVARIANT_ALL
132 /* Reserved words that are not actually used in the grammar.
134 %token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO
135 %token INLINE_TOK NOINLINE VOLATILE PUBLIC_TOK STATIC EXTERN EXTERNAL
136 %token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK OUPTUT
137 %token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4
139 %token SIZEOF CAST NAMESPACE USING
140 %token COHERENT RESTRICT READONLY WRITEONLY RESOURCE ATOMIC_UINT PATCH SAMPLE
141 %token SUBROUTINE SAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS SAMPLER2DMSARRAY
142 %token ISAMPLER2DMSARRAY USAMPLER2DMSARRAY
146 %token COMMON PARTITION ACTIVE FILTER
147 %token IMAGE1D IMAGE2D IMAGE3D IMAGECUBE IMAGE1DARRAY IMAGE2DARRAY
148 %token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY
149 %token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGECUBE UIMAGE1DARRAY UIMAGE2DARRAY
150 %token IMAGE1DSHADOW IMAGE2DSHADOW IMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER
151 %token IMAGE1DARRAYSHADOW IMAGE2DARRAYSHADOW
154 %type <identifier> variable_identifier
155 %type <node> statement
156 %type <node> statement_list
157 %type <node> simple_statement
158 %type <n> precision_qualifier
159 %type <type_qualifier> type_qualifier
160 %type <type_qualifier> storage_qualifier
161 %type <type_qualifier> interpolation_qualifier
162 %type <type_qualifier> layout_qualifier
163 %type <type_qualifier> layout_qualifier_id_list layout_qualifier_id
164 %type <type_qualifier> uniform_block_layout_qualifier
165 %type <type_specifier> type_specifier
166 %type <type_specifier> type_specifier_no_prec
167 %type <type_specifier> type_specifier_nonarray
168 %type <identifier> basic_type_specifier_nonarray
169 %type <fully_specified_type> fully_specified_type
170 %type <function> function_prototype
171 %type <function> function_header
172 %type <function> function_header_with_parameters
173 %type <function> function_declarator
174 %type <parameter_declarator> parameter_declarator
175 %type <parameter_declarator> parameter_declaration
176 %type <type_qualifier> parameter_qualifier
177 %type <type_qualifier> parameter_type_qualifier
178 %type <type_specifier> parameter_type_specifier
179 %type <function_definition> function_definition
180 %type <compound_statement> compound_statement_no_new_scope
181 %type <compound_statement> compound_statement
182 %type <node> statement_no_new_scope
183 %type <node> expression_statement
184 %type <expression> expression
185 %type <expression> primary_expression
186 %type <expression> assignment_expression
187 %type <expression> conditional_expression
188 %type <expression> logical_or_expression
189 %type <expression> logical_xor_expression
190 %type <expression> logical_and_expression
191 %type <expression> inclusive_or_expression
192 %type <expression> exclusive_or_expression
193 %type <expression> and_expression
194 %type <expression> equality_expression
195 %type <expression> relational_expression
196 %type <expression> shift_expression
197 %type <expression> additive_expression
198 %type <expression> multiplicative_expression
199 %type <expression> unary_expression
200 %type <expression> constant_expression
201 %type <expression> integer_expression
202 %type <expression> postfix_expression
203 %type <expression> function_call_header_with_parameters
204 %type <expression> function_call_header_no_parameters
205 %type <expression> function_call_header
206 %type <expression> function_call_generic
207 %type <expression> function_call_or_method
208 %type <expression> function_call
209 %type <expression> method_call_generic
210 %type <expression> method_call_header_with_parameters
211 %type <expression> method_call_header_no_parameters
212 %type <expression> method_call_header
213 %type <n> assignment_operator
214 %type <n> unary_operator
215 %type <expression> function_identifier
216 %type <node> external_declaration
217 %type <declarator_list> init_declarator_list
218 %type <declarator_list> single_declaration
219 %type <expression> initializer
220 %type <node> declaration
221 %type <node> declaration_statement
222 %type <node> jump_statement
223 %type <node> uniform_block
224 %type <struct_specifier> struct_specifier
225 %type <declarator_list> struct_declaration_list
226 %type <declarator_list> struct_declaration
227 %type <declaration> struct_declarator
228 %type <declaration> struct_declarator_list
229 %type <declarator_list> member_list
230 %type <declarator_list> member_declaration
231 %type <node> selection_statement
232 %type <selection_rest_statement> selection_rest_statement
233 %type <node> switch_statement
234 %type <switch_body> switch_body
235 %type <case_label_list> case_label_list
236 %type <case_label> case_label
237 %type <case_statement> case_statement
238 %type <case_statement_list> case_statement_list
239 %type <node> iteration_statement
240 %type <node> condition
241 %type <node> conditionopt
242 %type <node> for_init_statement
243 %type <for_rest_statement> for_rest_statement
244 %type <n> integer_constant
248 version_statement extension_statement_list
250 _mesa_glsl_initialize_types(state);
252 external_declaration_list
254 delete state->symbols;
255 state->symbols = new(ralloc_parent(state)) glsl_symbol_table;
256 _mesa_glsl_initialize_types(state);
261 /* blank - no #version specified: defaults are already set */
262 | VERSION_TOK INTCONSTANT EOL
264 state->process_version_directive(&@2, $2, NULL);
266 | VERSION_TOK INTCONSTANT any_identifier EOL
268 state->process_version_directive(&@2, $2, $3);
274 | PRAGMA_DEBUG_OFF EOL
275 | PRAGMA_OPTIMIZE_ON EOL
276 | PRAGMA_OPTIMIZE_OFF EOL
277 | PRAGMA_INVARIANT_ALL EOL
279 if (!state->is_version(120, 100)) {
280 _mesa_glsl_warning(& @1, state,
281 "pragma `invariant(all)' not supported in %s "
282 "(GLSL ES 1.00 or GLSL 1.20 required).",
283 state->get_version_string());
285 state->all_invariant = true;
290 extension_statement_list:
292 | extension_statement_list extension_statement
302 EXTENSION any_identifier COLON any_identifier EOL
304 if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) {
310 external_declaration_list:
313 /* FINISHME: The NULL test is required because pragmas are set to
314 * FINISHME: NULL. (See production rule for external_declaration.)
317 state->translation_unit.push_tail(& $1->link);
319 | external_declaration_list external_declaration
321 /* FINISHME: The NULL test is required because pragmas are set to
322 * FINISHME: NULL. (See production rule for external_declaration.)
325 state->translation_unit.push_tail(& $2->link);
338 $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
339 $$->set_location(yylloc);
340 $$->primary_expression.identifier = $1;
345 $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
346 $$->set_location(yylloc);
347 $$->primary_expression.int_constant = $1;
352 $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
353 $$->set_location(yylloc);
354 $$->primary_expression.uint_constant = $1;
359 $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
360 $$->set_location(yylloc);
361 $$->primary_expression.float_constant = $1;
366 $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
367 $$->set_location(yylloc);
368 $$->primary_expression.bool_constant = $1;
378 | postfix_expression '[' integer_expression ']'
381 $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL);
382 $$->set_location(yylloc);
388 | postfix_expression '.' any_identifier
391 $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL);
392 $$->set_location(yylloc);
393 $$->primary_expression.identifier = $3;
395 | postfix_expression INC_OP
398 $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL);
399 $$->set_location(yylloc);
401 | postfix_expression DEC_OP
404 $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL);
405 $$->set_location(yylloc);
414 function_call_or_method
417 function_call_or_method:
418 function_call_generic
419 | postfix_expression '.' method_call_generic
422 $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL);
423 $$->set_location(yylloc);
427 function_call_generic:
428 function_call_header_with_parameters ')'
429 | function_call_header_no_parameters ')'
432 function_call_header_no_parameters:
433 function_call_header VOID_TOK
434 | function_call_header
437 function_call_header_with_parameters:
438 function_call_header assignment_expression
441 $$->set_location(yylloc);
442 $$->expressions.push_tail(& $2->link);
444 | function_call_header_with_parameters ',' assignment_expression
447 $$->set_location(yylloc);
448 $$->expressions.push_tail(& $3->link);
452 // Grammar Note: Constructors look like functions, but lexical
453 // analysis recognized most of them as keywords. They are now
454 // recognized through "type_specifier".
455 function_call_header:
456 function_identifier '('
463 $$ = new(ctx) ast_function_expression($1);
464 $$->set_location(yylloc);
466 | variable_identifier
469 ast_expression *callee = new(ctx) ast_expression($1);
470 $$ = new(ctx) ast_function_expression(callee);
471 $$->set_location(yylloc);
476 ast_expression *callee = new(ctx) ast_expression($1);
477 $$ = new(ctx) ast_function_expression(callee);
478 $$->set_location(yylloc);
483 method_call_header_with_parameters ')'
484 | method_call_header_no_parameters ')'
487 method_call_header_no_parameters:
488 method_call_header VOID_TOK
492 method_call_header_with_parameters:
493 method_call_header assignment_expression
496 $$->set_location(yylloc);
497 $$->expressions.push_tail(& $2->link);
499 | method_call_header_with_parameters ',' assignment_expression
502 $$->set_location(yylloc);
503 $$->expressions.push_tail(& $3->link);
507 // Grammar Note: Constructors look like methods, but lexical
508 // analysis recognized most of them as keywords. They are now
509 // recognized through "type_specifier".
511 variable_identifier '('
514 ast_expression *callee = new(ctx) ast_expression($1);
515 $$ = new(ctx) ast_function_expression(callee);
516 $$->set_location(yylloc);
520 // Grammar Note: No traditional style type casts.
523 | INC_OP unary_expression
526 $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL);
527 $$->set_location(yylloc);
529 | DEC_OP unary_expression
532 $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL);
533 $$->set_location(yylloc);
535 | unary_operator unary_expression
538 $$ = new(ctx) ast_expression($1, $2, NULL, NULL);
539 $$->set_location(yylloc);
543 // Grammar Note: No '*' or '&' unary ops. Pointers are not supported.
545 '+' { $$ = ast_plus; }
546 | '-' { $$ = ast_neg; }
547 | '!' { $$ = ast_logic_not; }
548 | '~' { $$ = ast_bit_not; }
551 multiplicative_expression:
553 | multiplicative_expression '*' unary_expression
556 $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3);
557 $$->set_location(yylloc);
559 | multiplicative_expression '/' unary_expression
562 $$ = new(ctx) ast_expression_bin(ast_div, $1, $3);
563 $$->set_location(yylloc);
565 | multiplicative_expression '%' unary_expression
568 $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3);
569 $$->set_location(yylloc);
574 multiplicative_expression
575 | additive_expression '+' multiplicative_expression
578 $$ = new(ctx) ast_expression_bin(ast_add, $1, $3);
579 $$->set_location(yylloc);
581 | additive_expression '-' multiplicative_expression
584 $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3);
585 $$->set_location(yylloc);
591 | shift_expression LEFT_OP additive_expression
594 $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3);
595 $$->set_location(yylloc);
597 | shift_expression RIGHT_OP additive_expression
600 $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3);
601 $$->set_location(yylloc);
605 relational_expression:
607 | relational_expression '<' shift_expression
610 $$ = new(ctx) ast_expression_bin(ast_less, $1, $3);
611 $$->set_location(yylloc);
613 | relational_expression '>' shift_expression
616 $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3);
617 $$->set_location(yylloc);
619 | relational_expression LE_OP shift_expression
622 $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3);
623 $$->set_location(yylloc);
625 | relational_expression GE_OP shift_expression
628 $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3);
629 $$->set_location(yylloc);
634 relational_expression
635 | equality_expression EQ_OP relational_expression
638 $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3);
639 $$->set_location(yylloc);
641 | equality_expression NE_OP relational_expression
644 $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3);
645 $$->set_location(yylloc);
651 | and_expression '&' equality_expression
654 $$ = new(ctx) ast_expression_bin(ast_bit_and, $1, $3);
655 $$->set_location(yylloc);
659 exclusive_or_expression:
661 | exclusive_or_expression '^' and_expression
664 $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3);
665 $$->set_location(yylloc);
669 inclusive_or_expression:
670 exclusive_or_expression
671 | inclusive_or_expression '|' exclusive_or_expression
674 $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
675 $$->set_location(yylloc);
679 logical_and_expression:
680 inclusive_or_expression
681 | logical_and_expression AND_OP inclusive_or_expression
684 $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3);
685 $$->set_location(yylloc);
689 logical_xor_expression:
690 logical_and_expression
691 | logical_xor_expression XOR_OP logical_and_expression
694 $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3);
695 $$->set_location(yylloc);
699 logical_or_expression:
700 logical_xor_expression
701 | logical_or_expression OR_OP logical_xor_expression
704 $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3);
705 $$->set_location(yylloc);
709 conditional_expression:
710 logical_or_expression
711 | logical_or_expression '?' expression ':' assignment_expression
714 $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5);
715 $$->set_location(yylloc);
719 assignment_expression:
720 conditional_expression
721 | unary_expression assignment_operator assignment_expression
724 $$ = new(ctx) ast_expression($2, $1, $3, NULL);
725 $$->set_location(yylloc);
730 '=' { $$ = ast_assign; }
731 | MUL_ASSIGN { $$ = ast_mul_assign; }
732 | DIV_ASSIGN { $$ = ast_div_assign; }
733 | MOD_ASSIGN { $$ = ast_mod_assign; }
734 | ADD_ASSIGN { $$ = ast_add_assign; }
735 | SUB_ASSIGN { $$ = ast_sub_assign; }
736 | LEFT_ASSIGN { $$ = ast_ls_assign; }
737 | RIGHT_ASSIGN { $$ = ast_rs_assign; }
738 | AND_ASSIGN { $$ = ast_and_assign; }
739 | XOR_ASSIGN { $$ = ast_xor_assign; }
740 | OR_ASSIGN { $$ = ast_or_assign; }
744 assignment_expression
748 | expression ',' assignment_expression
751 if ($1->oper != ast_sequence) {
752 $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
753 $$->set_location(yylloc);
754 $$->expressions.push_tail(& $1->link);
759 $$->expressions.push_tail(& $3->link);
764 conditional_expression
768 function_prototype ';'
770 state->symbols->pop_scope();
773 | init_declarator_list ';'
777 | PRECISION precision_qualifier type_specifier_no_prec ';'
780 $3->is_precision_statement = true;
790 function_declarator ')'
795 | function_header_with_parameters
798 function_header_with_parameters:
799 function_header parameter_declaration
802 $$->parameters.push_tail(& $2->link);
804 | function_header_with_parameters ',' parameter_declaration
807 $$->parameters.push_tail(& $3->link);
812 fully_specified_type variable_identifier '('
815 $$ = new(ctx) ast_function();
816 $$->set_location(yylloc);
817 $$->return_type = $1;
820 state->symbols->add_function(new(state) ir_function($2));
821 state->symbols->push_scope();
825 parameter_declarator:
826 type_specifier any_identifier
829 $$ = new(ctx) ast_parameter_declarator();
830 $$->set_location(yylloc);
831 $$->type = new(ctx) ast_fully_specified_type();
832 $$->type->set_location(yylloc);
833 $$->type->specifier = $1;
836 | type_specifier any_identifier '[' constant_expression ']'
839 $$ = new(ctx) ast_parameter_declarator();
840 $$->set_location(yylloc);
841 $$->type = new(ctx) ast_fully_specified_type();
842 $$->type->set_location(yylloc);
843 $$->type->specifier = $1;
850 parameter_declaration:
851 parameter_type_qualifier parameter_qualifier parameter_declarator
853 $1.flags.i |= $2.flags.i;
856 $$->type->qualifier = $1;
858 | parameter_qualifier parameter_declarator
861 $$->type->qualifier = $1;
863 | parameter_type_qualifier parameter_qualifier parameter_type_specifier
866 $1.flags.i |= $2.flags.i;
868 $$ = new(ctx) ast_parameter_declarator();
869 $$->set_location(yylloc);
870 $$->type = new(ctx) ast_fully_specified_type();
871 $$->type->qualifier = $1;
872 $$->type->specifier = $3;
874 | parameter_qualifier parameter_type_specifier
877 $$ = new(ctx) ast_parameter_declarator();
878 $$->set_location(yylloc);
879 $$->type = new(ctx) ast_fully_specified_type();
880 $$->type->qualifier = $1;
881 $$->type->specifier = $2;
888 memset(& $$, 0, sizeof($$));
892 memset(& $$, 0, sizeof($$));
897 memset(& $$, 0, sizeof($$));
902 memset(& $$, 0, sizeof($$));
908 parameter_type_specifier:
912 init_declarator_list:
914 | init_declarator_list ',' any_identifier
917 ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL);
918 decl->set_location(yylloc);
921 $$->declarations.push_tail(&decl->link);
922 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
924 | init_declarator_list ',' any_identifier '[' ']'
927 ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
928 decl->set_location(yylloc);
931 $$->declarations.push_tail(&decl->link);
932 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
934 | init_declarator_list ',' any_identifier '[' constant_expression ']'
937 ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
938 decl->set_location(yylloc);
941 $$->declarations.push_tail(&decl->link);
942 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
944 | init_declarator_list ',' any_identifier '[' ']' '=' initializer
947 ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
948 decl->set_location(yylloc);
951 $$->declarations.push_tail(&decl->link);
952 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
954 | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' initializer
957 ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
958 decl->set_location(yylloc);
961 $$->declarations.push_tail(&decl->link);
962 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
964 | init_declarator_list ',' any_identifier '=' initializer
967 ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5);
968 decl->set_location(yylloc);
971 $$->declarations.push_tail(&decl->link);
972 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
976 // Grammar Note: No 'enum', or 'typedef'.
981 /* Empty declaration list is valid. */
982 $$ = new(ctx) ast_declarator_list($1);
983 $$->set_location(yylloc);
985 | fully_specified_type any_identifier
988 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
990 $$ = new(ctx) ast_declarator_list($1);
991 $$->set_location(yylloc);
992 $$->declarations.push_tail(&decl->link);
994 | fully_specified_type any_identifier '[' ']'
997 ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
999 $$ = new(ctx) ast_declarator_list($1);
1000 $$->set_location(yylloc);
1001 $$->declarations.push_tail(&decl->link);
1003 | fully_specified_type any_identifier '[' constant_expression ']'
1006 ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
1008 $$ = new(ctx) ast_declarator_list($1);
1009 $$->set_location(yylloc);
1010 $$->declarations.push_tail(&decl->link);
1012 | fully_specified_type any_identifier '[' ']' '=' initializer
1015 ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
1017 $$ = new(ctx) ast_declarator_list($1);
1018 $$->set_location(yylloc);
1019 $$->declarations.push_tail(&decl->link);
1021 | fully_specified_type any_identifier '[' constant_expression ']' '=' initializer
1024 ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
1026 $$ = new(ctx) ast_declarator_list($1);
1027 $$->set_location(yylloc);
1028 $$->declarations.push_tail(&decl->link);
1030 | fully_specified_type any_identifier '=' initializer
1033 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
1035 $$ = new(ctx) ast_declarator_list($1);
1036 $$->set_location(yylloc);
1037 $$->declarations.push_tail(&decl->link);
1039 | INVARIANT variable_identifier // Vertex only.
1042 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
1044 $$ = new(ctx) ast_declarator_list(NULL);
1045 $$->set_location(yylloc);
1046 $$->invariant = true;
1048 $$->declarations.push_tail(&decl->link);
1052 fully_specified_type:
1056 $$ = new(ctx) ast_fully_specified_type();
1057 $$->set_location(yylloc);
1060 | type_qualifier type_specifier
1063 $$ = new(ctx) ast_fully_specified_type();
1064 $$->set_location(yylloc);
1071 LAYOUT_TOK '(' layout_qualifier_id_list ')'
1077 layout_qualifier_id_list:
1079 | layout_qualifier_id_list ',' layout_qualifier_id
1082 if (!$$.merge_qualifier(& @3, state, $3)) {
1089 INTCONSTANT { $$ = $1; }
1090 | UINTCONSTANT { $$ = $1; }
1092 layout_qualifier_id:
1095 memset(& $$, 0, sizeof($$));
1097 /* Layout qualifiers for ARB_fragment_coord_conventions. */
1098 if (!$$.flags.i && state->ARB_fragment_coord_conventions_enable) {
1099 if (strcmp($1, "origin_upper_left") == 0) {
1100 $$.flags.q.origin_upper_left = 1;
1101 } else if (strcmp($1, "pixel_center_integer") == 0) {
1102 $$.flags.q.pixel_center_integer = 1;
1105 if ($$.flags.i && state->ARB_fragment_coord_conventions_warn) {
1106 _mesa_glsl_warning(& @1, state,
1107 "GL_ARB_fragment_coord_conventions layout "
1108 "identifier `%s' used\n", $1);
1112 /* Layout qualifiers for AMD/ARB_conservative_depth. */
1114 (state->AMD_conservative_depth_enable ||
1115 state->ARB_conservative_depth_enable)) {
1116 if (strcmp($1, "depth_any") == 0) {
1117 $$.flags.q.depth_any = 1;
1118 } else if (strcmp($1, "depth_greater") == 0) {
1119 $$.flags.q.depth_greater = 1;
1120 } else if (strcmp($1, "depth_less") == 0) {
1121 $$.flags.q.depth_less = 1;
1122 } else if (strcmp($1, "depth_unchanged") == 0) {
1123 $$.flags.q.depth_unchanged = 1;
1126 if ($$.flags.i && state->AMD_conservative_depth_warn) {
1127 _mesa_glsl_warning(& @1, state,
1128 "GL_AMD_conservative_depth "
1129 "layout qualifier `%s' is used\n", $1);
1131 if ($$.flags.i && state->ARB_conservative_depth_warn) {
1132 _mesa_glsl_warning(& @1, state,
1133 "GL_ARB_conservative_depth "
1134 "layout qualifier `%s' is used\n", $1);
1138 /* See also uniform_block_layout_qualifier. */
1139 if (!$$.flags.i && state->ARB_uniform_buffer_object_enable) {
1140 if (strcmp($1, "std140") == 0) {
1141 $$.flags.q.std140 = 1;
1142 } else if (strcmp($1, "shared") == 0) {
1143 $$.flags.q.shared = 1;
1144 } else if (strcmp($1, "column_major") == 0) {
1145 $$.flags.q.column_major = 1;
1148 if ($$.flags.i && state->ARB_uniform_buffer_object_warn) {
1149 _mesa_glsl_warning(& @1, state,
1150 "#version 140 / GL_ARB_uniform_buffer_object "
1151 "layout qualifier `%s' is used\n", $1);
1156 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1161 | any_identifier '=' integer_constant
1163 memset(& $$, 0, sizeof($$));
1165 if (state->ARB_explicit_attrib_location_enable) {
1166 /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and
1167 * FINISHME: GLSL 1.30 (or later) are supported.
1169 if (strcmp("location", $1) == 0) {
1170 $$.flags.q.explicit_location = 1;
1175 _mesa_glsl_error(& @3, state,
1176 "invalid location %d specified\n", $3);
1181 if (strcmp("index", $1) == 0) {
1182 $$.flags.q.explicit_index = 1;
1187 _mesa_glsl_error(& @3, state,
1188 "invalid index %d specified\n", $3);
1194 /* If the identifier didn't match any known layout identifiers,
1198 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1201 } else if (state->ARB_explicit_attrib_location_warn) {
1202 _mesa_glsl_warning(& @1, state,
1203 "GL_ARB_explicit_attrib_location layout "
1204 "identifier `%s' used\n", $1);
1207 | uniform_block_layout_qualifier
1210 /* Layout qualifiers for ARB_uniform_buffer_object. */
1211 if (!state->ARB_uniform_buffer_object_enable) {
1212 _mesa_glsl_error(& @1, state,
1213 "#version 140 / GL_ARB_uniform_buffer_object "
1214 "layout qualifier `%s' is used\n", $1);
1215 } else if (state->ARB_uniform_buffer_object_warn) {
1216 _mesa_glsl_warning(& @1, state,
1217 "#version 140 / GL_ARB_uniform_buffer_object "
1218 "layout qualifier `%s' is used\n", $1);
1223 /* This is a separate language rule because we parse these as tokens
1224 * (due to them being reserved keywords) instead of identifiers like
1225 * most qualifiers. See the any_identifier path of
1226 * layout_qualifier_id for the others.
1228 uniform_block_layout_qualifier:
1231 memset(& $$, 0, sizeof($$));
1232 $$.flags.q.row_major = 1;
1236 memset(& $$, 0, sizeof($$));
1237 $$.flags.q.packed = 1;
1241 interpolation_qualifier:
1244 memset(& $$, 0, sizeof($$));
1245 $$.flags.q.smooth = 1;
1249 memset(& $$, 0, sizeof($$));
1250 $$.flags.q.flat = 1;
1254 memset(& $$, 0, sizeof($$));
1255 $$.flags.q.noperspective = 1;
1259 parameter_type_qualifier:
1262 memset(& $$, 0, sizeof($$));
1263 $$.flags.q.constant = 1;
1270 | layout_qualifier storage_qualifier
1273 $$.flags.i |= $2.flags.i;
1275 | interpolation_qualifier
1276 | interpolation_qualifier storage_qualifier
1279 $$.flags.i |= $2.flags.i;
1281 | INVARIANT storage_qualifier
1284 $$.flags.q.invariant = 1;
1286 | INVARIANT interpolation_qualifier storage_qualifier
1289 $$.flags.i |= $3.flags.i;
1290 $$.flags.q.invariant = 1;
1294 memset(& $$, 0, sizeof($$));
1295 $$.flags.q.invariant = 1;
1302 memset(& $$, 0, sizeof($$));
1303 $$.flags.q.constant = 1;
1307 memset(& $$, 0, sizeof($$));
1308 $$.flags.q.attribute = 1;
1312 memset(& $$, 0, sizeof($$));
1313 $$.flags.q.varying = 1;
1317 memset(& $$, 0, sizeof($$));
1318 $$.flags.q.centroid = 1;
1319 $$.flags.q.varying = 1;
1323 memset(& $$, 0, sizeof($$));
1328 memset(& $$, 0, sizeof($$));
1333 memset(& $$, 0, sizeof($$));
1334 $$.flags.q.centroid = 1; $$.flags.q.in = 1;
1338 memset(& $$, 0, sizeof($$));
1339 $$.flags.q.centroid = 1; $$.flags.q.out = 1;
1343 memset(& $$, 0, sizeof($$));
1344 $$.flags.q.uniform = 1;
1349 type_specifier_no_prec
1353 | precision_qualifier type_specifier_no_prec
1360 type_specifier_no_prec:
1361 type_specifier_nonarray
1362 | type_specifier_nonarray '[' ']'
1365 $$->is_array = true;
1366 $$->array_size = NULL;
1368 | type_specifier_nonarray '[' constant_expression ']'
1371 $$->is_array = true;
1372 $$->array_size = $3;
1376 type_specifier_nonarray:
1377 basic_type_specifier_nonarray
1380 $$ = new(ctx) ast_type_specifier($1);
1381 $$->set_location(yylloc);
1386 $$ = new(ctx) ast_type_specifier($1);
1387 $$->set_location(yylloc);
1392 $$ = new(ctx) ast_type_specifier($1);
1393 $$->set_location(yylloc);
1397 basic_type_specifier_nonarray:
1398 VOID_TOK { $$ = "void"; }
1399 | FLOAT_TOK { $$ = "float"; }
1400 | INT_TOK { $$ = "int"; }
1401 | UINT_TOK { $$ = "uint"; }
1402 | BOOL_TOK { $$ = "bool"; }
1403 | VEC2 { $$ = "vec2"; }
1404 | VEC3 { $$ = "vec3"; }
1405 | VEC4 { $$ = "vec4"; }
1406 | BVEC2 { $$ = "bvec2"; }
1407 | BVEC3 { $$ = "bvec3"; }
1408 | BVEC4 { $$ = "bvec4"; }
1409 | IVEC2 { $$ = "ivec2"; }
1410 | IVEC3 { $$ = "ivec3"; }
1411 | IVEC4 { $$ = "ivec4"; }
1412 | UVEC2 { $$ = "uvec2"; }
1413 | UVEC3 { $$ = "uvec3"; }
1414 | UVEC4 { $$ = "uvec4"; }
1415 | MAT2X2 { $$ = "mat2"; }
1416 | MAT2X3 { $$ = "mat2x3"; }
1417 | MAT2X4 { $$ = "mat2x4"; }
1418 | MAT3X2 { $$ = "mat3x2"; }
1419 | MAT3X3 { $$ = "mat3"; }
1420 | MAT3X4 { $$ = "mat3x4"; }
1421 | MAT4X2 { $$ = "mat4x2"; }
1422 | MAT4X3 { $$ = "mat4x3"; }
1423 | MAT4X4 { $$ = "mat4"; }
1424 | SAMPLER1D { $$ = "sampler1D"; }
1425 | SAMPLER2D { $$ = "sampler2D"; }
1426 | SAMPLER2DRECT { $$ = "sampler2DRect"; }
1427 | SAMPLER3D { $$ = "sampler3D"; }
1428 | SAMPLERCUBE { $$ = "samplerCube"; }
1429 | SAMPLEREXTERNALOES { $$ = "samplerExternalOES"; }
1430 | SAMPLER1DSHADOW { $$ = "sampler1DShadow"; }
1431 | SAMPLER2DSHADOW { $$ = "sampler2DShadow"; }
1432 | SAMPLER2DRECTSHADOW { $$ = "sampler2DRectShadow"; }
1433 | SAMPLERCUBESHADOW { $$ = "samplerCubeShadow"; }
1434 | SAMPLER1DARRAY { $$ = "sampler1DArray"; }
1435 | SAMPLER2DARRAY { $$ = "sampler2DArray"; }
1436 | SAMPLER1DARRAYSHADOW { $$ = "sampler1DArrayShadow"; }
1437 | SAMPLER2DARRAYSHADOW { $$ = "sampler2DArrayShadow"; }
1438 | SAMPLERBUFFER { $$ = "samplerBuffer"; }
1439 | SAMPLERCUBEARRAY { $$ = "samplerCubeArray"; }
1440 | SAMPLERCUBEARRAYSHADOW { $$ = "samplerCubeArrayShadow"; }
1441 | ISAMPLER1D { $$ = "isampler1D"; }
1442 | ISAMPLER2D { $$ = "isampler2D"; }
1443 | ISAMPLER2DRECT { $$ = "isampler2DRect"; }
1444 | ISAMPLER3D { $$ = "isampler3D"; }
1445 | ISAMPLERCUBE { $$ = "isamplerCube"; }
1446 | ISAMPLER1DARRAY { $$ = "isampler1DArray"; }
1447 | ISAMPLER2DARRAY { $$ = "isampler2DArray"; }
1448 | ISAMPLERBUFFER { $$ = "isamplerBuffer"; }
1449 | ISAMPLERCUBEARRAY { $$ = "isamplerCubeArray"; }
1450 | USAMPLER1D { $$ = "usampler1D"; }
1451 | USAMPLER2D { $$ = "usampler2D"; }
1452 | USAMPLER2DRECT { $$ = "usampler2DRect"; }
1453 | USAMPLER3D { $$ = "usampler3D"; }
1454 | USAMPLERCUBE { $$ = "usamplerCube"; }
1455 | USAMPLER1DARRAY { $$ = "usampler1DArray"; }
1456 | USAMPLER2DARRAY { $$ = "usampler2DArray"; }
1457 | USAMPLERBUFFER { $$ = "usamplerBuffer"; }
1458 | USAMPLERCUBEARRAY { $$ = "usamplerCubeArray"; }
1461 precision_qualifier:
1463 state->check_precision_qualifiers_allowed(&@1);
1465 $$ = ast_precision_high;
1468 state->check_precision_qualifiers_allowed(&@1);
1470 $$ = ast_precision_medium;
1473 state->check_precision_qualifiers_allowed(&@1);
1475 $$ = ast_precision_low;
1480 STRUCT any_identifier '{' struct_declaration_list '}'
1483 $$ = new(ctx) ast_struct_specifier($2, $4);
1484 $$->set_location(yylloc);
1485 state->symbols->add_type($2, glsl_type::void_type);
1487 | STRUCT '{' struct_declaration_list '}'
1490 $$ = new(ctx) ast_struct_specifier(NULL, $3);
1491 $$->set_location(yylloc);
1495 struct_declaration_list:
1499 $1->link.self_link();
1501 | struct_declaration_list struct_declaration
1504 $$->link.insert_before(& $2->link);
1509 type_specifier struct_declarator_list ';'
1512 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1513 type->set_location(yylloc);
1515 type->specifier = $1;
1516 $$ = new(ctx) ast_declarator_list(type);
1517 $$->set_location(yylloc);
1519 $$->declarations.push_degenerate_list_at_head(& $2->link);
1523 struct_declarator_list:
1527 $1->link.self_link();
1529 | struct_declarator_list ',' struct_declarator
1532 $$->link.insert_before(& $3->link);
1540 $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
1541 $$->set_location(yylloc);
1542 state->symbols->add_variable(new(state) ir_variable(NULL, $1, ir_var_auto));
1544 | any_identifier '[' constant_expression ']'
1547 $$ = new(ctx) ast_declaration($1, true, $3, NULL);
1548 $$->set_location(yylloc);
1553 assignment_expression
1556 declaration_statement:
1560 // Grammar Note: labeled statements for SWITCH only; 'goto' is not
1563 compound_statement { $$ = (ast_node *) $1; }
1568 declaration_statement
1569 | expression_statement
1570 | selection_statement
1572 | iteration_statement
1580 $$ = new(ctx) ast_compound_statement(true, NULL);
1581 $$->set_location(yylloc);
1585 state->symbols->push_scope();
1590 $$ = new(ctx) ast_compound_statement(true, $3);
1591 $$->set_location(yylloc);
1592 state->symbols->pop_scope();
1596 statement_no_new_scope:
1597 compound_statement_no_new_scope { $$ = (ast_node *) $1; }
1601 compound_statement_no_new_scope:
1605 $$ = new(ctx) ast_compound_statement(false, NULL);
1606 $$->set_location(yylloc);
1608 | '{' statement_list '}'
1611 $$ = new(ctx) ast_compound_statement(false, $2);
1612 $$->set_location(yylloc);
1620 _mesa_glsl_error(& @1, state, "<nil> statement\n");
1625 $$->link.self_link();
1627 | statement_list statement
1630 _mesa_glsl_error(& @2, state, "<nil> statement\n");
1634 $$->link.insert_before(& $2->link);
1638 expression_statement:
1642 $$ = new(ctx) ast_expression_statement(NULL);
1643 $$->set_location(yylloc);
1648 $$ = new(ctx) ast_expression_statement($1);
1649 $$->set_location(yylloc);
1653 selection_statement:
1654 IF '(' expression ')' selection_rest_statement
1656 $$ = new(state) ast_selection_statement($3, $5.then_statement,
1658 $$->set_location(yylloc);
1662 selection_rest_statement:
1663 statement ELSE statement
1665 $$.then_statement = $1;
1666 $$.else_statement = $3;
1670 $$.then_statement = $1;
1671 $$.else_statement = NULL;
1678 $$ = (ast_node *) $1;
1680 | fully_specified_type any_identifier '=' initializer
1683 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
1684 ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
1685 decl->set_location(yylloc);
1686 declarator->set_location(yylloc);
1688 declarator->declarations.push_tail(&decl->link);
1694 * siwtch_statement grammar is based on the syntax described in the body
1695 * of the GLSL spec, not in it's appendix!!!
1698 SWITCH '(' expression ')' switch_body
1700 $$ = new(state) ast_switch_statement($3, $5);
1701 $$->set_location(yylloc);
1708 $$ = new(state) ast_switch_body(NULL);
1709 $$->set_location(yylloc);
1711 | '{' case_statement_list '}'
1713 $$ = new(state) ast_switch_body($2);
1714 $$->set_location(yylloc);
1721 $$ = new(state) ast_case_label($2);
1722 $$->set_location(yylloc);
1726 $$ = new(state) ast_case_label(NULL);
1727 $$->set_location(yylloc);
1734 ast_case_label_list *labels = new(state) ast_case_label_list();
1736 labels->labels.push_tail(& $1->link);
1738 $$->set_location(yylloc);
1740 | case_label_list case_label
1743 $$->labels.push_tail(& $2->link);
1748 case_label_list statement
1750 ast_case_statement *stmts = new(state) ast_case_statement($1);
1751 stmts->set_location(yylloc);
1753 stmts->stmts.push_tail(& $2->link);
1756 | case_statement statement
1759 $$->stmts.push_tail(& $2->link);
1763 case_statement_list:
1766 ast_case_statement_list *cases= new(state) ast_case_statement_list();
1767 cases->set_location(yylloc);
1769 cases->cases.push_tail(& $1->link);
1772 | case_statement_list case_statement
1775 $$->cases.push_tail(& $2->link);
1779 iteration_statement:
1780 WHILE '(' condition ')' statement_no_new_scope
1783 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
1784 NULL, $3, NULL, $5);
1785 $$->set_location(yylloc);
1787 | DO statement WHILE '(' expression ')' ';'
1790 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
1791 NULL, $5, NULL, $2);
1792 $$->set_location(yylloc);
1794 | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
1797 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
1798 $3, $4.cond, $4.rest, $6);
1799 $$->set_location(yylloc);
1804 expression_statement
1805 | declaration_statement
1822 | conditionopt ';' expression
1829 // Grammar Note: No 'goto'. Gotos are not supported.
1834 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
1835 $$->set_location(yylloc);
1840 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
1841 $$->set_location(yylloc);
1846 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
1847 $$->set_location(yylloc);
1849 | RETURN expression ';'
1852 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
1853 $$->set_location(yylloc);
1855 | DISCARD ';' // Fragment shader only.
1858 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
1859 $$->set_location(yylloc);
1863 external_declaration:
1864 function_definition { $$ = $1; }
1865 | declaration { $$ = $1; }
1866 | pragma_statement { $$ = NULL; }
1867 | layout_defaults { $$ = NULL; }
1870 function_definition:
1871 function_prototype compound_statement_no_new_scope
1874 $$ = new(ctx) ast_function_definition();
1875 $$->set_location(yylloc);
1879 state->symbols->pop_scope();
1883 /* layout_qualifieropt is packed into this rule */
1885 UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1888 $$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,
1891 if (!state->ARB_uniform_buffer_object_enable) {
1892 _mesa_glsl_error(& @1, state,
1893 "#version 140 / GL_ARB_uniform_buffer_object "
1894 "required for defining uniform blocks\n");
1895 } else if (state->ARB_uniform_buffer_object_warn) {
1896 _mesa_glsl_warning(& @1, state,
1897 "#version 140 / GL_ARB_uniform_buffer_object "
1898 "required for defining uniform blocks\n");
1901 | layout_qualifier UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1905 ast_type_qualifier qual = *state->default_uniform_qualifier;
1906 if (!qual.merge_qualifier(& @1, state, $1)) {
1909 $$ = new(ctx) ast_uniform_block(qual, $3, $5);
1911 if (!state->ARB_uniform_buffer_object_enable) {
1912 _mesa_glsl_error(& @1, state,
1913 "#version 140 / GL_ARB_uniform_buffer_object "
1914 "required for defining uniform blocks\n");
1915 } else if (state->ARB_uniform_buffer_object_warn) {
1916 _mesa_glsl_warning(& @1, state,
1917 "#version 140 / GL_ARB_uniform_buffer_object "
1918 "required for defining uniform blocks\n");
1927 $1->link.self_link();
1929 | member_declaration member_list
1932 $2->link.insert_before(& $$->link);
1936 /* Specifying "uniform" inside of a uniform block is redundant. */
1943 layout_qualifier uniformopt type_specifier struct_declarator_list ';'
1946 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1947 type->set_location(yylloc);
1949 type->qualifier = $1;
1950 type->qualifier.flags.q.uniform = true;
1951 type->specifier = $3;
1952 $$ = new(ctx) ast_declarator_list(type);
1953 $$->set_location(yylloc);
1954 $$->ubo_qualifiers_valid = true;
1956 $$->declarations.push_degenerate_list_at_head(& $4->link);
1958 | uniformopt type_specifier struct_declarator_list ';'
1961 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1962 type->set_location(yylloc);
1964 type->qualifier.flags.q.uniform = true;
1965 type->specifier = $2;
1966 $$ = new(ctx) ast_declarator_list(type);
1967 $$->set_location(yylloc);
1968 $$->ubo_qualifiers_valid = true;
1970 $$->declarations.push_degenerate_list_at_head(& $3->link);
1975 layout_qualifier UNIFORM ';'
1977 if (!state->default_uniform_qualifier->merge_qualifier(& @1, state,