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"
33 #define YYLEX_PARAM state->scanner
37 static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
39 _mesa_glsl_error(loc, st, "%s", msg);
55 %lex-param {void *scanner}
56 %parse-param {struct _mesa_glsl_parse_state *state}
61 const char *identifier;
63 struct ast_type_qualifier type_qualifier;
66 ast_type_specifier *type_specifier;
67 ast_fully_specified_type *fully_specified_type;
68 ast_function *function;
69 ast_parameter_declarator *parameter_declarator;
70 ast_function_definition *function_definition;
71 ast_compound_statement *compound_statement;
72 ast_expression *expression;
73 ast_declarator_list *declarator_list;
74 ast_struct_specifier *struct_specifier;
75 ast_declaration *declaration;
76 ast_switch_body *switch_body;
77 ast_case_label *case_label;
78 ast_case_label_list *case_label_list;
79 ast_case_statement *case_statement;
80 ast_case_statement_list *case_statement_list;
88 ast_node *then_statement;
89 ast_node *else_statement;
90 } selection_rest_statement;
93 %token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK
94 %token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
95 %token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4
96 %token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING
97 %token NOPERSPECTIVE FLAT SMOOTH
98 %token MAT2X2 MAT2X3 MAT2X4
99 %token MAT3X2 MAT3X3 MAT3X4
100 %token MAT4X2 MAT4X3 MAT4X4
101 %token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW
102 %token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW
103 %token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
104 %token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D
105 %token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY
106 %token SAMPLER2DRECT ISAMPLER2DRECT USAMPLER2DRECT SAMPLER2DRECTSHADOW
107 %token SAMPLERBUFFER ISAMPLERBUFFER USAMPLERBUFFER
108 %token SAMPLEREXTERNALOES
109 %token STRUCT VOID_TOK WHILE
110 %token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
111 %type <identifier> any_identifier
112 %token <real> FLOATCONSTANT
113 %token <n> INTCONSTANT UINTCONSTANT BOOLCONSTANT
114 %token <identifier> FIELD_SELECTION
115 %token LEFT_OP RIGHT_OP
116 %token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
117 %token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
118 %token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
121 %token LOWP MEDIUMP HIGHP SUPERP PRECISION
123 %token VERSION_TOK EXTENSION LINE COLON EOL INTERFACE OUTPUT
124 %token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF
125 %token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF
126 %token PRAGMA_INVARIANT_ALL
129 /* Reserved words that are not actually used in the grammar.
131 %token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO
132 %token INLINE_TOK NOINLINE VOLATILE PUBLIC_TOK STATIC EXTERN EXTERNAL
133 %token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK OUPTUT
134 %token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4
136 %token SIZEOF CAST NAMESPACE USING
140 %token COMMON PARTITION ACTIVE FILTER
141 %token IMAGE1D IMAGE2D IMAGE3D IMAGECUBE IMAGE1DARRAY IMAGE2DARRAY
142 %token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY
143 %token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGECUBE UIMAGE1DARRAY UIMAGE2DARRAY
144 %token IMAGE1DSHADOW IMAGE2DSHADOW IMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER
145 %token IMAGE1DARRAYSHADOW IMAGE2DARRAYSHADOW
148 %type <identifier> variable_identifier
149 %type <node> statement
150 %type <node> statement_list
151 %type <node> simple_statement
152 %type <n> precision_qualifier
153 %type <type_qualifier> type_qualifier
154 %type <type_qualifier> storage_qualifier
155 %type <type_qualifier> interpolation_qualifier
156 %type <type_qualifier> layout_qualifier
157 %type <type_qualifier> layout_qualifier_id_list layout_qualifier_id
158 %type <type_qualifier> uniform_block_layout_qualifier
159 %type <type_specifier> type_specifier
160 %type <type_specifier> type_specifier_no_prec
161 %type <type_specifier> type_specifier_nonarray
162 %type <identifier> basic_type_specifier_nonarray
163 %type <fully_specified_type> fully_specified_type
164 %type <function> function_prototype
165 %type <function> function_header
166 %type <function> function_header_with_parameters
167 %type <function> function_declarator
168 %type <parameter_declarator> parameter_declarator
169 %type <parameter_declarator> parameter_declaration
170 %type <type_qualifier> parameter_qualifier
171 %type <type_qualifier> parameter_type_qualifier
172 %type <type_specifier> parameter_type_specifier
173 %type <function_definition> function_definition
174 %type <compound_statement> compound_statement_no_new_scope
175 %type <compound_statement> compound_statement
176 %type <node> statement_no_new_scope
177 %type <node> expression_statement
178 %type <expression> expression
179 %type <expression> primary_expression
180 %type <expression> assignment_expression
181 %type <expression> conditional_expression
182 %type <expression> logical_or_expression
183 %type <expression> logical_xor_expression
184 %type <expression> logical_and_expression
185 %type <expression> inclusive_or_expression
186 %type <expression> exclusive_or_expression
187 %type <expression> and_expression
188 %type <expression> equality_expression
189 %type <expression> relational_expression
190 %type <expression> shift_expression
191 %type <expression> additive_expression
192 %type <expression> multiplicative_expression
193 %type <expression> unary_expression
194 %type <expression> constant_expression
195 %type <expression> integer_expression
196 %type <expression> postfix_expression
197 %type <expression> function_call_header_with_parameters
198 %type <expression> function_call_header_no_parameters
199 %type <expression> function_call_header
200 %type <expression> function_call_generic
201 %type <expression> function_call_or_method
202 %type <expression> function_call
203 %type <expression> method_call_generic
204 %type <expression> method_call_header_with_parameters
205 %type <expression> method_call_header_no_parameters
206 %type <expression> method_call_header
207 %type <n> assignment_operator
208 %type <n> unary_operator
209 %type <expression> function_identifier
210 %type <node> external_declaration
211 %type <declarator_list> init_declarator_list
212 %type <declarator_list> single_declaration
213 %type <expression> initializer
214 %type <node> declaration
215 %type <node> declaration_statement
216 %type <node> jump_statement
217 %type <node> uniform_block
218 %type <struct_specifier> struct_specifier
219 %type <declarator_list> struct_declaration_list
220 %type <declarator_list> struct_declaration
221 %type <declaration> struct_declarator
222 %type <declaration> struct_declarator_list
223 %type <declarator_list> member_list
224 %type <declarator_list> member_declaration
225 %type <node> selection_statement
226 %type <selection_rest_statement> selection_rest_statement
227 %type <node> switch_statement
228 %type <switch_body> switch_body
229 %type <case_label_list> case_label_list
230 %type <case_label> case_label
231 %type <case_statement> case_statement
232 %type <case_statement_list> case_statement_list
233 %type <node> iteration_statement
234 %type <node> condition
235 %type <node> conditionopt
236 %type <node> for_init_statement
237 %type <for_rest_statement> for_rest_statement
241 version_statement extension_statement_list
243 _mesa_glsl_initialize_types(state);
245 external_declaration_list
247 delete state->symbols;
248 state->symbols = new(ralloc_parent(state)) glsl_symbol_table;
249 _mesa_glsl_initialize_types(state);
254 /* blank - no #version specified: defaults are already set */
255 | VERSION_TOK INTCONSTANT EOL
257 bool supported = false;
261 state->es_shader = true;
262 supported = state->Const.GLSL_100ES;
265 supported = state->Const.GLSL_110;
268 supported = state->Const.GLSL_120;
271 supported = state->Const.GLSL_130;
274 supported = state->Const.GLSL_140;
281 state->language_version = $2;
282 state->version_string =
283 ralloc_asprintf(state, "GLSL%s %d.%02d",
284 state->es_shader ? " ES" : "",
285 state->language_version / 100,
286 state->language_version % 100);
289 _mesa_glsl_error(& @2, state, "%s is not supported. "
290 "Supported versions are: %s\n",
291 state->version_string,
292 state->supported_version_string);
299 | PRAGMA_DEBUG_OFF EOL
300 | PRAGMA_OPTIMIZE_ON EOL
301 | PRAGMA_OPTIMIZE_OFF EOL
302 | PRAGMA_INVARIANT_ALL EOL
304 if (state->language_version < 120) {
305 _mesa_glsl_warning(& @1, state,
306 "pragma `invariant(all)' not supported in %s",
307 state->version_string);
309 state->all_invariant = true;
314 extension_statement_list:
316 | extension_statement_list extension_statement
326 EXTENSION any_identifier COLON any_identifier EOL
328 if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) {
334 external_declaration_list:
337 /* FINISHME: The NULL test is required because pragmas are set to
338 * FINISHME: NULL. (See production rule for external_declaration.)
341 state->translation_unit.push_tail(& $1->link);
343 | external_declaration_list external_declaration
345 /* FINISHME: The NULL test is required because pragmas are set to
346 * FINISHME: NULL. (See production rule for external_declaration.)
349 state->translation_unit.push_tail(& $2->link);
362 $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
363 $$->set_location(yylloc);
364 $$->primary_expression.identifier = $1;
369 $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
370 $$->set_location(yylloc);
371 $$->primary_expression.int_constant = $1;
376 $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
377 $$->set_location(yylloc);
378 $$->primary_expression.uint_constant = $1;
383 $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
384 $$->set_location(yylloc);
385 $$->primary_expression.float_constant = $1;
390 $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
391 $$->set_location(yylloc);
392 $$->primary_expression.bool_constant = $1;
402 | postfix_expression '[' integer_expression ']'
405 $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL);
406 $$->set_location(yylloc);
412 | postfix_expression '.' any_identifier
415 $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL);
416 $$->set_location(yylloc);
417 $$->primary_expression.identifier = $3;
419 | postfix_expression INC_OP
422 $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL);
423 $$->set_location(yylloc);
425 | postfix_expression DEC_OP
428 $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL);
429 $$->set_location(yylloc);
438 function_call_or_method
441 function_call_or_method:
442 function_call_generic
443 | postfix_expression '.' method_call_generic
446 $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL);
447 $$->set_location(yylloc);
451 function_call_generic:
452 function_call_header_with_parameters ')'
453 | function_call_header_no_parameters ')'
456 function_call_header_no_parameters:
457 function_call_header VOID_TOK
458 | function_call_header
461 function_call_header_with_parameters:
462 function_call_header assignment_expression
465 $$->set_location(yylloc);
466 $$->expressions.push_tail(& $2->link);
468 | function_call_header_with_parameters ',' assignment_expression
471 $$->set_location(yylloc);
472 $$->expressions.push_tail(& $3->link);
476 // Grammar Note: Constructors look like functions, but lexical
477 // analysis recognized most of them as keywords. They are now
478 // recognized through "type_specifier".
479 function_call_header:
480 function_identifier '('
487 $$ = new(ctx) ast_function_expression($1);
488 $$->set_location(yylloc);
490 | variable_identifier
493 ast_expression *callee = new(ctx) ast_expression($1);
494 $$ = new(ctx) ast_function_expression(callee);
495 $$->set_location(yylloc);
500 ast_expression *callee = new(ctx) ast_expression($1);
501 $$ = new(ctx) ast_function_expression(callee);
502 $$->set_location(yylloc);
507 method_call_header_with_parameters ')'
508 | method_call_header_no_parameters ')'
511 method_call_header_no_parameters:
512 method_call_header VOID_TOK
516 method_call_header_with_parameters:
517 method_call_header assignment_expression
520 $$->set_location(yylloc);
521 $$->expressions.push_tail(& $2->link);
523 | method_call_header_with_parameters ',' assignment_expression
526 $$->set_location(yylloc);
527 $$->expressions.push_tail(& $3->link);
531 // Grammar Note: Constructors look like methods, but lexical
532 // analysis recognized most of them as keywords. They are now
533 // recognized through "type_specifier".
535 variable_identifier '('
538 ast_expression *callee = new(ctx) ast_expression($1);
539 $$ = new(ctx) ast_function_expression(callee);
540 $$->set_location(yylloc);
544 // Grammar Note: No traditional style type casts.
547 | INC_OP unary_expression
550 $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL);
551 $$->set_location(yylloc);
553 | DEC_OP unary_expression
556 $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL);
557 $$->set_location(yylloc);
559 | unary_operator unary_expression
562 $$ = new(ctx) ast_expression($1, $2, NULL, NULL);
563 $$->set_location(yylloc);
567 // Grammar Note: No '*' or '&' unary ops. Pointers are not supported.
569 '+' { $$ = ast_plus; }
570 | '-' { $$ = ast_neg; }
571 | '!' { $$ = ast_logic_not; }
572 | '~' { $$ = ast_bit_not; }
575 multiplicative_expression:
577 | multiplicative_expression '*' unary_expression
580 $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3);
581 $$->set_location(yylloc);
583 | multiplicative_expression '/' unary_expression
586 $$ = new(ctx) ast_expression_bin(ast_div, $1, $3);
587 $$->set_location(yylloc);
589 | multiplicative_expression '%' unary_expression
592 $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3);
593 $$->set_location(yylloc);
598 multiplicative_expression
599 | additive_expression '+' multiplicative_expression
602 $$ = new(ctx) ast_expression_bin(ast_add, $1, $3);
603 $$->set_location(yylloc);
605 | additive_expression '-' multiplicative_expression
608 $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3);
609 $$->set_location(yylloc);
615 | shift_expression LEFT_OP additive_expression
618 $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3);
619 $$->set_location(yylloc);
621 | shift_expression RIGHT_OP additive_expression
624 $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3);
625 $$->set_location(yylloc);
629 relational_expression:
631 | relational_expression '<' shift_expression
634 $$ = new(ctx) ast_expression_bin(ast_less, $1, $3);
635 $$->set_location(yylloc);
637 | relational_expression '>' shift_expression
640 $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3);
641 $$->set_location(yylloc);
643 | relational_expression LE_OP shift_expression
646 $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3);
647 $$->set_location(yylloc);
649 | relational_expression GE_OP shift_expression
652 $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3);
653 $$->set_location(yylloc);
658 relational_expression
659 | equality_expression EQ_OP relational_expression
662 $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3);
663 $$->set_location(yylloc);
665 | equality_expression NE_OP relational_expression
668 $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3);
669 $$->set_location(yylloc);
675 | and_expression '&' equality_expression
678 $$ = new(ctx) ast_expression_bin(ast_bit_and, $1, $3);
679 $$->set_location(yylloc);
683 exclusive_or_expression:
685 | exclusive_or_expression '^' and_expression
688 $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3);
689 $$->set_location(yylloc);
693 inclusive_or_expression:
694 exclusive_or_expression
695 | inclusive_or_expression '|' exclusive_or_expression
698 $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
699 $$->set_location(yylloc);
703 logical_and_expression:
704 inclusive_or_expression
705 | logical_and_expression AND_OP inclusive_or_expression
708 $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3);
709 $$->set_location(yylloc);
713 logical_xor_expression:
714 logical_and_expression
715 | logical_xor_expression XOR_OP logical_and_expression
718 $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3);
719 $$->set_location(yylloc);
723 logical_or_expression:
724 logical_xor_expression
725 | logical_or_expression OR_OP logical_xor_expression
728 $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3);
729 $$->set_location(yylloc);
733 conditional_expression:
734 logical_or_expression
735 | logical_or_expression '?' expression ':' assignment_expression
738 $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5);
739 $$->set_location(yylloc);
743 assignment_expression:
744 conditional_expression
745 | unary_expression assignment_operator assignment_expression
748 $$ = new(ctx) ast_expression($2, $1, $3, NULL);
749 $$->set_location(yylloc);
754 '=' { $$ = ast_assign; }
755 | MUL_ASSIGN { $$ = ast_mul_assign; }
756 | DIV_ASSIGN { $$ = ast_div_assign; }
757 | MOD_ASSIGN { $$ = ast_mod_assign; }
758 | ADD_ASSIGN { $$ = ast_add_assign; }
759 | SUB_ASSIGN { $$ = ast_sub_assign; }
760 | LEFT_ASSIGN { $$ = ast_ls_assign; }
761 | RIGHT_ASSIGN { $$ = ast_rs_assign; }
762 | AND_ASSIGN { $$ = ast_and_assign; }
763 | XOR_ASSIGN { $$ = ast_xor_assign; }
764 | OR_ASSIGN { $$ = ast_or_assign; }
768 assignment_expression
772 | expression ',' assignment_expression
775 if ($1->oper != ast_sequence) {
776 $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
777 $$->set_location(yylloc);
778 $$->expressions.push_tail(& $1->link);
783 $$->expressions.push_tail(& $3->link);
788 conditional_expression
792 function_prototype ';'
794 state->symbols->pop_scope();
797 | init_declarator_list ';'
801 | PRECISION precision_qualifier type_specifier_no_prec ';'
804 $3->is_precision_statement = true;
814 function_declarator ')'
819 | function_header_with_parameters
822 function_header_with_parameters:
823 function_header parameter_declaration
826 $$->parameters.push_tail(& $2->link);
828 | function_header_with_parameters ',' parameter_declaration
831 $$->parameters.push_tail(& $3->link);
836 fully_specified_type variable_identifier '('
839 $$ = new(ctx) ast_function();
840 $$->set_location(yylloc);
841 $$->return_type = $1;
844 state->symbols->add_function(new(state) ir_function($2));
845 state->symbols->push_scope();
849 parameter_declarator:
850 type_specifier any_identifier
853 $$ = new(ctx) ast_parameter_declarator();
854 $$->set_location(yylloc);
855 $$->type = new(ctx) ast_fully_specified_type();
856 $$->type->set_location(yylloc);
857 $$->type->specifier = $1;
860 | type_specifier any_identifier '[' constant_expression ']'
863 $$ = new(ctx) ast_parameter_declarator();
864 $$->set_location(yylloc);
865 $$->type = new(ctx) ast_fully_specified_type();
866 $$->type->set_location(yylloc);
867 $$->type->specifier = $1;
874 parameter_declaration:
875 parameter_type_qualifier parameter_qualifier parameter_declarator
877 $1.flags.i |= $2.flags.i;
880 $$->type->qualifier = $1;
882 | parameter_qualifier parameter_declarator
885 $$->type->qualifier = $1;
887 | parameter_type_qualifier parameter_qualifier parameter_type_specifier
890 $1.flags.i |= $2.flags.i;
892 $$ = new(ctx) ast_parameter_declarator();
893 $$->set_location(yylloc);
894 $$->type = new(ctx) ast_fully_specified_type();
895 $$->type->qualifier = $1;
896 $$->type->specifier = $3;
898 | parameter_qualifier parameter_type_specifier
901 $$ = new(ctx) ast_parameter_declarator();
902 $$->set_location(yylloc);
903 $$->type = new(ctx) ast_fully_specified_type();
904 $$->type->qualifier = $1;
905 $$->type->specifier = $2;
912 memset(& $$, 0, sizeof($$));
916 memset(& $$, 0, sizeof($$));
921 memset(& $$, 0, sizeof($$));
926 memset(& $$, 0, sizeof($$));
932 parameter_type_specifier:
936 init_declarator_list:
938 | init_declarator_list ',' any_identifier
941 ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL);
942 decl->set_location(yylloc);
945 $$->declarations.push_tail(&decl->link);
946 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
948 | init_declarator_list ',' any_identifier '[' ']'
951 ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
952 decl->set_location(yylloc);
955 $$->declarations.push_tail(&decl->link);
956 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
958 | init_declarator_list ',' any_identifier '[' constant_expression ']'
961 ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
962 decl->set_location(yylloc);
965 $$->declarations.push_tail(&decl->link);
966 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
968 | init_declarator_list ',' any_identifier '[' ']' '=' initializer
971 ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
972 decl->set_location(yylloc);
975 $$->declarations.push_tail(&decl->link);
976 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
978 | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' initializer
981 ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
982 decl->set_location(yylloc);
985 $$->declarations.push_tail(&decl->link);
986 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
988 | init_declarator_list ',' any_identifier '=' initializer
991 ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5);
992 decl->set_location(yylloc);
995 $$->declarations.push_tail(&decl->link);
996 state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
1000 // Grammar Note: No 'enum', or 'typedef'.
1002 fully_specified_type
1005 /* Empty declaration list is valid. */
1006 $$ = new(ctx) ast_declarator_list($1);
1007 $$->set_location(yylloc);
1009 | fully_specified_type any_identifier
1012 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
1014 $$ = new(ctx) ast_declarator_list($1);
1015 $$->set_location(yylloc);
1016 $$->declarations.push_tail(&decl->link);
1018 | fully_specified_type any_identifier '[' ']'
1021 ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
1023 $$ = new(ctx) ast_declarator_list($1);
1024 $$->set_location(yylloc);
1025 $$->declarations.push_tail(&decl->link);
1027 | fully_specified_type any_identifier '[' constant_expression ']'
1030 ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
1032 $$ = new(ctx) ast_declarator_list($1);
1033 $$->set_location(yylloc);
1034 $$->declarations.push_tail(&decl->link);
1036 | fully_specified_type any_identifier '[' ']' '=' initializer
1039 ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
1041 $$ = new(ctx) ast_declarator_list($1);
1042 $$->set_location(yylloc);
1043 $$->declarations.push_tail(&decl->link);
1045 | fully_specified_type any_identifier '[' constant_expression ']' '=' initializer
1048 ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
1050 $$ = new(ctx) ast_declarator_list($1);
1051 $$->set_location(yylloc);
1052 $$->declarations.push_tail(&decl->link);
1054 | fully_specified_type any_identifier '=' initializer
1057 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
1059 $$ = new(ctx) ast_declarator_list($1);
1060 $$->set_location(yylloc);
1061 $$->declarations.push_tail(&decl->link);
1063 | INVARIANT variable_identifier // Vertex only.
1066 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
1068 $$ = new(ctx) ast_declarator_list(NULL);
1069 $$->set_location(yylloc);
1070 $$->invariant = true;
1072 $$->declarations.push_tail(&decl->link);
1076 fully_specified_type:
1080 $$ = new(ctx) ast_fully_specified_type();
1081 $$->set_location(yylloc);
1084 | type_qualifier type_specifier
1087 $$ = new(ctx) ast_fully_specified_type();
1088 $$->set_location(yylloc);
1095 LAYOUT_TOK '(' layout_qualifier_id_list ')'
1101 layout_qualifier_id_list:
1103 | layout_qualifier_id_list ',' layout_qualifier_id
1105 if (($1.flags.i & $3.flags.i) != 0) {
1106 _mesa_glsl_error(& @3, state,
1107 "duplicate layout qualifiers used\n");
1112 $$.flags.i |= $3.flags.i;
1114 if ($3.flags.q.explicit_location)
1115 $$.location = $3.location;
1117 if ($3.flags.q.explicit_index)
1118 $$.index = $3.index;
1122 layout_qualifier_id:
1125 memset(& $$, 0, sizeof($$));
1127 /* Layout qualifiers for ARB_fragment_coord_conventions. */
1128 if (!$$.flags.i && state->ARB_fragment_coord_conventions_enable) {
1129 if (strcmp($1, "origin_upper_left") == 0) {
1130 $$.flags.q.origin_upper_left = 1;
1131 } else if (strcmp($1, "pixel_center_integer") == 0) {
1132 $$.flags.q.pixel_center_integer = 1;
1135 if ($$.flags.i && state->ARB_fragment_coord_conventions_warn) {
1136 _mesa_glsl_warning(& @1, state,
1137 "GL_ARB_fragment_coord_conventions layout "
1138 "identifier `%s' used\n", $1);
1142 /* Layout qualifiers for AMD/ARB_conservative_depth. */
1144 (state->AMD_conservative_depth_enable ||
1145 state->ARB_conservative_depth_enable)) {
1146 if (strcmp($1, "depth_any") == 0) {
1147 $$.flags.q.depth_any = 1;
1148 } else if (strcmp($1, "depth_greater") == 0) {
1149 $$.flags.q.depth_greater = 1;
1150 } else if (strcmp($1, "depth_less") == 0) {
1151 $$.flags.q.depth_less = 1;
1152 } else if (strcmp($1, "depth_unchanged") == 0) {
1153 $$.flags.q.depth_unchanged = 1;
1156 if ($$.flags.i && state->AMD_conservative_depth_warn) {
1157 _mesa_glsl_warning(& @1, state,
1158 "GL_AMD_conservative_depth "
1159 "layout qualifier `%s' is used\n", $1);
1161 if ($$.flags.i && state->ARB_conservative_depth_warn) {
1162 _mesa_glsl_warning(& @1, state,
1163 "GL_ARB_conservative_depth "
1164 "layout qualifier `%s' is used\n", $1);
1168 /* See also uniform_block_layout_qualifier. */
1169 if (!$$.flags.i && state->ARB_uniform_buffer_object_enable) {
1170 if (strcmp($1, "std140") == 0) {
1171 $$.flags.q.std140 = 1;
1172 } else if (strcmp($1, "shared") == 0) {
1173 $$.flags.q.shared = 1;
1174 } else if (strcmp($1, "column_major") == 0) {
1175 $$.flags.q.column_major = 1;
1178 if ($$.flags.i && state->ARB_uniform_buffer_object_warn) {
1179 _mesa_glsl_warning(& @1, state,
1180 "#version 140 / GL_ARB_uniform_buffer_object "
1181 "layout qualifier `%s' is used\n", $1);
1186 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1191 | any_identifier '=' INTCONSTANT
1193 memset(& $$, 0, sizeof($$));
1195 if (state->ARB_explicit_attrib_location_enable) {
1196 /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and
1197 * FINISHME: GLSL 1.30 (or later) are supported.
1199 if (strcmp("location", $1) == 0) {
1200 $$.flags.q.explicit_location = 1;
1205 _mesa_glsl_error(& @3, state,
1206 "invalid location %d specified\n", $3);
1211 if (strcmp("index", $1) == 0) {
1212 $$.flags.q.explicit_index = 1;
1217 _mesa_glsl_error(& @3, state,
1218 "invalid index %d specified\n", $3);
1224 /* If the identifier didn't match any known layout identifiers,
1228 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1231 } else if (state->ARB_explicit_attrib_location_warn) {
1232 _mesa_glsl_warning(& @1, state,
1233 "GL_ARB_explicit_attrib_location layout "
1234 "identifier `%s' used\n", $1);
1237 | uniform_block_layout_qualifier
1240 /* Layout qualifiers for ARB_uniform_buffer_object. */
1241 if (!state->ARB_uniform_buffer_object_enable) {
1242 _mesa_glsl_error(& @1, state,
1243 "#version 140 / GL_ARB_uniform_buffer_object "
1244 "layout qualifier `%s' is used\n", $1);
1245 } else if (state->ARB_uniform_buffer_object_warn) {
1246 _mesa_glsl_warning(& @1, state,
1247 "#version 140 / GL_ARB_uniform_buffer_object "
1248 "layout qualifier `%s' is used\n", $1);
1253 /* This is a separate language rule because we parse these as tokens
1254 * (due to them being reserved keywords) instead of identifiers like
1255 * most qualifiers. See the any_identifier path of
1256 * layout_qualifier_id for the others.
1258 uniform_block_layout_qualifier:
1261 memset(& $$, 0, sizeof($$));
1262 $$.flags.q.row_major = 1;
1266 memset(& $$, 0, sizeof($$));
1267 $$.flags.q.packed = 1;
1271 interpolation_qualifier:
1274 memset(& $$, 0, sizeof($$));
1275 $$.flags.q.smooth = 1;
1279 memset(& $$, 0, sizeof($$));
1280 $$.flags.q.flat = 1;
1284 memset(& $$, 0, sizeof($$));
1285 $$.flags.q.noperspective = 1;
1289 parameter_type_qualifier:
1292 memset(& $$, 0, sizeof($$));
1293 $$.flags.q.constant = 1;
1300 | layout_qualifier storage_qualifier
1303 $$.flags.i |= $2.flags.i;
1305 | interpolation_qualifier
1306 | interpolation_qualifier storage_qualifier
1309 $$.flags.i |= $2.flags.i;
1311 | INVARIANT storage_qualifier
1314 $$.flags.q.invariant = 1;
1316 | INVARIANT interpolation_qualifier storage_qualifier
1319 $$.flags.i |= $3.flags.i;
1320 $$.flags.q.invariant = 1;
1324 memset(& $$, 0, sizeof($$));
1325 $$.flags.q.invariant = 1;
1332 memset(& $$, 0, sizeof($$));
1333 $$.flags.q.constant = 1;
1337 memset(& $$, 0, sizeof($$));
1338 $$.flags.q.attribute = 1;
1342 memset(& $$, 0, sizeof($$));
1343 $$.flags.q.varying = 1;
1347 memset(& $$, 0, sizeof($$));
1348 $$.flags.q.centroid = 1;
1349 $$.flags.q.varying = 1;
1353 memset(& $$, 0, sizeof($$));
1358 memset(& $$, 0, sizeof($$));
1363 memset(& $$, 0, sizeof($$));
1364 $$.flags.q.centroid = 1; $$.flags.q.in = 1;
1368 memset(& $$, 0, sizeof($$));
1369 $$.flags.q.centroid = 1; $$.flags.q.out = 1;
1373 memset(& $$, 0, sizeof($$));
1374 $$.flags.q.uniform = 1;
1379 type_specifier_no_prec
1383 | precision_qualifier type_specifier_no_prec
1390 type_specifier_no_prec:
1391 type_specifier_nonarray
1392 | type_specifier_nonarray '[' ']'
1395 $$->is_array = true;
1396 $$->array_size = NULL;
1398 | type_specifier_nonarray '[' constant_expression ']'
1401 $$->is_array = true;
1402 $$->array_size = $3;
1406 type_specifier_nonarray:
1407 basic_type_specifier_nonarray
1410 $$ = new(ctx) ast_type_specifier($1);
1411 $$->set_location(yylloc);
1416 $$ = new(ctx) ast_type_specifier($1);
1417 $$->set_location(yylloc);
1422 $$ = new(ctx) ast_type_specifier($1);
1423 $$->set_location(yylloc);
1427 basic_type_specifier_nonarray:
1428 VOID_TOK { $$ = "void"; }
1429 | FLOAT_TOK { $$ = "float"; }
1430 | INT_TOK { $$ = "int"; }
1431 | UINT_TOK { $$ = "uint"; }
1432 | BOOL_TOK { $$ = "bool"; }
1433 | VEC2 { $$ = "vec2"; }
1434 | VEC3 { $$ = "vec3"; }
1435 | VEC4 { $$ = "vec4"; }
1436 | BVEC2 { $$ = "bvec2"; }
1437 | BVEC3 { $$ = "bvec3"; }
1438 | BVEC4 { $$ = "bvec4"; }
1439 | IVEC2 { $$ = "ivec2"; }
1440 | IVEC3 { $$ = "ivec3"; }
1441 | IVEC4 { $$ = "ivec4"; }
1442 | UVEC2 { $$ = "uvec2"; }
1443 | UVEC3 { $$ = "uvec3"; }
1444 | UVEC4 { $$ = "uvec4"; }
1445 | MAT2X2 { $$ = "mat2"; }
1446 | MAT2X3 { $$ = "mat2x3"; }
1447 | MAT2X4 { $$ = "mat2x4"; }
1448 | MAT3X2 { $$ = "mat3x2"; }
1449 | MAT3X3 { $$ = "mat3"; }
1450 | MAT3X4 { $$ = "mat3x4"; }
1451 | MAT4X2 { $$ = "mat4x2"; }
1452 | MAT4X3 { $$ = "mat4x3"; }
1453 | MAT4X4 { $$ = "mat4"; }
1454 | SAMPLER1D { $$ = "sampler1D"; }
1455 | SAMPLER2D { $$ = "sampler2D"; }
1456 | SAMPLER2DRECT { $$ = "sampler2DRect"; }
1457 | SAMPLER3D { $$ = "sampler3D"; }
1458 | SAMPLERCUBE { $$ = "samplerCube"; }
1459 | SAMPLEREXTERNALOES { $$ = "samplerExternalOES"; }
1460 | SAMPLER1DSHADOW { $$ = "sampler1DShadow"; }
1461 | SAMPLER2DSHADOW { $$ = "sampler2DShadow"; }
1462 | SAMPLER2DRECTSHADOW { $$ = "sampler2DRectShadow"; }
1463 | SAMPLERCUBESHADOW { $$ = "samplerCubeShadow"; }
1464 | SAMPLER1DARRAY { $$ = "sampler1DArray"; }
1465 | SAMPLER2DARRAY { $$ = "sampler2DArray"; }
1466 | SAMPLER1DARRAYSHADOW { $$ = "sampler1DArrayShadow"; }
1467 | SAMPLER2DARRAYSHADOW { $$ = "sampler2DArrayShadow"; }
1468 | SAMPLERBUFFER { $$ = "samplerBuffer"; }
1469 | ISAMPLER1D { $$ = "isampler1D"; }
1470 | ISAMPLER2D { $$ = "isampler2D"; }
1471 | ISAMPLER2DRECT { $$ = "isampler2DRect"; }
1472 | ISAMPLER3D { $$ = "isampler3D"; }
1473 | ISAMPLERCUBE { $$ = "isamplerCube"; }
1474 | ISAMPLER1DARRAY { $$ = "isampler1DArray"; }
1475 | ISAMPLER2DARRAY { $$ = "isampler2DArray"; }
1476 | ISAMPLERBUFFER { $$ = "isamplerBuffer"; }
1477 | USAMPLER1D { $$ = "usampler1D"; }
1478 | USAMPLER2D { $$ = "usampler2D"; }
1479 | USAMPLER2DRECT { $$ = "usampler2DRect"; }
1480 | USAMPLER3D { $$ = "usampler3D"; }
1481 | USAMPLERCUBE { $$ = "usamplerCube"; }
1482 | USAMPLER1DARRAY { $$ = "usampler1DArray"; }
1483 | USAMPLER2DARRAY { $$ = "usampler2DArray"; }
1484 | USAMPLERBUFFER { $$ = "usamplerBuffer"; }
1487 precision_qualifier:
1489 if (!state->es_shader && state->language_version < 130)
1490 _mesa_glsl_error(& @1, state,
1491 "precision qualifier forbidden "
1492 "in %s (1.30 or later "
1494 state->version_string);
1496 $$ = ast_precision_high;
1499 if (!state->es_shader && state->language_version < 130)
1500 _mesa_glsl_error(& @1, state,
1501 "precision qualifier forbidden "
1502 "in %s (1.30 or later "
1504 state->version_string);
1506 $$ = ast_precision_medium;
1509 if (!state->es_shader && state->language_version < 130)
1510 _mesa_glsl_error(& @1, state,
1511 "precision qualifier forbidden "
1512 "in %s (1.30 or later "
1514 state->version_string);
1516 $$ = ast_precision_low;
1521 STRUCT any_identifier '{' struct_declaration_list '}'
1524 $$ = new(ctx) ast_struct_specifier($2, $4);
1525 $$->set_location(yylloc);
1526 state->symbols->add_type($2, glsl_type::void_type);
1528 | STRUCT '{' struct_declaration_list '}'
1531 $$ = new(ctx) ast_struct_specifier(NULL, $3);
1532 $$->set_location(yylloc);
1536 struct_declaration_list:
1540 $1->link.self_link();
1542 | struct_declaration_list struct_declaration
1545 $$->link.insert_before(& $2->link);
1550 type_specifier struct_declarator_list ';'
1553 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1554 type->set_location(yylloc);
1556 type->specifier = $1;
1557 $$ = new(ctx) ast_declarator_list(type);
1558 $$->set_location(yylloc);
1560 $$->declarations.push_degenerate_list_at_head(& $2->link);
1564 struct_declarator_list:
1568 $1->link.self_link();
1570 | struct_declarator_list ',' struct_declarator
1573 $$->link.insert_before(& $3->link);
1581 $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
1582 $$->set_location(yylloc);
1583 state->symbols->add_variable(new(state) ir_variable(NULL, $1, ir_var_auto));
1585 | any_identifier '[' constant_expression ']'
1588 $$ = new(ctx) ast_declaration($1, true, $3, NULL);
1589 $$->set_location(yylloc);
1594 assignment_expression
1597 declaration_statement:
1601 // Grammar Note: labeled statements for SWITCH only; 'goto' is not
1604 compound_statement { $$ = (ast_node *) $1; }
1609 declaration_statement
1610 | expression_statement
1611 | selection_statement
1613 | iteration_statement
1621 $$ = new(ctx) ast_compound_statement(true, NULL);
1622 $$->set_location(yylloc);
1626 state->symbols->push_scope();
1631 $$ = new(ctx) ast_compound_statement(true, $3);
1632 $$->set_location(yylloc);
1633 state->symbols->pop_scope();
1637 statement_no_new_scope:
1638 compound_statement_no_new_scope { $$ = (ast_node *) $1; }
1642 compound_statement_no_new_scope:
1646 $$ = new(ctx) ast_compound_statement(false, NULL);
1647 $$->set_location(yylloc);
1649 | '{' statement_list '}'
1652 $$ = new(ctx) ast_compound_statement(false, $2);
1653 $$->set_location(yylloc);
1661 _mesa_glsl_error(& @1, state, "<nil> statement\n");
1666 $$->link.self_link();
1668 | statement_list statement
1671 _mesa_glsl_error(& @2, state, "<nil> statement\n");
1675 $$->link.insert_before(& $2->link);
1679 expression_statement:
1683 $$ = new(ctx) ast_expression_statement(NULL);
1684 $$->set_location(yylloc);
1689 $$ = new(ctx) ast_expression_statement($1);
1690 $$->set_location(yylloc);
1694 selection_statement:
1695 IF '(' expression ')' selection_rest_statement
1697 $$ = new(state) ast_selection_statement($3, $5.then_statement,
1699 $$->set_location(yylloc);
1703 selection_rest_statement:
1704 statement ELSE statement
1706 $$.then_statement = $1;
1707 $$.else_statement = $3;
1711 $$.then_statement = $1;
1712 $$.else_statement = NULL;
1719 $$ = (ast_node *) $1;
1721 | fully_specified_type any_identifier '=' initializer
1724 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
1725 ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
1726 decl->set_location(yylloc);
1727 declarator->set_location(yylloc);
1729 declarator->declarations.push_tail(&decl->link);
1735 * siwtch_statement grammar is based on the syntax described in the body
1736 * of the GLSL spec, not in it's appendix!!!
1739 SWITCH '(' expression ')' switch_body
1741 $$ = new(state) ast_switch_statement($3, $5);
1742 $$->set_location(yylloc);
1749 $$ = new(state) ast_switch_body(NULL);
1750 $$->set_location(yylloc);
1752 | '{' case_statement_list '}'
1754 $$ = new(state) ast_switch_body($2);
1755 $$->set_location(yylloc);
1762 $$ = new(state) ast_case_label($2);
1763 $$->set_location(yylloc);
1767 $$ = new(state) ast_case_label(NULL);
1768 $$->set_location(yylloc);
1775 ast_case_label_list *labels = new(state) ast_case_label_list();
1777 labels->labels.push_tail(& $1->link);
1779 $$->set_location(yylloc);
1781 | case_label_list case_label
1784 $$->labels.push_tail(& $2->link);
1789 case_label_list statement
1791 ast_case_statement *stmts = new(state) ast_case_statement($1);
1792 stmts->set_location(yylloc);
1794 stmts->stmts.push_tail(& $2->link);
1797 | case_statement statement
1800 $$->stmts.push_tail(& $2->link);
1804 case_statement_list:
1807 ast_case_statement_list *cases= new(state) ast_case_statement_list();
1808 cases->set_location(yylloc);
1810 cases->cases.push_tail(& $1->link);
1813 | case_statement_list case_statement
1816 $$->cases.push_tail(& $2->link);
1820 iteration_statement:
1821 WHILE '(' condition ')' statement_no_new_scope
1824 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
1825 NULL, $3, NULL, $5);
1826 $$->set_location(yylloc);
1828 | DO statement WHILE '(' expression ')' ';'
1831 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
1832 NULL, $5, NULL, $2);
1833 $$->set_location(yylloc);
1835 | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
1838 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
1839 $3, $4.cond, $4.rest, $6);
1840 $$->set_location(yylloc);
1845 expression_statement
1846 | declaration_statement
1863 | conditionopt ';' expression
1870 // Grammar Note: No 'goto'. Gotos are not supported.
1875 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
1876 $$->set_location(yylloc);
1881 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
1882 $$->set_location(yylloc);
1887 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
1888 $$->set_location(yylloc);
1890 | RETURN expression ';'
1893 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
1894 $$->set_location(yylloc);
1896 | DISCARD ';' // Fragment shader only.
1899 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
1900 $$->set_location(yylloc);
1904 external_declaration:
1905 function_definition { $$ = $1; }
1906 | declaration { $$ = $1; }
1907 | pragma_statement { $$ = NULL; }
1910 function_definition:
1911 function_prototype compound_statement_no_new_scope
1914 $$ = new(ctx) ast_function_definition();
1915 $$->set_location(yylloc);
1919 state->symbols->pop_scope();
1923 /* layout_qualifieropt is packed into this rule */
1925 UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1928 ast_type_qualifier no_qual;
1929 memset(&no_qual, 0, sizeof(no_qual));
1930 $$ = new(ctx) ast_uniform_block(no_qual, $2, $4);
1932 | layout_qualifier UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1935 $$ = new(ctx) ast_uniform_block($1, $3, $5);
1943 $1->link.self_link();
1945 | member_declaration member_list
1948 $2->link.insert_before(& $$->link);
1952 /* Specifying "uniform" inside of a uniform block is redundant. */
1959 layout_qualifier uniformopt type_specifier struct_declarator_list ';'
1962 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1963 type->set_location(yylloc);
1965 type->qualifier = $1;
1966 type->qualifier.flags.q.uniform = true;
1967 type->specifier = $3;
1968 $$ = new(ctx) ast_declarator_list(type);
1969 $$->set_location(yylloc);
1970 $$->ubo_qualifiers_valid = true;
1972 $$->declarations.push_degenerate_list_at_head(& $4->link);
1974 | uniformopt type_specifier struct_declarator_list ';'
1977 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1978 type->set_location(yylloc);
1980 type->qualifier.flags.q.uniform = true;
1981 type->specifier = $2;
1982 $$ = new(ctx) ast_declarator_list(type);
1983 $$->set_location(yylloc);
1984 $$->ubo_qualifiers_valid = true;
1986 $$->declarations.push_degenerate_list_at_head(& $3->link);