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;
1146 } else if (strcmp($1, "row_major") == 0) {
1147 $$.flags.q.row_major = 1;
1150 if ($$.flags.i && state->ARB_uniform_buffer_object_warn) {
1151 _mesa_glsl_warning(& @1, state,
1152 "#version 140 / GL_ARB_uniform_buffer_object "
1153 "layout qualifier `%s' is used\n", $1);
1158 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1163 | any_identifier '=' integer_constant
1165 memset(& $$, 0, sizeof($$));
1167 if (state->ARB_explicit_attrib_location_enable) {
1168 /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and
1169 * FINISHME: GLSL 1.30 (or later) are supported.
1171 if (strcmp("location", $1) == 0) {
1172 $$.flags.q.explicit_location = 1;
1177 _mesa_glsl_error(& @3, state,
1178 "invalid location %d specified\n", $3);
1183 if (strcmp("index", $1) == 0) {
1184 $$.flags.q.explicit_index = 1;
1189 _mesa_glsl_error(& @3, state,
1190 "invalid index %d specified\n", $3);
1196 /* If the identifier didn't match any known layout identifiers,
1200 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
1203 } else if (state->ARB_explicit_attrib_location_warn) {
1204 _mesa_glsl_warning(& @1, state,
1205 "GL_ARB_explicit_attrib_location layout "
1206 "identifier `%s' used\n", $1);
1209 | uniform_block_layout_qualifier
1212 /* Layout qualifiers for ARB_uniform_buffer_object. */
1213 if (!state->ARB_uniform_buffer_object_enable) {
1214 _mesa_glsl_error(& @1, state,
1215 "#version 140 / GL_ARB_uniform_buffer_object "
1216 "layout qualifier `%s' is used\n", $1);
1217 } else if (state->ARB_uniform_buffer_object_warn) {
1218 _mesa_glsl_warning(& @1, state,
1219 "#version 140 / GL_ARB_uniform_buffer_object "
1220 "layout qualifier `%s' is used\n", $1);
1225 /* This is a separate language rule because we parse these as tokens
1226 * (due to them being reserved keywords) instead of identifiers like
1227 * most qualifiers. See the any_identifier path of
1228 * layout_qualifier_id for the others.
1230 uniform_block_layout_qualifier:
1233 memset(& $$, 0, sizeof($$));
1234 $$.flags.q.row_major = 1;
1238 memset(& $$, 0, sizeof($$));
1239 $$.flags.q.packed = 1;
1243 interpolation_qualifier:
1246 memset(& $$, 0, sizeof($$));
1247 $$.flags.q.smooth = 1;
1251 memset(& $$, 0, sizeof($$));
1252 $$.flags.q.flat = 1;
1256 memset(& $$, 0, sizeof($$));
1257 $$.flags.q.noperspective = 1;
1261 parameter_type_qualifier:
1264 memset(& $$, 0, sizeof($$));
1265 $$.flags.q.constant = 1;
1272 | layout_qualifier storage_qualifier
1275 $$.flags.i |= $2.flags.i;
1277 | interpolation_qualifier
1278 | interpolation_qualifier storage_qualifier
1281 $$.flags.i |= $2.flags.i;
1283 | INVARIANT storage_qualifier
1286 $$.flags.q.invariant = 1;
1288 | INVARIANT interpolation_qualifier storage_qualifier
1291 $$.flags.i |= $3.flags.i;
1292 $$.flags.q.invariant = 1;
1296 memset(& $$, 0, sizeof($$));
1297 $$.flags.q.invariant = 1;
1304 memset(& $$, 0, sizeof($$));
1305 $$.flags.q.constant = 1;
1309 memset(& $$, 0, sizeof($$));
1310 $$.flags.q.attribute = 1;
1314 memset(& $$, 0, sizeof($$));
1315 $$.flags.q.varying = 1;
1319 memset(& $$, 0, sizeof($$));
1320 $$.flags.q.centroid = 1;
1321 $$.flags.q.varying = 1;
1325 memset(& $$, 0, sizeof($$));
1330 memset(& $$, 0, sizeof($$));
1335 memset(& $$, 0, sizeof($$));
1336 $$.flags.q.centroid = 1; $$.flags.q.in = 1;
1340 memset(& $$, 0, sizeof($$));
1341 $$.flags.q.centroid = 1; $$.flags.q.out = 1;
1345 memset(& $$, 0, sizeof($$));
1346 $$.flags.q.uniform = 1;
1351 type_specifier_no_prec
1355 | precision_qualifier type_specifier_no_prec
1362 type_specifier_no_prec:
1363 type_specifier_nonarray
1364 | type_specifier_nonarray '[' ']'
1367 $$->is_array = true;
1368 $$->array_size = NULL;
1370 | type_specifier_nonarray '[' constant_expression ']'
1373 $$->is_array = true;
1374 $$->array_size = $3;
1378 type_specifier_nonarray:
1379 basic_type_specifier_nonarray
1382 $$ = new(ctx) ast_type_specifier($1);
1383 $$->set_location(yylloc);
1388 $$ = new(ctx) ast_type_specifier($1);
1389 $$->set_location(yylloc);
1394 $$ = new(ctx) ast_type_specifier($1);
1395 $$->set_location(yylloc);
1399 basic_type_specifier_nonarray:
1400 VOID_TOK { $$ = "void"; }
1401 | FLOAT_TOK { $$ = "float"; }
1402 | INT_TOK { $$ = "int"; }
1403 | UINT_TOK { $$ = "uint"; }
1404 | BOOL_TOK { $$ = "bool"; }
1405 | VEC2 { $$ = "vec2"; }
1406 | VEC3 { $$ = "vec3"; }
1407 | VEC4 { $$ = "vec4"; }
1408 | BVEC2 { $$ = "bvec2"; }
1409 | BVEC3 { $$ = "bvec3"; }
1410 | BVEC4 { $$ = "bvec4"; }
1411 | IVEC2 { $$ = "ivec2"; }
1412 | IVEC3 { $$ = "ivec3"; }
1413 | IVEC4 { $$ = "ivec4"; }
1414 | UVEC2 { $$ = "uvec2"; }
1415 | UVEC3 { $$ = "uvec3"; }
1416 | UVEC4 { $$ = "uvec4"; }
1417 | MAT2X2 { $$ = "mat2"; }
1418 | MAT2X3 { $$ = "mat2x3"; }
1419 | MAT2X4 { $$ = "mat2x4"; }
1420 | MAT3X2 { $$ = "mat3x2"; }
1421 | MAT3X3 { $$ = "mat3"; }
1422 | MAT3X4 { $$ = "mat3x4"; }
1423 | MAT4X2 { $$ = "mat4x2"; }
1424 | MAT4X3 { $$ = "mat4x3"; }
1425 | MAT4X4 { $$ = "mat4"; }
1426 | SAMPLER1D { $$ = "sampler1D"; }
1427 | SAMPLER2D { $$ = "sampler2D"; }
1428 | SAMPLER2DRECT { $$ = "sampler2DRect"; }
1429 | SAMPLER3D { $$ = "sampler3D"; }
1430 | SAMPLERCUBE { $$ = "samplerCube"; }
1431 | SAMPLEREXTERNALOES { $$ = "samplerExternalOES"; }
1432 | SAMPLER1DSHADOW { $$ = "sampler1DShadow"; }
1433 | SAMPLER2DSHADOW { $$ = "sampler2DShadow"; }
1434 | SAMPLER2DRECTSHADOW { $$ = "sampler2DRectShadow"; }
1435 | SAMPLERCUBESHADOW { $$ = "samplerCubeShadow"; }
1436 | SAMPLER1DARRAY { $$ = "sampler1DArray"; }
1437 | SAMPLER2DARRAY { $$ = "sampler2DArray"; }
1438 | SAMPLER1DARRAYSHADOW { $$ = "sampler1DArrayShadow"; }
1439 | SAMPLER2DARRAYSHADOW { $$ = "sampler2DArrayShadow"; }
1440 | SAMPLERBUFFER { $$ = "samplerBuffer"; }
1441 | SAMPLERCUBEARRAY { $$ = "samplerCubeArray"; }
1442 | SAMPLERCUBEARRAYSHADOW { $$ = "samplerCubeArrayShadow"; }
1443 | ISAMPLER1D { $$ = "isampler1D"; }
1444 | ISAMPLER2D { $$ = "isampler2D"; }
1445 | ISAMPLER2DRECT { $$ = "isampler2DRect"; }
1446 | ISAMPLER3D { $$ = "isampler3D"; }
1447 | ISAMPLERCUBE { $$ = "isamplerCube"; }
1448 | ISAMPLER1DARRAY { $$ = "isampler1DArray"; }
1449 | ISAMPLER2DARRAY { $$ = "isampler2DArray"; }
1450 | ISAMPLERBUFFER { $$ = "isamplerBuffer"; }
1451 | ISAMPLERCUBEARRAY { $$ = "isamplerCubeArray"; }
1452 | USAMPLER1D { $$ = "usampler1D"; }
1453 | USAMPLER2D { $$ = "usampler2D"; }
1454 | USAMPLER2DRECT { $$ = "usampler2DRect"; }
1455 | USAMPLER3D { $$ = "usampler3D"; }
1456 | USAMPLERCUBE { $$ = "usamplerCube"; }
1457 | USAMPLER1DARRAY { $$ = "usampler1DArray"; }
1458 | USAMPLER2DARRAY { $$ = "usampler2DArray"; }
1459 | USAMPLERBUFFER { $$ = "usamplerBuffer"; }
1460 | USAMPLERCUBEARRAY { $$ = "usamplerCubeArray"; }
1463 precision_qualifier:
1465 state->check_precision_qualifiers_allowed(&@1);
1467 $$ = ast_precision_high;
1470 state->check_precision_qualifiers_allowed(&@1);
1472 $$ = ast_precision_medium;
1475 state->check_precision_qualifiers_allowed(&@1);
1477 $$ = ast_precision_low;
1482 STRUCT any_identifier '{' struct_declaration_list '}'
1485 $$ = new(ctx) ast_struct_specifier($2, $4);
1486 $$->set_location(yylloc);
1487 state->symbols->add_type($2, glsl_type::void_type);
1489 | STRUCT '{' struct_declaration_list '}'
1492 $$ = new(ctx) ast_struct_specifier(NULL, $3);
1493 $$->set_location(yylloc);
1497 struct_declaration_list:
1501 $1->link.self_link();
1503 | struct_declaration_list struct_declaration
1506 $$->link.insert_before(& $2->link);
1511 type_specifier struct_declarator_list ';'
1514 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1515 type->set_location(yylloc);
1517 type->specifier = $1;
1518 $$ = new(ctx) ast_declarator_list(type);
1519 $$->set_location(yylloc);
1521 $$->declarations.push_degenerate_list_at_head(& $2->link);
1525 struct_declarator_list:
1529 $1->link.self_link();
1531 | struct_declarator_list ',' struct_declarator
1534 $$->link.insert_before(& $3->link);
1542 $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
1543 $$->set_location(yylloc);
1544 state->symbols->add_variable(new(state) ir_variable(NULL, $1, ir_var_auto));
1546 | any_identifier '[' constant_expression ']'
1549 $$ = new(ctx) ast_declaration($1, true, $3, NULL);
1550 $$->set_location(yylloc);
1555 assignment_expression
1558 declaration_statement:
1562 // Grammar Note: labeled statements for SWITCH only; 'goto' is not
1565 compound_statement { $$ = (ast_node *) $1; }
1570 declaration_statement
1571 | expression_statement
1572 | selection_statement
1574 | iteration_statement
1582 $$ = new(ctx) ast_compound_statement(true, NULL);
1583 $$->set_location(yylloc);
1587 state->symbols->push_scope();
1592 $$ = new(ctx) ast_compound_statement(true, $3);
1593 $$->set_location(yylloc);
1594 state->symbols->pop_scope();
1598 statement_no_new_scope:
1599 compound_statement_no_new_scope { $$ = (ast_node *) $1; }
1603 compound_statement_no_new_scope:
1607 $$ = new(ctx) ast_compound_statement(false, NULL);
1608 $$->set_location(yylloc);
1610 | '{' statement_list '}'
1613 $$ = new(ctx) ast_compound_statement(false, $2);
1614 $$->set_location(yylloc);
1622 _mesa_glsl_error(& @1, state, "<nil> statement\n");
1627 $$->link.self_link();
1629 | statement_list statement
1632 _mesa_glsl_error(& @2, state, "<nil> statement\n");
1636 $$->link.insert_before(& $2->link);
1640 expression_statement:
1644 $$ = new(ctx) ast_expression_statement(NULL);
1645 $$->set_location(yylloc);
1650 $$ = new(ctx) ast_expression_statement($1);
1651 $$->set_location(yylloc);
1655 selection_statement:
1656 IF '(' expression ')' selection_rest_statement
1658 $$ = new(state) ast_selection_statement($3, $5.then_statement,
1660 $$->set_location(yylloc);
1664 selection_rest_statement:
1665 statement ELSE statement
1667 $$.then_statement = $1;
1668 $$.else_statement = $3;
1672 $$.then_statement = $1;
1673 $$.else_statement = NULL;
1680 $$ = (ast_node *) $1;
1682 | fully_specified_type any_identifier '=' initializer
1685 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
1686 ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
1687 decl->set_location(yylloc);
1688 declarator->set_location(yylloc);
1690 declarator->declarations.push_tail(&decl->link);
1696 * siwtch_statement grammar is based on the syntax described in the body
1697 * of the GLSL spec, not in it's appendix!!!
1700 SWITCH '(' expression ')' switch_body
1702 $$ = new(state) ast_switch_statement($3, $5);
1703 $$->set_location(yylloc);
1710 $$ = new(state) ast_switch_body(NULL);
1711 $$->set_location(yylloc);
1713 | '{' case_statement_list '}'
1715 $$ = new(state) ast_switch_body($2);
1716 $$->set_location(yylloc);
1723 $$ = new(state) ast_case_label($2);
1724 $$->set_location(yylloc);
1728 $$ = new(state) ast_case_label(NULL);
1729 $$->set_location(yylloc);
1736 ast_case_label_list *labels = new(state) ast_case_label_list();
1738 labels->labels.push_tail(& $1->link);
1740 $$->set_location(yylloc);
1742 | case_label_list case_label
1745 $$->labels.push_tail(& $2->link);
1750 case_label_list statement
1752 ast_case_statement *stmts = new(state) ast_case_statement($1);
1753 stmts->set_location(yylloc);
1755 stmts->stmts.push_tail(& $2->link);
1758 | case_statement statement
1761 $$->stmts.push_tail(& $2->link);
1765 case_statement_list:
1768 ast_case_statement_list *cases= new(state) ast_case_statement_list();
1769 cases->set_location(yylloc);
1771 cases->cases.push_tail(& $1->link);
1774 | case_statement_list case_statement
1777 $$->cases.push_tail(& $2->link);
1781 iteration_statement:
1782 WHILE '(' condition ')' statement_no_new_scope
1785 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
1786 NULL, $3, NULL, $5);
1787 $$->set_location(yylloc);
1789 | DO statement WHILE '(' expression ')' ';'
1792 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
1793 NULL, $5, NULL, $2);
1794 $$->set_location(yylloc);
1796 | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
1799 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
1800 $3, $4.cond, $4.rest, $6);
1801 $$->set_location(yylloc);
1806 expression_statement
1807 | declaration_statement
1824 | conditionopt ';' expression
1831 // Grammar Note: No 'goto'. Gotos are not supported.
1836 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
1837 $$->set_location(yylloc);
1842 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
1843 $$->set_location(yylloc);
1848 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
1849 $$->set_location(yylloc);
1851 | RETURN expression ';'
1854 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
1855 $$->set_location(yylloc);
1857 | DISCARD ';' // Fragment shader only.
1860 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
1861 $$->set_location(yylloc);
1865 external_declaration:
1866 function_definition { $$ = $1; }
1867 | declaration { $$ = $1; }
1868 | pragma_statement { $$ = NULL; }
1869 | layout_defaults { $$ = NULL; }
1872 function_definition:
1873 function_prototype compound_statement_no_new_scope
1876 $$ = new(ctx) ast_function_definition();
1877 $$->set_location(yylloc);
1881 state->symbols->pop_scope();
1885 /* layout_qualifieropt is packed into this rule */
1887 UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1890 $$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,
1893 if (!state->ARB_uniform_buffer_object_enable) {
1894 _mesa_glsl_error(& @1, state,
1895 "#version 140 / GL_ARB_uniform_buffer_object "
1896 "required for defining uniform blocks\n");
1897 } else if (state->ARB_uniform_buffer_object_warn) {
1898 _mesa_glsl_warning(& @1, state,
1899 "#version 140 / GL_ARB_uniform_buffer_object "
1900 "required for defining uniform blocks\n");
1903 | layout_qualifier UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
1907 ast_type_qualifier qual = *state->default_uniform_qualifier;
1908 if (!qual.merge_qualifier(& @1, state, $1)) {
1911 $$ = new(ctx) ast_uniform_block(qual, $3, $5);
1913 if (!state->ARB_uniform_buffer_object_enable) {
1914 _mesa_glsl_error(& @1, state,
1915 "#version 140 / GL_ARB_uniform_buffer_object "
1916 "required for defining uniform blocks\n");
1917 } else if (state->ARB_uniform_buffer_object_warn) {
1918 _mesa_glsl_warning(& @1, state,
1919 "#version 140 / GL_ARB_uniform_buffer_object "
1920 "required for defining uniform blocks\n");
1929 $1->link.self_link();
1931 | member_declaration member_list
1934 $2->link.insert_before(& $$->link);
1938 /* Specifying "uniform" inside of a uniform block is redundant. */
1945 layout_qualifier uniformopt type_specifier struct_declarator_list ';'
1948 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1949 type->set_location(yylloc);
1951 type->qualifier = $1;
1952 type->qualifier.flags.q.uniform = true;
1953 type->specifier = $3;
1954 $$ = new(ctx) ast_declarator_list(type);
1955 $$->set_location(yylloc);
1956 $$->ubo_qualifiers_valid = true;
1958 $$->declarations.push_degenerate_list_at_head(& $4->link);
1960 | uniformopt type_specifier struct_declarator_list ';'
1963 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1964 type->set_location(yylloc);
1966 type->qualifier.flags.q.uniform = true;
1967 type->specifier = $2;
1968 $$ = new(ctx) ast_declarator_list(type);
1969 $$->set_location(yylloc);
1970 $$->ubo_qualifiers_valid = true;
1972 $$->declarations.push_degenerate_list_at_head(& $3->link);
1977 layout_qualifier UNIFORM ';'
1979 if (!state->default_uniform_qualifier->merge_qualifier(& @1, state,