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; }
1093 layout_qualifier_id:
1096 memset(& $$, 0, sizeof($$));
1098 /* Layout qualifiers for ARB_fragment_coord_conventions. */
1099 if (!$$.flags.i && state->ARB_fragment_coord_conventions_enable) {
1100 if (strcmp($1, "origin_upper_left") == 0) {
1101 $$.flags.q.origin_upper_left = 1;
1102 } else if (strcmp($1, "pixel_center_integer") == 0) {
1103 $$.flags.q.pixel_center_integer = 1;
1106 if ($$.flags.i && state->ARB_fragment_coord_conventions_warn) {
1107 _mesa_glsl_warning(& @1, state,
1108 "GL_ARB_fragment_coord_conventions layout "
1109 "identifier `%s' used\n", $1);
1113 /* Layout qualifiers for AMD/ARB_conservative_depth. */
1115 (state->AMD_conservative_depth_enable ||
1116 state->ARB_conservative_depth_enable)) {
1117 if (strcmp($1, "depth_any") == 0) {
1118 $$.flags.q.depth_any = 1;
1119 } else if (strcmp($1, "depth_greater") == 0) {
1120 $$.flags.q.depth_greater = 1;
1121 } else if (strcmp($1, "depth_less") == 0) {
1122 $$.flags.q.depth_less = 1;
1123 } else if (strcmp($1, "depth_unchanged") == 0) {
1124 $$.flags.q.depth_unchanged = 1;
1127 if ($$.flags.i && state->AMD_conservative_depth_warn) {
1128 _mesa_glsl_warning(& @1, state,
1129 "GL_AMD_conservative_depth "
1130 "layout qualifier `%s' is used\n", $1);
1132 if ($$.flags.i && state->ARB_conservative_depth_warn) {
1133 _mesa_glsl_warning(& @1, state,
1134 "GL_ARB_conservative_depth "
1135 "layout qualifier `%s' is used\n", $1);
1139 /* See also uniform_block_layout_qualifier. */
1140 if (!$$.flags.i && state->ARB_uniform_buffer_object_enable) {
1141 if (strcmp($1, "std140") == 0) {
1142 $$.flags.q.std140 = 1;
1143 } else if (strcmp($1, "shared") == 0) {
1144 $$.flags.q.shared = 1;
1145 } else if (strcmp($1, "column_major") == 0) {
1146 $$.flags.q.column_major = 1;
1147 } else if (strcmp($1, "row_major") == 0) {
1148 $$.flags.q.row_major = 1;
1151 if ($$.flags.i && state->ARB_uniform_buffer_object_warn) {
1152 _mesa_glsl_warning(& @1, state,
1153 "#version 140 / GL_ARB_uniform_buffer_object "
1154 "layout qualifier `%s' is used\n", $1);
1159 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1164 | any_identifier '=' integer_constant
1166 memset(& $$, 0, sizeof($$));
1168 if (state->ARB_explicit_attrib_location_enable) {
1169 /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and
1170 * FINISHME: GLSL 1.30 (or later) are supported.
1172 if (strcmp("location", $1) == 0) {
1173 $$.flags.q.explicit_location = 1;
1178 _mesa_glsl_error(& @3, state,
1179 "invalid location %d specified\n", $3);
1184 if (strcmp("index", $1) == 0) {
1185 $$.flags.q.explicit_index = 1;
1190 _mesa_glsl_error(& @3, state,
1191 "invalid index %d specified\n", $3);
1197 /* If the identifier didn't match any known layout identifiers,
1201 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1204 } else if (state->ARB_explicit_attrib_location_warn) {
1205 _mesa_glsl_warning(& @1, state,
1206 "GL_ARB_explicit_attrib_location layout "
1207 "identifier `%s' used\n", $1);
1210 | uniform_block_layout_qualifier
1213 /* Layout qualifiers for ARB_uniform_buffer_object. */
1214 if (!state->ARB_uniform_buffer_object_enable) {
1215 _mesa_glsl_error(& @1, state,
1216 "#version 140 / GL_ARB_uniform_buffer_object "
1217 "layout qualifier `%s' is used\n", $1);
1218 } else if (state->ARB_uniform_buffer_object_warn) {
1219 _mesa_glsl_warning(& @1, state,
1220 "#version 140 / GL_ARB_uniform_buffer_object "
1221 "layout qualifier `%s' is used\n", $1);
1226 /* This is a separate language rule because we parse these as tokens
1227 * (due to them being reserved keywords) instead of identifiers like
1228 * most qualifiers. See the any_identifier path of
1229 * layout_qualifier_id for the others.
1231 uniform_block_layout_qualifier:
1234 memset(& $$, 0, sizeof($$));
1235 $$.flags.q.row_major = 1;
1239 memset(& $$, 0, sizeof($$));
1240 $$.flags.q.packed = 1;
1244 interpolation_qualifier:
1247 memset(& $$, 0, sizeof($$));
1248 $$.flags.q.smooth = 1;
1252 memset(& $$, 0, sizeof($$));
1253 $$.flags.q.flat = 1;
1257 memset(& $$, 0, sizeof($$));
1258 $$.flags.q.noperspective = 1;
1262 parameter_type_qualifier:
1265 memset(& $$, 0, sizeof($$));
1266 $$.flags.q.constant = 1;
1273 | layout_qualifier storage_qualifier
1276 $$.flags.i |= $2.flags.i;
1278 | interpolation_qualifier
1279 | interpolation_qualifier storage_qualifier
1282 $$.flags.i |= $2.flags.i;
1284 | INVARIANT storage_qualifier
1287 $$.flags.q.invariant = 1;
1289 | INVARIANT interpolation_qualifier storage_qualifier
1292 $$.flags.i |= $3.flags.i;
1293 $$.flags.q.invariant = 1;
1297 memset(& $$, 0, sizeof($$));
1298 $$.flags.q.invariant = 1;
1305 memset(& $$, 0, sizeof($$));
1306 $$.flags.q.constant = 1;
1310 memset(& $$, 0, sizeof($$));
1311 $$.flags.q.attribute = 1;
1315 memset(& $$, 0, sizeof($$));
1316 $$.flags.q.varying = 1;
1320 memset(& $$, 0, sizeof($$));
1321 $$.flags.q.centroid = 1;
1322 $$.flags.q.varying = 1;
1326 memset(& $$, 0, sizeof($$));
1331 memset(& $$, 0, sizeof($$));
1336 memset(& $$, 0, sizeof($$));
1337 $$.flags.q.centroid = 1; $$.flags.q.in = 1;
1341 memset(& $$, 0, sizeof($$));
1342 $$.flags.q.centroid = 1; $$.flags.q.out = 1;
1346 memset(& $$, 0, sizeof($$));
1347 $$.flags.q.uniform = 1;
1352 type_specifier_no_prec
1356 | precision_qualifier type_specifier_no_prec
1363 type_specifier_no_prec:
1364 type_specifier_nonarray
1365 | type_specifier_nonarray '[' ']'
1368 $$->is_array = true;
1369 $$->array_size = NULL;
1371 | type_specifier_nonarray '[' constant_expression ']'
1374 $$->is_array = true;
1375 $$->array_size = $3;
1379 type_specifier_nonarray:
1380 basic_type_specifier_nonarray
1383 $$ = new(ctx) ast_type_specifier($1);
1384 $$->set_location(yylloc);
1389 $$ = new(ctx) ast_type_specifier($1);
1390 $$->set_location(yylloc);
1395 $$ = new(ctx) ast_type_specifier($1);
1396 $$->set_location(yylloc);
1400 basic_type_specifier_nonarray:
1401 VOID_TOK { $$ = "void"; }
1402 | FLOAT_TOK { $$ = "float"; }
1403 | INT_TOK { $$ = "int"; }
1404 | UINT_TOK { $$ = "uint"; }
1405 | BOOL_TOK { $$ = "bool"; }
1406 | VEC2 { $$ = "vec2"; }
1407 | VEC3 { $$ = "vec3"; }
1408 | VEC4 { $$ = "vec4"; }
1409 | BVEC2 { $$ = "bvec2"; }
1410 | BVEC3 { $$ = "bvec3"; }
1411 | BVEC4 { $$ = "bvec4"; }
1412 | IVEC2 { $$ = "ivec2"; }
1413 | IVEC3 { $$ = "ivec3"; }
1414 | IVEC4 { $$ = "ivec4"; }
1415 | UVEC2 { $$ = "uvec2"; }
1416 | UVEC3 { $$ = "uvec3"; }
1417 | UVEC4 { $$ = "uvec4"; }
1418 | MAT2X2 { $$ = "mat2"; }
1419 | MAT2X3 { $$ = "mat2x3"; }
1420 | MAT2X4 { $$ = "mat2x4"; }
1421 | MAT3X2 { $$ = "mat3x2"; }
1422 | MAT3X3 { $$ = "mat3"; }
1423 | MAT3X4 { $$ = "mat3x4"; }
1424 | MAT4X2 { $$ = "mat4x2"; }
1425 | MAT4X3 { $$ = "mat4x3"; }
1426 | MAT4X4 { $$ = "mat4"; }
1427 | SAMPLER1D { $$ = "sampler1D"; }
1428 | SAMPLER2D { $$ = "sampler2D"; }
1429 | SAMPLER2DRECT { $$ = "sampler2DRect"; }
1430 | SAMPLER3D { $$ = "sampler3D"; }
1431 | SAMPLERCUBE { $$ = "samplerCube"; }
1432 | SAMPLEREXTERNALOES { $$ = "samplerExternalOES"; }
1433 | SAMPLER1DSHADOW { $$ = "sampler1DShadow"; }
1434 | SAMPLER2DSHADOW { $$ = "sampler2DShadow"; }
1435 | SAMPLER2DRECTSHADOW { $$ = "sampler2DRectShadow"; }
1436 | SAMPLERCUBESHADOW { $$ = "samplerCubeShadow"; }
1437 | SAMPLER1DARRAY { $$ = "sampler1DArray"; }
1438 | SAMPLER2DARRAY { $$ = "sampler2DArray"; }
1439 | SAMPLER1DARRAYSHADOW { $$ = "sampler1DArrayShadow"; }
1440 | SAMPLER2DARRAYSHADOW { $$ = "sampler2DArrayShadow"; }
1441 | SAMPLERBUFFER { $$ = "samplerBuffer"; }
1442 | SAMPLERCUBEARRAY { $$ = "samplerCubeArray"; }
1443 | SAMPLERCUBEARRAYSHADOW { $$ = "samplerCubeArrayShadow"; }
1444 | ISAMPLER1D { $$ = "isampler1D"; }
1445 | ISAMPLER2D { $$ = "isampler2D"; }
1446 | ISAMPLER2DRECT { $$ = "isampler2DRect"; }
1447 | ISAMPLER3D { $$ = "isampler3D"; }
1448 | ISAMPLERCUBE { $$ = "isamplerCube"; }
1449 | ISAMPLER1DARRAY { $$ = "isampler1DArray"; }
1450 | ISAMPLER2DARRAY { $$ = "isampler2DArray"; }
1451 | ISAMPLERBUFFER { $$ = "isamplerBuffer"; }
1452 | ISAMPLERCUBEARRAY { $$ = "isamplerCubeArray"; }
1453 | USAMPLER1D { $$ = "usampler1D"; }
1454 | USAMPLER2D { $$ = "usampler2D"; }
1455 | USAMPLER2DRECT { $$ = "usampler2DRect"; }
1456 | USAMPLER3D { $$ = "usampler3D"; }
1457 | USAMPLERCUBE { $$ = "usamplerCube"; }
1458 | USAMPLER1DARRAY { $$ = "usampler1DArray"; }
1459 | USAMPLER2DARRAY { $$ = "usampler2DArray"; }
1460 | USAMPLERBUFFER { $$ = "usamplerBuffer"; }
1461 | USAMPLERCUBEARRAY { $$ = "usamplerCubeArray"; }
1464 precision_qualifier:
1466 state->check_precision_qualifiers_allowed(&@1);
1468 $$ = ast_precision_high;
1471 state->check_precision_qualifiers_allowed(&@1);
1473 $$ = ast_precision_medium;
1476 state->check_precision_qualifiers_allowed(&@1);
1478 $$ = ast_precision_low;
1483 STRUCT any_identifier '{' struct_declaration_list '}'
1486 $$ = new(ctx) ast_struct_specifier($2, $4);
1487 $$->set_location(yylloc);
1488 state->symbols->add_type($2, glsl_type::void_type);
1490 | STRUCT '{' struct_declaration_list '}'
1493 $$ = new(ctx) ast_struct_specifier(NULL, $3);
1494 $$->set_location(yylloc);
1498 struct_declaration_list:
1502 $1->link.self_link();
1504 | struct_declaration_list struct_declaration
1507 $$->link.insert_before(& $2->link);
1512 type_specifier struct_declarator_list ';'
1515 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1516 type->set_location(yylloc);
1518 type->specifier = $1;
1519 $$ = new(ctx) ast_declarator_list(type);
1520 $$->set_location(yylloc);
1522 $$->declarations.push_degenerate_list_at_head(& $2->link);
1526 struct_declarator_list:
1530 $1->link.self_link();
1532 | struct_declarator_list ',' struct_declarator
1535 $$->link.insert_before(& $3->link);
1543 $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
1544 $$->set_location(yylloc);
1545 state->symbols->add_variable(new(state) ir_variable(NULL, $1, ir_var_auto));
1547 | any_identifier '[' constant_expression ']'
1550 $$ = new(ctx) ast_declaration($1, true, $3, NULL);
1551 $$->set_location(yylloc);
1556 assignment_expression
1559 declaration_statement:
1563 // Grammar Note: labeled statements for SWITCH only; 'goto' is not
1566 compound_statement { $$ = (ast_node *) $1; }
1571 declaration_statement
1572 | expression_statement
1573 | selection_statement
1575 | iteration_statement
1583 $$ = new(ctx) ast_compound_statement(true, NULL);
1584 $$->set_location(yylloc);
1588 state->symbols->push_scope();
1593 $$ = new(ctx) ast_compound_statement(true, $3);
1594 $$->set_location(yylloc);
1595 state->symbols->pop_scope();
1599 statement_no_new_scope:
1600 compound_statement_no_new_scope { $$ = (ast_node *) $1; }
1604 compound_statement_no_new_scope:
1608 $$ = new(ctx) ast_compound_statement(false, NULL);
1609 $$->set_location(yylloc);
1611 | '{' statement_list '}'
1614 $$ = new(ctx) ast_compound_statement(false, $2);
1615 $$->set_location(yylloc);
1623 _mesa_glsl_error(& @1, state, "<nil> statement\n");
1628 $$->link.self_link();
1630 | statement_list statement
1633 _mesa_glsl_error(& @2, state, "<nil> statement\n");
1637 $$->link.insert_before(& $2->link);
1641 expression_statement:
1645 $$ = new(ctx) ast_expression_statement(NULL);
1646 $$->set_location(yylloc);
1651 $$ = new(ctx) ast_expression_statement($1);
1652 $$->set_location(yylloc);
1656 selection_statement:
1657 IF '(' expression ')' selection_rest_statement
1659 $$ = new(state) ast_selection_statement($3, $5.then_statement,
1661 $$->set_location(yylloc);
1665 selection_rest_statement:
1666 statement ELSE statement
1668 $$.then_statement = $1;
1669 $$.else_statement = $3;
1673 $$.then_statement = $1;
1674 $$.else_statement = NULL;
1681 $$ = (ast_node *) $1;
1683 | fully_specified_type any_identifier '=' initializer
1686 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
1687 ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
1688 decl->set_location(yylloc);
1689 declarator->set_location(yylloc);
1691 declarator->declarations.push_tail(&decl->link);
1697 * siwtch_statement grammar is based on the syntax described in the body
1698 * of the GLSL spec, not in it's appendix!!!
1701 SWITCH '(' expression ')' switch_body
1703 $$ = new(state) ast_switch_statement($3, $5);
1704 $$->set_location(yylloc);
1711 $$ = new(state) ast_switch_body(NULL);
1712 $$->set_location(yylloc);
1714 | '{' case_statement_list '}'
1716 $$ = new(state) ast_switch_body($2);
1717 $$->set_location(yylloc);
1724 $$ = new(state) ast_case_label($2);
1725 $$->set_location(yylloc);
1729 $$ = new(state) ast_case_label(NULL);
1730 $$->set_location(yylloc);
1737 ast_case_label_list *labels = new(state) ast_case_label_list();
1739 labels->labels.push_tail(& $1->link);
1741 $$->set_location(yylloc);
1743 | case_label_list case_label
1746 $$->labels.push_tail(& $2->link);
1751 case_label_list statement
1753 ast_case_statement *stmts = new(state) ast_case_statement($1);
1754 stmts->set_location(yylloc);
1756 stmts->stmts.push_tail(& $2->link);
1759 | case_statement statement
1762 $$->stmts.push_tail(& $2->link);
1766 case_statement_list:
1769 ast_case_statement_list *cases= new(state) ast_case_statement_list();
1770 cases->set_location(yylloc);
1772 cases->cases.push_tail(& $1->link);
1775 | case_statement_list case_statement
1778 $$->cases.push_tail(& $2->link);
1782 iteration_statement:
1783 WHILE '(' condition ')' statement_no_new_scope
1786 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
1787 NULL, $3, NULL, $5);
1788 $$->set_location(yylloc);
1790 | DO statement WHILE '(' expression ')' ';'
1793 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
1794 NULL, $5, NULL, $2);
1795 $$->set_location(yylloc);
1797 | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
1800 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
1801 $3, $4.cond, $4.rest, $6);
1802 $$->set_location(yylloc);
1807 expression_statement
1808 | declaration_statement
1825 | conditionopt ';' expression
1832 // Grammar Note: No 'goto'. Gotos are not supported.
1837 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
1838 $$->set_location(yylloc);
1843 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
1844 $$->set_location(yylloc);
1849 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
1850 $$->set_location(yylloc);
1852 | RETURN expression ';'
1855 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
1856 $$->set_location(yylloc);
1858 | DISCARD ';' // Fragment shader only.
1861 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
1862 $$->set_location(yylloc);
1866 external_declaration:
1867 function_definition { $$ = $1; }
1868 | declaration { $$ = $1; }
1869 | pragma_statement { $$ = NULL; }
1870 | layout_defaults { $$ = NULL; }
1873 function_definition:
1874 function_prototype compound_statement_no_new_scope
1877 $$ = new(ctx) ast_function_definition();
1878 $$->set_location(yylloc);
1882 state->symbols->pop_scope();
1886 /* layout_qualifieropt is packed into this rule */
1888 UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1891 $$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,
1894 if (!state->ARB_uniform_buffer_object_enable) {
1895 _mesa_glsl_error(& @1, state,
1896 "#version 140 / GL_ARB_uniform_buffer_object "
1897 "required for defining uniform blocks\n");
1898 } else if (state->ARB_uniform_buffer_object_warn) {
1899 _mesa_glsl_warning(& @1, state,
1900 "#version 140 / GL_ARB_uniform_buffer_object "
1901 "required for defining uniform blocks\n");
1904 | layout_qualifier UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1908 ast_type_qualifier qual = *state->default_uniform_qualifier;
1909 if (!qual.merge_qualifier(& @1, state, $1)) {
1912 $$ = new(ctx) ast_uniform_block(qual, $3, $5);
1914 if (!state->ARB_uniform_buffer_object_enable) {
1915 _mesa_glsl_error(& @1, state,
1916 "#version 140 / GL_ARB_uniform_buffer_object "
1917 "required for defining uniform blocks\n");
1918 } else if (state->ARB_uniform_buffer_object_warn) {
1919 _mesa_glsl_warning(& @1, state,
1920 "#version 140 / GL_ARB_uniform_buffer_object "
1921 "required for defining uniform blocks\n");
1930 $1->link.self_link();
1932 | member_declaration member_list
1935 $2->link.insert_before(& $$->link);
1939 /* Specifying "uniform" inside of a uniform block is redundant. */
1946 layout_qualifier uniformopt type_specifier struct_declarator_list ';'
1949 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1950 type->set_location(yylloc);
1952 type->qualifier = $1;
1953 type->qualifier.flags.q.uniform = true;
1954 type->specifier = $3;
1955 $$ = new(ctx) ast_declarator_list(type);
1956 $$->set_location(yylloc);
1957 $$->ubo_qualifiers_valid = true;
1959 $$->declarations.push_degenerate_list_at_head(& $4->link);
1961 | uniformopt type_specifier struct_declarator_list ';'
1964 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1965 type->set_location(yylloc);
1967 type->qualifier.flags.q.uniform = true;
1968 type->specifier = $2;
1969 $$ = new(ctx) ast_declarator_list(type);
1970 $$->set_location(yylloc);
1971 $$->ubo_qualifiers_valid = true;
1973 $$->declarations.push_degenerate_list_at_head(& $3->link);
1978 layout_qualifier UNIFORM ';'
1980 if (!state->default_uniform_qualifier->merge_qualifier(& @1, state,