Merge pull request #2028 from ShchchowAMD/constant_expressions_array_mod
[platform/upstream/glslang.git] / glslang / MachineIndependent / glslang.y
1 //
2 // Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
3 // Copyright (C) 2012-2013 LunarG, Inc.
4 // Copyright (C) 2017 ARM Limited.
5 // Copyright (C) 2015-2018 Google, Inc.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions
11 // are met:
12 //
13 //    Redistributions of source code must retain the above copyright
14 //    notice, this list of conditions and the following disclaimer.
15 //
16 //    Redistributions in binary form must reproduce the above
17 //    copyright notice, this list of conditions and the following
18 //    disclaimer in the documentation and/or other materials provided
19 //    with the distribution.
20 //
21 //    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
22 //    contributors may be used to endorse or promote products derived
23 //    from this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38
39 //
40 // Do not edit the .y file, only edit the .m4 file.
41 // The .y bison file is not a source file, it is a derivative of the .m4 file.
42 // The m4 file needs to be processed by m4 to generate the .y bison file.
43 //
44 // Code sandwiched between a pair:
45 //
46 //    GLSLANG_WEB_EXCLUDE_ON
47 //      ...
48 //      ...
49 //      ...
50 //    GLSLANG_WEB_EXCLUDE_OFF
51 //
52 // Will be excluded from the grammar when m4 is executed as:
53 //
54 //    m4 -P -DGLSLANG_WEB
55 //
56 // It will be included when m4 is executed as:
57 //
58 //    m4 -P
59 //
60
61
62
63
64 /**
65  * This is bison grammar and productions for parsing all versions of the
66  * GLSL shading languages.
67  */
68 %{
69
70 /* Based on:
71 ANSI C Yacc grammar
72
73 In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a
74 matching Lex specification) for the April 30, 1985 draft version of the
75 ANSI C standard.  Tom Stockfisch reposted it to net.sources in 1987; that
76 original, as mentioned in the answer to question 17.25 of the comp.lang.c
77 FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z.
78
79 I intend to keep this version as close to the current C Standard grammar as
80 possible; please let me know if you discover discrepancies.
81
82 Jutta Degener, 1995
83 */
84
85 #include "SymbolTable.h"
86 #include "ParseHelper.h"
87 #include "../Public/ShaderLang.h"
88 #include "attribute.h"
89
90 using namespace glslang;
91
92 %}
93
94 %define parse.error verbose
95
96 %union {
97     struct {
98         glslang::TSourceLoc loc;
99         union {
100             glslang::TString *string;
101             int i;
102             unsigned int u;
103             long long i64;
104             unsigned long long u64;
105             bool b;
106             double d;
107         };
108         glslang::TSymbol* symbol;
109     } lex;
110     struct {
111         glslang::TSourceLoc loc;
112         glslang::TOperator op;
113         union {
114             TIntermNode* intermNode;
115             glslang::TIntermNodePair nodePair;
116             glslang::TIntermTyped* intermTypedNode;
117             glslang::TAttributes* attributes;
118         };
119         union {
120             glslang::TPublicType type;
121             glslang::TFunction* function;
122             glslang::TParameter param;
123             glslang::TTypeLoc typeLine;
124             glslang::TTypeList* typeList;
125             glslang::TArraySizes* arraySizes;
126             glslang::TIdentifierList* identifierList;
127         };
128         glslang::TArraySizes* typeParameters;
129     } interm;
130 }
131
132 %{
133
134 /* windows only pragma */
135 #ifdef _MSC_VER
136     #pragma warning(disable : 4065)
137     #pragma warning(disable : 4127)
138     #pragma warning(disable : 4244)
139 #endif
140
141 #define parseContext (*pParseContext)
142 #define yyerror(context, msg) context->parserError(msg)
143
144 extern int yylex(YYSTYPE*, TParseContext&);
145
146 %}
147
148 %parse-param {glslang::TParseContext* pParseContext}
149 %lex-param {parseContext}
150 %pure-parser  // enable thread safety
151 %expect 1     // One shift reduce conflict because of if | else
152
153 %token <lex> CONST BOOL INT UINT FLOAT
154 %token <lex> BVEC2 BVEC3 BVEC4
155 %token <lex> IVEC2 IVEC3 IVEC4
156 %token <lex> UVEC2 UVEC3 UVEC4
157 %token <lex> VEC2 VEC3 VEC4
158 %token <lex> MAT2 MAT3 MAT4
159 %token <lex> MAT2X2 MAT2X3 MAT2X4
160 %token <lex> MAT3X2 MAT3X3 MAT3X4
161 %token <lex> MAT4X2 MAT4X3 MAT4X4
162
163 // combined image/sampler
164 %token <lex> SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER2DSHADOW
165 %token <lex> SAMPLERCUBESHADOW SAMPLER2DARRAY
166 %token <lex> SAMPLER2DARRAYSHADOW ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
167 %token <lex> ISAMPLER2DARRAY USAMPLER2D USAMPLER3D
168 %token <lex> USAMPLERCUBE USAMPLER2DARRAY
169
170 // separate image/sampler
171 %token <lex> SAMPLER SAMPLERSHADOW
172 %token <lex>  TEXTURE2D  TEXTURE3D  TEXTURECUBE  TEXTURE2DARRAY
173 %token <lex> ITEXTURE2D ITEXTURE3D ITEXTURECUBE ITEXTURE2DARRAY
174 %token <lex> UTEXTURE2D UTEXTURE3D UTEXTURECUBE UTEXTURE2DARRAY
175
176
177
178 %token <lex> ATTRIBUTE VARYING
179 %token <lex> FLOAT16_T FLOAT32_T DOUBLE FLOAT64_T
180 %token <lex> INT64_T UINT64_T INT32_T UINT32_T INT16_T UINT16_T INT8_T UINT8_T
181 %token <lex> I64VEC2 I64VEC3 I64VEC4
182 %token <lex> U64VEC2 U64VEC3 U64VEC4
183 %token <lex> I32VEC2 I32VEC3 I32VEC4
184 %token <lex> U32VEC2 U32VEC3 U32VEC4
185 %token <lex> I16VEC2 I16VEC3 I16VEC4
186 %token <lex> U16VEC2 U16VEC3 U16VEC4
187 %token <lex> I8VEC2  I8VEC3  I8VEC4
188 %token <lex> U8VEC2  U8VEC3  U8VEC4
189 %token <lex> DVEC2 DVEC3 DVEC4 DMAT2 DMAT3 DMAT4
190 %token <lex> F16VEC2 F16VEC3 F16VEC4 F16MAT2 F16MAT3 F16MAT4
191 %token <lex> F32VEC2 F32VEC3 F32VEC4 F32MAT2 F32MAT3 F32MAT4
192 %token <lex> F64VEC2 F64VEC3 F64VEC4 F64MAT2 F64MAT3 F64MAT4
193 %token <lex> DMAT2X2 DMAT2X3 DMAT2X4
194 %token <lex> DMAT3X2 DMAT3X3 DMAT3X4
195 %token <lex> DMAT4X2 DMAT4X3 DMAT4X4
196 %token <lex> F16MAT2X2 F16MAT2X3 F16MAT2X4
197 %token <lex> F16MAT3X2 F16MAT3X3 F16MAT3X4
198 %token <lex> F16MAT4X2 F16MAT4X3 F16MAT4X4
199 %token <lex> F32MAT2X2 F32MAT2X3 F32MAT2X4
200 %token <lex> F32MAT3X2 F32MAT3X3 F32MAT3X4
201 %token <lex> F32MAT4X2 F32MAT4X3 F32MAT4X4
202 %token <lex> F64MAT2X2 F64MAT2X3 F64MAT2X4
203 %token <lex> F64MAT3X2 F64MAT3X3 F64MAT3X4
204 %token <lex> F64MAT4X2 F64MAT4X3 F64MAT4X4
205 %token <lex> ATOMIC_UINT
206 %token <lex> ACCSTRUCTNV
207 %token <lex> FCOOPMATNV ICOOPMATNV UCOOPMATNV
208
209 // combined image/sampler
210 %token <lex> SAMPLERCUBEARRAY SAMPLERCUBEARRAYSHADOW
211 %token <lex> ISAMPLERCUBEARRAY USAMPLERCUBEARRAY
212 %token <lex> SAMPLER1D SAMPLER1DARRAY SAMPLER1DARRAYSHADOW ISAMPLER1D SAMPLER1DSHADOW
213 %token <lex> SAMPLER2DRECT SAMPLER2DRECTSHADOW ISAMPLER2DRECT USAMPLER2DRECT
214 %token <lex> SAMPLERBUFFER ISAMPLERBUFFER USAMPLERBUFFER
215 %token <lex> SAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS
216 %token <lex> SAMPLER2DMSARRAY ISAMPLER2DMSARRAY USAMPLER2DMSARRAY
217 %token <lex> SAMPLEREXTERNALOES
218 %token <lex> SAMPLEREXTERNAL2DY2YEXT
219 %token <lex> ISAMPLER1DARRAY USAMPLER1D USAMPLER1DARRAY 
220 %token <lex> F16SAMPLER1D F16SAMPLER2D F16SAMPLER3D F16SAMPLER2DRECT F16SAMPLERCUBE
221 %token <lex> F16SAMPLER1DARRAY F16SAMPLER2DARRAY F16SAMPLERCUBEARRAY
222 %token <lex> F16SAMPLERBUFFER F16SAMPLER2DMS F16SAMPLER2DMSARRAY
223 %token <lex> F16SAMPLER1DSHADOW F16SAMPLER2DSHADOW F16SAMPLER1DARRAYSHADOW F16SAMPLER2DARRAYSHADOW
224 %token <lex> F16SAMPLER2DRECTSHADOW F16SAMPLERCUBESHADOW F16SAMPLERCUBEARRAYSHADOW
225
226 // images
227 %token <lex> IMAGE1D IIMAGE1D UIMAGE1D IMAGE2D IIMAGE2D
228 %token <lex> UIMAGE2D IMAGE3D IIMAGE3D UIMAGE3D
229 %token <lex> IMAGE2DRECT IIMAGE2DRECT UIMAGE2DRECT
230 %token <lex> IMAGECUBE IIMAGECUBE UIMAGECUBE
231 %token <lex> IMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER
232 %token <lex> IMAGE1DARRAY IIMAGE1DARRAY UIMAGE1DARRAY
233 %token <lex> IMAGE2DARRAY IIMAGE2DARRAY UIMAGE2DARRAY
234 %token <lex> IMAGECUBEARRAY IIMAGECUBEARRAY UIMAGECUBEARRAY
235 %token <lex> IMAGE2DMS IIMAGE2DMS UIMAGE2DMS
236 %token <lex> IMAGE2DMSARRAY IIMAGE2DMSARRAY UIMAGE2DMSARRAY
237
238 %token <lex> F16IMAGE1D F16IMAGE2D F16IMAGE3D F16IMAGE2DRECT
239 %token <lex> F16IMAGECUBE F16IMAGE1DARRAY F16IMAGE2DARRAY F16IMAGECUBEARRAY
240 %token <lex> F16IMAGEBUFFER F16IMAGE2DMS F16IMAGE2DMSARRAY
241
242 // texture without sampler
243 %token <lex> TEXTURECUBEARRAY ITEXTURECUBEARRAY UTEXTURECUBEARRAY
244 %token <lex> TEXTURE1D ITEXTURE1D UTEXTURE1D
245 %token <lex> TEXTURE1DARRAY ITEXTURE1DARRAY UTEXTURE1DARRAY
246 %token <lex> TEXTURE2DRECT ITEXTURE2DRECT UTEXTURE2DRECT
247 %token <lex> TEXTUREBUFFER ITEXTUREBUFFER UTEXTUREBUFFER
248 %token <lex> TEXTURE2DMS ITEXTURE2DMS UTEXTURE2DMS
249 %token <lex> TEXTURE2DMSARRAY ITEXTURE2DMSARRAY UTEXTURE2DMSARRAY
250
251 %token <lex> F16TEXTURE1D F16TEXTURE2D F16TEXTURE3D F16TEXTURE2DRECT F16TEXTURECUBE
252 %token <lex> F16TEXTURE1DARRAY F16TEXTURE2DARRAY F16TEXTURECUBEARRAY
253 %token <lex> F16TEXTUREBUFFER F16TEXTURE2DMS F16TEXTURE2DMSARRAY
254
255 // input attachments
256 %token <lex> SUBPASSINPUT SUBPASSINPUTMS ISUBPASSINPUT ISUBPASSINPUTMS USUBPASSINPUT USUBPASSINPUTMS
257 %token <lex> F16SUBPASSINPUT F16SUBPASSINPUTMS
258
259
260
261 %token <lex> LEFT_OP RIGHT_OP
262 %token <lex> INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
263 %token <lex> AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
264 %token <lex> MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
265 %token <lex> SUB_ASSIGN
266
267 %token <lex> LEFT_PAREN RIGHT_PAREN LEFT_BRACKET RIGHT_BRACKET LEFT_BRACE RIGHT_BRACE DOT
268 %token <lex> COMMA COLON EQUAL SEMICOLON BANG DASH TILDE PLUS STAR SLASH PERCENT
269 %token <lex> LEFT_ANGLE RIGHT_ANGLE VERTICAL_BAR CARET AMPERSAND QUESTION
270
271 %token <lex> INVARIANT
272 %token <lex> HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION
273 %token <lex> PACKED RESOURCE SUPERP
274
275 %token <lex> FLOATCONSTANT INTCONSTANT UINTCONSTANT BOOLCONSTANT
276 %token <lex> IDENTIFIER TYPE_NAME
277 %token <lex> CENTROID IN OUT INOUT
278 %token <lex> STRUCT VOID WHILE
279 %token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
280 %token <lex> UNIFORM SHARED BUFFER
281 %token <lex> FLAT SMOOTH LAYOUT
282
283
284 %token <lex> DOUBLECONSTANT INT16CONSTANT UINT16CONSTANT FLOAT16CONSTANT INT32CONSTANT UINT32CONSTANT
285 %token <lex> INT64CONSTANT UINT64CONSTANT
286 %token <lex> SUBROUTINE DEMOTE
287 %token <lex> PAYLOADNV PAYLOADINNV HITATTRNV CALLDATANV CALLDATAINNV
288 %token <lex> PATCH SAMPLE NONUNIFORM
289 %token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY DEVICECOHERENT QUEUEFAMILYCOHERENT WORKGROUPCOHERENT
290 %token <lex> SUBGROUPCOHERENT NONPRIVATE
291 %token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV
292 %token <lex> PRECISE
293
294
295 %type <interm> assignment_operator unary_operator
296 %type <interm.intermTypedNode> variable_identifier primary_expression postfix_expression
297 %type <interm.intermTypedNode> expression integer_expression assignment_expression
298 %type <interm.intermTypedNode> unary_expression multiplicative_expression additive_expression
299 %type <interm.intermTypedNode> relational_expression equality_expression
300 %type <interm.intermTypedNode> conditional_expression constant_expression
301 %type <interm.intermTypedNode> logical_or_expression logical_xor_expression logical_and_expression
302 %type <interm.intermTypedNode> shift_expression and_expression exclusive_or_expression inclusive_or_expression
303 %type <interm.intermTypedNode> function_call initializer condition conditionopt
304
305 %type <interm.intermNode> translation_unit function_definition
306 %type <interm.intermNode> statement simple_statement
307 %type <interm.intermNode> statement_list switch_statement_list compound_statement
308 %type <interm.intermNode> declaration_statement selection_statement selection_statement_nonattributed expression_statement
309 %type <interm.intermNode> switch_statement switch_statement_nonattributed case_label
310 %type <interm.intermNode> declaration external_declaration
311 %type <interm.intermNode> for_init_statement compound_statement_no_new_scope
312 %type <interm.nodePair> selection_rest_statement for_rest_statement
313 %type <interm.intermNode> iteration_statement iteration_statement_nonattributed jump_statement statement_no_new_scope statement_scoped
314 %type <interm> single_declaration init_declarator_list
315
316 %type <interm> parameter_declaration parameter_declarator parameter_type_specifier
317
318 %type <interm> array_specifier
319 %type <interm.type> invariant_qualifier interpolation_qualifier storage_qualifier precision_qualifier
320 %type <interm.type> layout_qualifier layout_qualifier_id_list layout_qualifier_id
321
322 %type <interm.typeParameters> type_parameter_specifier
323 %type <interm.typeParameters> type_parameter_specifier_opt
324 %type <interm.typeParameters> type_parameter_specifier_list
325
326 %type <interm.type> type_qualifier fully_specified_type type_specifier
327 %type <interm.type> single_type_qualifier
328 %type <interm.type> type_specifier_nonarray
329 %type <interm.type> struct_specifier
330 %type <interm.typeLine> struct_declarator
331 %type <interm.typeList> struct_declarator_list struct_declaration struct_declaration_list
332 %type <interm> block_structure
333 %type <interm.function> function_header function_declarator
334 %type <interm.function> function_header_with_parameters
335 %type <interm> function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype
336 %type <interm> function_call_or_method function_identifier function_call_header
337
338 %type <interm.identifierList> identifier_list
339
340
341 %type <interm.type> precise_qualifier non_uniform_qualifier
342 %type <interm.typeList> type_name_list
343 %type <interm.attributes> attribute attribute_list single_attribute
344 %type <interm.intermNode> demote_statement
345 %type <interm.intermTypedNode> initializer_list
346
347
348 %start translation_unit
349 %%
350
351 variable_identifier
352     : IDENTIFIER {
353         $$ = parseContext.handleVariable($1.loc, $1.symbol, $1.string);
354     }
355     ;
356
357 primary_expression
358     : variable_identifier {
359         $$ = $1;
360     }
361     | LEFT_PAREN expression RIGHT_PAREN {
362         $$ = $2;
363         if ($$->getAsConstantUnion())
364             $$->getAsConstantUnion()->setExpression();
365     }
366     | FLOATCONSTANT {
367         $$ = parseContext.intermediate.addConstantUnion($1.d, EbtFloat, $1.loc, true);
368     }
369     | INTCONSTANT {
370         $$ = parseContext.intermediate.addConstantUnion($1.i, $1.loc, true);
371     }
372     | UINTCONSTANT {
373         parseContext.fullIntegerCheck($1.loc, "unsigned literal");
374         $$ = parseContext.intermediate.addConstantUnion($1.u, $1.loc, true);
375     }
376     | BOOLCONSTANT {
377         $$ = parseContext.intermediate.addConstantUnion($1.b, $1.loc, true);
378     }
379
380     | INT32CONSTANT {
381         parseContext.explicitInt32Check($1.loc, "32-bit signed literal");
382         $$ = parseContext.intermediate.addConstantUnion($1.i, $1.loc, true);
383     }
384     | UINT32CONSTANT {
385         parseContext.explicitInt32Check($1.loc, "32-bit signed literal");
386         $$ = parseContext.intermediate.addConstantUnion($1.u, $1.loc, true);
387     }
388     | INT64CONSTANT {
389         parseContext.int64Check($1.loc, "64-bit integer literal");
390         $$ = parseContext.intermediate.addConstantUnion($1.i64, $1.loc, true);
391     }
392     | UINT64CONSTANT {
393         parseContext.int64Check($1.loc, "64-bit unsigned integer literal");
394         $$ = parseContext.intermediate.addConstantUnion($1.u64, $1.loc, true);
395     }
396     | INT16CONSTANT {
397         parseContext.explicitInt16Check($1.loc, "16-bit integer literal");
398         $$ = parseContext.intermediate.addConstantUnion((short)$1.i, $1.loc, true);
399     }
400     | UINT16CONSTANT {
401         parseContext.explicitInt16Check($1.loc, "16-bit unsigned integer literal");
402         $$ = parseContext.intermediate.addConstantUnion((unsigned short)$1.u, $1.loc, true);
403     }
404     | DOUBLECONSTANT {
405         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double literal");
406         if (! parseContext.symbolTable.atBuiltInLevel())
407             parseContext.doubleCheck($1.loc, "double literal");
408         $$ = parseContext.intermediate.addConstantUnion($1.d, EbtDouble, $1.loc, true);
409     }
410     | FLOAT16CONSTANT {
411         parseContext.float16Check($1.loc, "half float literal");
412         $$ = parseContext.intermediate.addConstantUnion($1.d, EbtFloat16, $1.loc, true);
413     }
414
415     ;
416
417 postfix_expression
418     : primary_expression {
419         $$ = $1;
420     }
421     | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET {
422         $$ = parseContext.handleBracketDereference($2.loc, $1, $3);
423     }
424     | function_call {
425         $$ = $1;
426     }
427     | postfix_expression DOT IDENTIFIER {
428         $$ = parseContext.handleDotDereference($3.loc, $1, *$3.string);
429     }
430     | postfix_expression INC_OP {
431         parseContext.variableCheck($1);
432         parseContext.lValueErrorCheck($2.loc, "++", $1);
433         $$ = parseContext.handleUnaryMath($2.loc, "++", EOpPostIncrement, $1);
434     }
435     | postfix_expression DEC_OP {
436         parseContext.variableCheck($1);
437         parseContext.lValueErrorCheck($2.loc, "--", $1);
438         $$ = parseContext.handleUnaryMath($2.loc, "--", EOpPostDecrement, $1);
439     }
440     ;
441
442 integer_expression
443     : expression {
444         parseContext.integerCheck($1, "[]");
445         $$ = $1;
446     }
447     ;
448
449 function_call
450     : function_call_or_method {
451         $$ = parseContext.handleFunctionCall($1.loc, $1.function, $1.intermNode);
452         delete $1.function;
453     }
454     ;
455
456 function_call_or_method
457     : function_call_generic {
458         $$ = $1;
459     }
460     ;
461
462 function_call_generic
463     : function_call_header_with_parameters RIGHT_PAREN {
464         $$ = $1;
465         $$.loc = $2.loc;
466     }
467     | function_call_header_no_parameters RIGHT_PAREN {
468         $$ = $1;
469         $$.loc = $2.loc;
470     }
471     ;
472
473 function_call_header_no_parameters
474     : function_call_header VOID {
475         $$ = $1;
476     }
477     | function_call_header {
478         $$ = $1;
479     }
480     ;
481
482 function_call_header_with_parameters
483     : function_call_header assignment_expression {
484         TParameter param = { 0, new TType };
485         param.type->shallowCopy($2->getType());
486         $1.function->addParameter(param);
487         $$.function = $1.function;
488         $$.intermNode = $2;
489     }
490     | function_call_header_with_parameters COMMA assignment_expression {
491         TParameter param = { 0, new TType };
492         param.type->shallowCopy($3->getType());
493         $1.function->addParameter(param);
494         $$.function = $1.function;
495         $$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.loc);
496     }
497     ;
498
499 function_call_header
500     : function_identifier LEFT_PAREN {
501         $$ = $1;
502     }
503     ;
504
505 // Grammar Note:  Constructors look like functions, but are recognized as types.
506
507 function_identifier
508     : type_specifier {
509         // Constructor
510         $$.intermNode = 0;
511         $$.function = parseContext.handleConstructorCall($1.loc, $1);
512     }
513     | postfix_expression {
514         //
515         // Should be a method or subroutine call, but we haven't recognized the arguments yet.
516         //
517         $$.function = 0;
518         $$.intermNode = 0;
519
520         TIntermMethod* method = $1->getAsMethodNode();
521         if (method) {
522             $$.function = new TFunction(&method->getMethodName(), TType(EbtInt), EOpArrayLength);
523             $$.intermNode = method->getObject();
524         } else {
525             TIntermSymbol* symbol = $1->getAsSymbolNode();
526             if (symbol) {
527                 parseContext.reservedErrorCheck(symbol->getLoc(), symbol->getName());
528                 TFunction *function = new TFunction(&symbol->getName(), TType(EbtVoid));
529                 $$.function = function;
530             } else
531                 parseContext.error($1->getLoc(), "function call, method, or subroutine call expected", "", "");
532         }
533
534         if ($$.function == 0) {
535             // error recover
536             TString* empty = NewPoolTString("");
537             $$.function = new TFunction(empty, TType(EbtVoid), EOpNull);
538         }
539     }
540
541     | non_uniform_qualifier {
542         // Constructor
543         $$.intermNode = 0;
544         $$.function = parseContext.handleConstructorCall($1.loc, $1);
545     }
546
547     ;
548
549 unary_expression
550     : postfix_expression {
551         parseContext.variableCheck($1);
552         $$ = $1;
553         if (TIntermMethod* method = $1->getAsMethodNode())
554             parseContext.error($1->getLoc(), "incomplete method syntax", method->getMethodName().c_str(), "");
555     }
556     | INC_OP unary_expression {
557         parseContext.lValueErrorCheck($1.loc, "++", $2);
558         $$ = parseContext.handleUnaryMath($1.loc, "++", EOpPreIncrement, $2);
559     }
560     | DEC_OP unary_expression {
561         parseContext.lValueErrorCheck($1.loc, "--", $2);
562         $$ = parseContext.handleUnaryMath($1.loc, "--", EOpPreDecrement, $2);
563     }
564     | unary_operator unary_expression {
565         if ($1.op != EOpNull) {
566             char errorOp[2] = {0, 0};
567             switch($1.op) {
568             case EOpNegative:   errorOp[0] = '-'; break;
569             case EOpLogicalNot: errorOp[0] = '!'; break;
570             case EOpBitwiseNot: errorOp[0] = '~'; break;
571             default: break; // some compilers want this
572             }
573             $$ = parseContext.handleUnaryMath($1.loc, errorOp, $1.op, $2);
574         } else {
575             $$ = $2;
576             if ($$->getAsConstantUnion())
577                 $$->getAsConstantUnion()->setExpression();
578         }
579     }
580     ;
581 // Grammar Note:  No traditional style type casts.
582
583 unary_operator
584     : PLUS  { $$.loc = $1.loc; $$.op = EOpNull; }
585     | DASH  { $$.loc = $1.loc; $$.op = EOpNegative; }
586     | BANG  { $$.loc = $1.loc; $$.op = EOpLogicalNot; }
587     | TILDE { $$.loc = $1.loc; $$.op = EOpBitwiseNot;
588               parseContext.fullIntegerCheck($1.loc, "bitwise not"); }
589     ;
590 // Grammar Note:  No '*' or '&' unary ops.  Pointers are not supported.
591
592 multiplicative_expression
593     : unary_expression { $$ = $1; }
594     | multiplicative_expression STAR unary_expression {
595         $$ = parseContext.handleBinaryMath($2.loc, "*", EOpMul, $1, $3);
596         if ($$ == 0)
597             $$ = $1;
598     }
599     | multiplicative_expression SLASH unary_expression {
600         $$ = parseContext.handleBinaryMath($2.loc, "/", EOpDiv, $1, $3);
601         if ($$ == 0)
602             $$ = $1;
603     }
604     | multiplicative_expression PERCENT unary_expression {
605         parseContext.fullIntegerCheck($2.loc, "%");
606         $$ = parseContext.handleBinaryMath($2.loc, "%", EOpMod, $1, $3);
607         if ($$ == 0)
608             $$ = $1;
609     }
610     ;
611
612 additive_expression
613     : multiplicative_expression { $$ = $1; }
614     | additive_expression PLUS multiplicative_expression {
615         $$ = parseContext.handleBinaryMath($2.loc, "+", EOpAdd, $1, $3);
616         if ($$ == 0)
617             $$ = $1;
618     }
619     | additive_expression DASH multiplicative_expression {
620         $$ = parseContext.handleBinaryMath($2.loc, "-", EOpSub, $1, $3);
621         if ($$ == 0)
622             $$ = $1;
623     }
624     ;
625
626 shift_expression
627     : additive_expression { $$ = $1; }
628     | shift_expression LEFT_OP additive_expression {
629         parseContext.fullIntegerCheck($2.loc, "bit shift left");
630         $$ = parseContext.handleBinaryMath($2.loc, "<<", EOpLeftShift, $1, $3);
631         if ($$ == 0)
632             $$ = $1;
633     }
634     | shift_expression RIGHT_OP additive_expression {
635         parseContext.fullIntegerCheck($2.loc, "bit shift right");
636         $$ = parseContext.handleBinaryMath($2.loc, ">>", EOpRightShift, $1, $3);
637         if ($$ == 0)
638             $$ = $1;
639     }
640     ;
641
642 relational_expression
643     : shift_expression { $$ = $1; }
644     | relational_expression LEFT_ANGLE shift_expression {
645         $$ = parseContext.handleBinaryMath($2.loc, "<", EOpLessThan, $1, $3);
646         if ($$ == 0)
647             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
648     }
649     | relational_expression RIGHT_ANGLE shift_expression  {
650         $$ = parseContext.handleBinaryMath($2.loc, ">", EOpGreaterThan, $1, $3);
651         if ($$ == 0)
652             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
653     }
654     | relational_expression LE_OP shift_expression  {
655         $$ = parseContext.handleBinaryMath($2.loc, "<=", EOpLessThanEqual, $1, $3);
656         if ($$ == 0)
657             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
658     }
659     | relational_expression GE_OP shift_expression  {
660         $$ = parseContext.handleBinaryMath($2.loc, ">=", EOpGreaterThanEqual, $1, $3);
661         if ($$ == 0)
662             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
663     }
664     ;
665
666 equality_expression
667     : relational_expression { $$ = $1; }
668     | equality_expression EQ_OP relational_expression  {
669         parseContext.arrayObjectCheck($2.loc, $1->getType(), "array comparison");
670         parseContext.opaqueCheck($2.loc, $1->getType(), "==");
671         parseContext.specializationCheck($2.loc, $1->getType(), "==");
672         parseContext.referenceCheck($2.loc, $1->getType(), "==");
673         $$ = parseContext.handleBinaryMath($2.loc, "==", EOpEqual, $1, $3);
674         if ($$ == 0)
675             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
676     }
677     | equality_expression NE_OP relational_expression {
678         parseContext.arrayObjectCheck($2.loc, $1->getType(), "array comparison");
679         parseContext.opaqueCheck($2.loc, $1->getType(), "!=");
680         parseContext.specializationCheck($2.loc, $1->getType(), "!=");
681         parseContext.referenceCheck($2.loc, $1->getType(), "!=");
682         $$ = parseContext.handleBinaryMath($2.loc, "!=", EOpNotEqual, $1, $3);
683         if ($$ == 0)
684             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
685     }
686     ;
687
688 and_expression
689     : equality_expression { $$ = $1; }
690     | and_expression AMPERSAND equality_expression {
691         parseContext.fullIntegerCheck($2.loc, "bitwise and");
692         $$ = parseContext.handleBinaryMath($2.loc, "&", EOpAnd, $1, $3);
693         if ($$ == 0)
694             $$ = $1;
695     }
696     ;
697
698 exclusive_or_expression
699     : and_expression { $$ = $1; }
700     | exclusive_or_expression CARET and_expression {
701         parseContext.fullIntegerCheck($2.loc, "bitwise exclusive or");
702         $$ = parseContext.handleBinaryMath($2.loc, "^", EOpExclusiveOr, $1, $3);
703         if ($$ == 0)
704             $$ = $1;
705     }
706     ;
707
708 inclusive_or_expression
709     : exclusive_or_expression { $$ = $1; }
710     | inclusive_or_expression VERTICAL_BAR exclusive_or_expression {
711         parseContext.fullIntegerCheck($2.loc, "bitwise inclusive or");
712         $$ = parseContext.handleBinaryMath($2.loc, "|", EOpInclusiveOr, $1, $3);
713         if ($$ == 0)
714             $$ = $1;
715     }
716     ;
717
718 logical_and_expression
719     : inclusive_or_expression { $$ = $1; }
720     | logical_and_expression AND_OP inclusive_or_expression {
721         $$ = parseContext.handleBinaryMath($2.loc, "&&", EOpLogicalAnd, $1, $3);
722         if ($$ == 0)
723             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
724     }
725     ;
726
727 logical_xor_expression
728     : logical_and_expression { $$ = $1; }
729     | logical_xor_expression XOR_OP logical_and_expression  {
730         $$ = parseContext.handleBinaryMath($2.loc, "^^", EOpLogicalXor, $1, $3);
731         if ($$ == 0)
732             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
733     }
734     ;
735
736 logical_or_expression
737     : logical_xor_expression { $$ = $1; }
738     | logical_or_expression OR_OP logical_xor_expression  {
739         $$ = parseContext.handleBinaryMath($2.loc, "||", EOpLogicalOr, $1, $3);
740         if ($$ == 0)
741             $$ = parseContext.intermediate.addConstantUnion(false, $2.loc);
742     }
743     ;
744
745 conditional_expression
746     : logical_or_expression { $$ = $1; }
747     | logical_or_expression QUESTION {
748         ++parseContext.controlFlowNestingLevel;
749     }
750       expression COLON assignment_expression {
751         --parseContext.controlFlowNestingLevel;
752         parseContext.boolCheck($2.loc, $1);
753         parseContext.rValueErrorCheck($2.loc, "?", $1);
754         parseContext.rValueErrorCheck($5.loc, ":", $4);
755         parseContext.rValueErrorCheck($5.loc, ":", $6);
756         $$ = parseContext.intermediate.addSelection($1, $4, $6, $2.loc);
757         if ($$ == 0) {
758             parseContext.binaryOpError($2.loc, ":", $4->getCompleteString(), $6->getCompleteString());
759             $$ = $6;
760         }
761     }
762     ;
763
764 assignment_expression
765     : conditional_expression { $$ = $1; }
766     | unary_expression assignment_operator assignment_expression {
767         parseContext.arrayObjectCheck($2.loc, $1->getType(), "array assignment");
768         parseContext.opaqueCheck($2.loc, $1->getType(), "=");
769         parseContext.storage16BitAssignmentCheck($2.loc, $1->getType(), "=");
770         parseContext.specializationCheck($2.loc, $1->getType(), "=");
771         parseContext.lValueErrorCheck($2.loc, "assign", $1);
772         parseContext.rValueErrorCheck($2.loc, "assign", $3);
773         $$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.loc);
774         if ($$ == 0) {
775             parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
776             $$ = $1;
777         }
778     }
779     ;
780
781 assignment_operator
782     : EQUAL {
783         $$.loc = $1.loc;
784         $$.op = EOpAssign;
785     }
786     | MUL_ASSIGN {
787         $$.loc = $1.loc;
788         $$.op = EOpMulAssign;
789     }
790     | DIV_ASSIGN {
791         $$.loc = $1.loc;
792         $$.op = EOpDivAssign;
793     }
794     | MOD_ASSIGN {
795         parseContext.fullIntegerCheck($1.loc, "%=");
796         $$.loc = $1.loc;
797         $$.op = EOpModAssign;
798     }
799     | ADD_ASSIGN {
800         $$.loc = $1.loc;
801         $$.op = EOpAddAssign;
802     }
803     | SUB_ASSIGN {
804         $$.loc = $1.loc;
805         $$.op = EOpSubAssign;
806     }
807     | LEFT_ASSIGN {
808         parseContext.fullIntegerCheck($1.loc, "bit-shift left assign");
809         $$.loc = $1.loc; $$.op = EOpLeftShiftAssign;
810     }
811     | RIGHT_ASSIGN {
812         parseContext.fullIntegerCheck($1.loc, "bit-shift right assign");
813         $$.loc = $1.loc; $$.op = EOpRightShiftAssign;
814     }
815     | AND_ASSIGN {
816         parseContext.fullIntegerCheck($1.loc, "bitwise-and assign");
817         $$.loc = $1.loc; $$.op = EOpAndAssign;
818     }
819     | XOR_ASSIGN {
820         parseContext.fullIntegerCheck($1.loc, "bitwise-xor assign");
821         $$.loc = $1.loc; $$.op = EOpExclusiveOrAssign;
822     }
823     | OR_ASSIGN {
824         parseContext.fullIntegerCheck($1.loc, "bitwise-or assign");
825         $$.loc = $1.loc; $$.op = EOpInclusiveOrAssign;
826     }
827     ;
828
829 expression
830     : assignment_expression {
831         $$ = $1;
832     }
833     | expression COMMA assignment_expression {
834         parseContext.samplerConstructorLocationCheck($2.loc, ",", $3);
835         $$ = parseContext.intermediate.addComma($1, $3, $2.loc);
836         if ($$ == 0) {
837             parseContext.binaryOpError($2.loc, ",", $1->getCompleteString(), $3->getCompleteString());
838             $$ = $3;
839         }
840     }
841     ;
842
843 constant_expression
844     : conditional_expression {
845         parseContext.constantValueCheck($1, "");
846         $$ = $1;
847     }
848     ;
849
850 declaration
851     : function_prototype SEMICOLON {
852         parseContext.handleFunctionDeclarator($1.loc, *$1.function, true /* prototype */);
853         $$ = 0;
854         // TODO: 4.0 functionality: subroutines: make the identifier a user type for this signature
855     }
856     | init_declarator_list SEMICOLON {
857         if ($1.intermNode && $1.intermNode->getAsAggregate())
858             $1.intermNode->getAsAggregate()->setOperator(EOpSequence);
859         $$ = $1.intermNode;
860     }
861     | PRECISION precision_qualifier type_specifier SEMICOLON {
862         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "precision statement");
863         // lazy setting of the previous scope's defaults, has effect only the first time it is called in a particular scope
864         parseContext.symbolTable.setPreviousDefaultPrecisions(&parseContext.defaultPrecision[0]);
865         parseContext.setDefaultPrecision($1.loc, $3, $2.qualifier.precision);
866         $$ = 0;
867     }
868     | block_structure SEMICOLON {
869         parseContext.declareBlock($1.loc, *$1.typeList);
870         $$ = 0;
871     }
872     | block_structure IDENTIFIER SEMICOLON {
873         parseContext.declareBlock($1.loc, *$1.typeList, $2.string);
874         $$ = 0;
875     }
876     | block_structure IDENTIFIER array_specifier SEMICOLON {
877         parseContext.declareBlock($1.loc, *$1.typeList, $2.string, $3.arraySizes);
878         $$ = 0;
879     }
880     | type_qualifier SEMICOLON {
881         parseContext.globalQualifierFixCheck($1.loc, $1.qualifier);
882         parseContext.updateStandaloneQualifierDefaults($1.loc, $1);
883         $$ = 0;
884     }
885     | type_qualifier IDENTIFIER SEMICOLON {
886         parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
887         parseContext.addQualifierToExisting($1.loc, $1.qualifier, *$2.string);
888         $$ = 0;
889     }
890     | type_qualifier IDENTIFIER identifier_list SEMICOLON {
891         parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
892         $3->push_back($2.string);
893         parseContext.addQualifierToExisting($1.loc, $1.qualifier, *$3);
894         $$ = 0;
895     }
896     ;
897
898 block_structure
899     : type_qualifier IDENTIFIER LEFT_BRACE { parseContext.nestedBlockCheck($1.loc); } struct_declaration_list RIGHT_BRACE {
900         --parseContext.structNestingLevel;
901         parseContext.blockName = $2.string;
902         parseContext.globalQualifierFixCheck($1.loc, $1.qualifier);
903         parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
904         parseContext.currentBlockQualifier = $1.qualifier;
905         $$.loc = $1.loc;
906         $$.typeList = $5;
907     }
908
909 identifier_list
910     : COMMA IDENTIFIER {
911         $$ = new TIdentifierList;
912         $$->push_back($2.string);
913     }
914     | identifier_list COMMA IDENTIFIER {
915         $$ = $1;
916         $$->push_back($3.string);
917     }
918     ;
919
920 function_prototype
921     : function_declarator RIGHT_PAREN  {
922         $$.function = $1;
923         $$.loc = $2.loc;
924     }
925     ;
926
927 function_declarator
928     : function_header {
929         $$ = $1;
930     }
931     | function_header_with_parameters {
932         $$ = $1;
933     }
934     ;
935
936
937 function_header_with_parameters
938     : function_header parameter_declaration {
939         // Add the parameter
940         $$ = $1;
941         if ($2.param.type->getBasicType() != EbtVoid)
942             $1->addParameter($2.param);
943         else
944             delete $2.param.type;
945     }
946     | function_header_with_parameters COMMA parameter_declaration {
947         //
948         // Only first parameter of one-parameter functions can be void
949         // The check for named parameters not being void is done in parameter_declarator
950         //
951         if ($3.param.type->getBasicType() == EbtVoid) {
952             //
953             // This parameter > first is void
954             //
955             parseContext.error($2.loc, "cannot be an argument type except for '(void)'", "void", "");
956             delete $3.param.type;
957         } else {
958             // Add the parameter
959             $$ = $1;
960             $1->addParameter($3.param);
961         }
962     }
963     ;
964
965 function_header
966     : fully_specified_type IDENTIFIER LEFT_PAREN {
967         if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) {
968             parseContext.error($2.loc, "no qualifiers allowed for function return",
969                                GetStorageQualifierString($1.qualifier.storage), "");
970         }
971         if ($1.arraySizes)
972             parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
973
974         // Add the function as a prototype after parsing it (we do not support recursion)
975         TFunction *function;
976         TType type($1);
977
978         // Potentially rename shader entry point function.  No-op most of the time.
979         parseContext.renameShaderFunction($2.string);
980
981         // Make the function
982         function = new TFunction($2.string, type);
983         $$ = function;
984     }
985     ;
986
987 parameter_declarator
988     // Type + name
989     : type_specifier IDENTIFIER {
990         if ($1.arraySizes) {
991             parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
992             parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
993             parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
994         }
995         if ($1.basicType == EbtVoid) {
996             parseContext.error($2.loc, "illegal use of type 'void'", $2.string->c_str(), "");
997         }
998         parseContext.reservedErrorCheck($2.loc, *$2.string);
999
1000         TParameter param = {$2.string, new TType($1)};
1001         $$.loc = $2.loc;
1002         $$.param = param;
1003     }
1004     | type_specifier IDENTIFIER array_specifier {
1005         if ($1.arraySizes) {
1006             parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
1007             parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
1008             parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
1009         }
1010         TType* type = new TType($1);
1011         type->transferArraySizes($3.arraySizes);
1012         type->copyArrayInnerSizes($1.arraySizes);
1013
1014         parseContext.arrayOfArrayVersionCheck($2.loc, type->getArraySizes());
1015         parseContext.arraySizeRequiredCheck($3.loc, *$3.arraySizes);
1016         parseContext.reservedErrorCheck($2.loc, *$2.string);
1017
1018         TParameter param = { $2.string, type };
1019
1020         $$.loc = $2.loc;
1021         $$.param = param;
1022     }
1023     ;
1024
1025 parameter_declaration
1026     //
1027     // With name
1028     //
1029     : type_qualifier parameter_declarator {
1030         $$ = $2;
1031         if ($1.qualifier.precision != EpqNone)
1032             $$.param.type->getQualifier().precision = $1.qualifier.precision;
1033         parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
1034
1035         parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
1036         parseContext.parameterTypeCheck($2.loc, $1.qualifier.storage, *$$.param.type);
1037         parseContext.paramCheckFix($1.loc, $1.qualifier, *$$.param.type);
1038
1039     }
1040     | parameter_declarator {
1041         $$ = $1;
1042
1043         parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type);
1044         parseContext.paramCheckFixStorage($1.loc, EvqTemporary, *$$.param.type);
1045         parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
1046     }
1047     //
1048     // Without name
1049     //
1050     | type_qualifier parameter_type_specifier {
1051         $$ = $2;
1052         if ($1.qualifier.precision != EpqNone)
1053             $$.param.type->getQualifier().precision = $1.qualifier.precision;
1054         parseContext.precisionQualifierCheck($1.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
1055
1056         parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers);
1057         parseContext.parameterTypeCheck($2.loc, $1.qualifier.storage, *$$.param.type);
1058         parseContext.paramCheckFix($1.loc, $1.qualifier, *$$.param.type);
1059     }
1060     | parameter_type_specifier {
1061         $$ = $1;
1062
1063         parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type);
1064         parseContext.paramCheckFixStorage($1.loc, EvqTemporary, *$$.param.type);
1065         parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
1066     }
1067     ;
1068
1069 parameter_type_specifier
1070     : type_specifier {
1071         TParameter param = { 0, new TType($1) };
1072         $$.param = param;
1073         if ($1.arraySizes)
1074             parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
1075     }
1076     ;
1077
1078 init_declarator_list
1079     : single_declaration {
1080         $$ = $1;
1081     }
1082     | init_declarator_list COMMA IDENTIFIER {
1083         $$ = $1;
1084         parseContext.declareVariable($3.loc, *$3.string, $1.type);
1085     }
1086     | init_declarator_list COMMA IDENTIFIER array_specifier {
1087         $$ = $1;
1088         parseContext.declareVariable($3.loc, *$3.string, $1.type, $4.arraySizes);
1089     }
1090     | init_declarator_list COMMA IDENTIFIER array_specifier EQUAL initializer {
1091         $$.type = $1.type;
1092         TIntermNode* initNode = parseContext.declareVariable($3.loc, *$3.string, $1.type, $4.arraySizes, $6);
1093         $$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, initNode, $5.loc);
1094     }
1095     | init_declarator_list COMMA IDENTIFIER EQUAL initializer {
1096         $$.type = $1.type;
1097         TIntermNode* initNode = parseContext.declareVariable($3.loc, *$3.string, $1.type, 0, $5);
1098         $$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, initNode, $4.loc);
1099     }
1100     ;
1101
1102 single_declaration
1103     : fully_specified_type {
1104         $$.type = $1;
1105         $$.intermNode = 0;
1106
1107         parseContext.declareTypeDefaults($$.loc, $$.type);
1108
1109     }
1110     | fully_specified_type IDENTIFIER {
1111         $$.type = $1;
1112         $$.intermNode = 0;
1113         parseContext.declareVariable($2.loc, *$2.string, $1);
1114     }
1115     | fully_specified_type IDENTIFIER array_specifier {
1116         $$.type = $1;
1117         $$.intermNode = 0;
1118         parseContext.declareVariable($2.loc, *$2.string, $1, $3.arraySizes);
1119     }
1120     | fully_specified_type IDENTIFIER array_specifier EQUAL initializer {
1121         $$.type = $1;
1122         TIntermNode* initNode = parseContext.declareVariable($2.loc, *$2.string, $1, $3.arraySizes, $5);
1123         $$.intermNode = parseContext.intermediate.growAggregate(0, initNode, $4.loc);
1124     }
1125     | fully_specified_type IDENTIFIER EQUAL initializer {
1126         $$.type = $1;
1127         TIntermNode* initNode = parseContext.declareVariable($2.loc, *$2.string, $1, 0, $4);
1128         $$.intermNode = parseContext.intermediate.growAggregate(0, initNode, $3.loc);
1129     }
1130
1131 // Grammar Note:  No 'enum', or 'typedef'.
1132
1133 fully_specified_type
1134     : type_specifier {
1135         $$ = $1;
1136
1137         parseContext.globalQualifierTypeCheck($1.loc, $1.qualifier, $$);
1138         if ($1.arraySizes) {
1139             parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
1140             parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
1141         }
1142         parseContext.precisionQualifierCheck($$.loc, $$.basicType, $$.qualifier);
1143     }
1144     | type_qualifier type_specifier  {
1145         parseContext.globalQualifierFixCheck($1.loc, $1.qualifier);
1146         parseContext.globalQualifierTypeCheck($1.loc, $1.qualifier, $2);
1147
1148         if ($2.arraySizes) {
1149             parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
1150             parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
1151         }
1152
1153         if ($2.arraySizes && parseContext.arrayQualifierError($2.loc, $1.qualifier))
1154             $2.arraySizes = nullptr;
1155
1156         parseContext.checkNoShaderLayouts($2.loc, $1.shaderQualifiers);
1157         $2.shaderQualifiers.merge($1.shaderQualifiers);
1158         parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true);
1159         parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
1160
1161         $$ = $2;
1162
1163         if (! $$.qualifier.isInterpolation() &&
1164             ((parseContext.language == EShLangVertex   && $$.qualifier.storage == EvqVaryingOut) ||
1165              (parseContext.language == EShLangFragment && $$.qualifier.storage == EvqVaryingIn)))
1166             $$.qualifier.smooth = true;
1167     }
1168     ;
1169
1170 invariant_qualifier
1171     : INVARIANT {
1172         parseContext.globalCheck($1.loc, "invariant");
1173         parseContext.profileRequires($$.loc, ENoProfile, 120, 0, "invariant");
1174         $$.init($1.loc);
1175         $$.qualifier.invariant = true;
1176     }
1177     ;
1178
1179 interpolation_qualifier
1180     : SMOOTH {
1181         parseContext.globalCheck($1.loc, "smooth");
1182         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "smooth");
1183         parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "smooth");
1184         $$.init($1.loc);
1185         $$.qualifier.smooth = true;
1186     }
1187     | FLAT {
1188         parseContext.globalCheck($1.loc, "flat");
1189         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "flat");
1190         parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "flat");
1191         $$.init($1.loc);
1192         $$.qualifier.flat = true;
1193     }
1194
1195     | NOPERSPECTIVE {
1196         parseContext.globalCheck($1.loc, "noperspective");
1197         parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_NV_shader_noperspective_interpolation, "noperspective");
1198         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "noperspective");
1199         $$.init($1.loc);
1200         $$.qualifier.nopersp = true;
1201     }
1202     | EXPLICITINTERPAMD {
1203         parseContext.globalCheck($1.loc, "__explicitInterpAMD");
1204         parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_AMD_shader_explicit_vertex_parameter, "explicit interpolation");
1205         parseContext.profileRequires($1.loc, ECompatibilityProfile, 450, E_GL_AMD_shader_explicit_vertex_parameter, "explicit interpolation");
1206         $$.init($1.loc);
1207         $$.qualifier.explicitInterp = true;
1208     }
1209     | PERVERTEXNV {
1210         parseContext.globalCheck($1.loc, "pervertexNV");
1211         parseContext.profileRequires($1.loc, ECoreProfile, 0, E_GL_NV_fragment_shader_barycentric, "fragment shader barycentric");
1212         parseContext.profileRequires($1.loc, ECompatibilityProfile, 0, E_GL_NV_fragment_shader_barycentric, "fragment shader barycentric");
1213         parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_NV_fragment_shader_barycentric, "fragment shader barycentric");
1214         $$.init($1.loc);
1215         $$.qualifier.pervertexNV = true;
1216     }
1217     | PERPRIMITIVENV {
1218         // No need for profile version or extension check. Shader stage already checks both.
1219         parseContext.globalCheck($1.loc, "perprimitiveNV");
1220         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
1221         // Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
1222         if (parseContext.language == EShLangFragment)
1223             parseContext.requireExtensions($1.loc, 1, &E_GL_NV_mesh_shader, "perprimitiveNV");
1224         $$.init($1.loc);
1225         $$.qualifier.perPrimitiveNV = true;
1226     }
1227     | PERVIEWNV {
1228         // No need for profile version or extension check. Shader stage already checks both.
1229         parseContext.globalCheck($1.loc, "perviewNV");
1230         parseContext.requireStage($1.loc, EShLangMeshNV, "perviewNV");
1231         $$.init($1.loc);
1232         $$.qualifier.perViewNV = true;
1233     }
1234     | PERTASKNV {
1235         // No need for profile version or extension check. Shader stage already checks both.
1236         parseContext.globalCheck($1.loc, "taskNV");
1237         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
1238         $$.init($1.loc);
1239         $$.qualifier.perTaskNV = true;
1240     }
1241
1242     ;
1243
1244 layout_qualifier
1245     : LAYOUT LEFT_PAREN layout_qualifier_id_list RIGHT_PAREN {
1246         $$ = $3;
1247     }
1248     ;
1249
1250 layout_qualifier_id_list
1251     : layout_qualifier_id {
1252         $$ = $1;
1253     }
1254     | layout_qualifier_id_list COMMA layout_qualifier_id {
1255         $$ = $1;
1256         $$.shaderQualifiers.merge($3.shaderQualifiers);
1257         parseContext.mergeObjectLayoutQualifiers($$.qualifier, $3.qualifier, false);
1258     }
1259
1260 layout_qualifier_id
1261     : IDENTIFIER {
1262         $$.init($1.loc);
1263         parseContext.setLayoutQualifier($1.loc, $$, *$1.string);
1264     }
1265     | IDENTIFIER EQUAL constant_expression {
1266         $$.init($1.loc);
1267         parseContext.setLayoutQualifier($1.loc, $$, *$1.string, $3);
1268     }
1269     | SHARED { // because "shared" is both an identifier and a keyword
1270         $$.init($1.loc);
1271         TString strShared("shared");
1272         parseContext.setLayoutQualifier($1.loc, $$, strShared);
1273     }
1274     ;
1275
1276
1277 precise_qualifier
1278     : PRECISE {
1279         parseContext.profileRequires($$.loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader5, "precise");
1280         parseContext.profileRequires($1.loc, EEsProfile, 320, Num_AEP_gpu_shader5, AEP_gpu_shader5, "precise");
1281         $$.init($1.loc);
1282         $$.qualifier.noContraction = true;
1283     }
1284     ;
1285
1286
1287 type_qualifier
1288     : single_type_qualifier {
1289         $$ = $1;
1290     }
1291     | type_qualifier single_type_qualifier {
1292         $$ = $1;
1293         if ($$.basicType == EbtVoid)
1294             $$.basicType = $2.basicType;
1295
1296         $$.shaderQualifiers.merge($2.shaderQualifiers);
1297         parseContext.mergeQualifiers($$.loc, $$.qualifier, $2.qualifier, false);
1298     }
1299     ;
1300
1301 single_type_qualifier
1302     : storage_qualifier {
1303         $$ = $1;
1304     }
1305     | layout_qualifier {
1306         $$ = $1;
1307     }
1308     | precision_qualifier {
1309         parseContext.checkPrecisionQualifier($1.loc, $1.qualifier.precision);
1310         $$ = $1;
1311     }
1312     | interpolation_qualifier {
1313         // allow inheritance of storage qualifier from block declaration
1314         $$ = $1;
1315     }
1316     | invariant_qualifier {
1317         // allow inheritance of storage qualifier from block declaration
1318         $$ = $1;
1319     }
1320
1321     | precise_qualifier {
1322         // allow inheritance of storage qualifier from block declaration
1323         $$ = $1;
1324     }
1325     | non_uniform_qualifier {
1326         $$ = $1;
1327     }
1328
1329     ;
1330
1331 storage_qualifier
1332     : CONST {
1333         $$.init($1.loc);
1334         $$.qualifier.storage = EvqConst;  // will later turn into EvqConstReadOnly, if the initializer is not constant
1335     }
1336     | INOUT {
1337         parseContext.globalCheck($1.loc, "inout");
1338         $$.init($1.loc);
1339         $$.qualifier.storage = EvqInOut;
1340     }
1341     | IN {
1342         parseContext.globalCheck($1.loc, "in");
1343         $$.init($1.loc);
1344         // whether this is a parameter "in" or a pipeline "in" will get sorted out a bit later
1345         $$.qualifier.storage = EvqIn;
1346     }
1347     | OUT {
1348         parseContext.globalCheck($1.loc, "out");
1349         $$.init($1.loc);
1350         // whether this is a parameter "out" or a pipeline "out" will get sorted out a bit later
1351         $$.qualifier.storage = EvqOut;
1352     }
1353     | CENTROID {
1354         parseContext.profileRequires($1.loc, ENoProfile, 120, 0, "centroid");
1355         parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "centroid");
1356         parseContext.globalCheck($1.loc, "centroid");
1357         $$.init($1.loc);
1358         $$.qualifier.centroid = true;
1359     }
1360     | UNIFORM {
1361         parseContext.globalCheck($1.loc, "uniform");
1362         $$.init($1.loc);
1363         $$.qualifier.storage = EvqUniform;
1364     }
1365     | SHARED {
1366         parseContext.globalCheck($1.loc, "shared");
1367         parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_compute_shader, "shared");
1368         parseContext.profileRequires($1.loc, EEsProfile, 310, 0, "shared");
1369         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangComputeMask | EShLangMeshNVMask | EShLangTaskNVMask), "shared");
1370         $$.init($1.loc);
1371         $$.qualifier.storage = EvqShared;
1372     }
1373     | BUFFER {
1374         parseContext.globalCheck($1.loc, "buffer");
1375         $$.init($1.loc);
1376         $$.qualifier.storage = EvqBuffer;
1377     }
1378
1379     | ATTRIBUTE {
1380         parseContext.requireStage($1.loc, EShLangVertex, "attribute");
1381         parseContext.checkDeprecated($1.loc, ECoreProfile, 130, "attribute");
1382         parseContext.checkDeprecated($1.loc, ENoProfile, 130, "attribute");
1383         parseContext.requireNotRemoved($1.loc, ECoreProfile, 420, "attribute");
1384         parseContext.requireNotRemoved($1.loc, EEsProfile, 300, "attribute");
1385
1386         parseContext.globalCheck($1.loc, "attribute");
1387
1388         $$.init($1.loc);
1389         $$.qualifier.storage = EvqVaryingIn;
1390     }
1391     | VARYING {
1392         parseContext.checkDeprecated($1.loc, ENoProfile, 130, "varying");
1393         parseContext.checkDeprecated($1.loc, ECoreProfile, 130, "varying");
1394         parseContext.requireNotRemoved($1.loc, ECoreProfile, 420, "varying");
1395         parseContext.requireNotRemoved($1.loc, EEsProfile, 300, "varying");
1396
1397         parseContext.globalCheck($1.loc, "varying");
1398
1399         $$.init($1.loc);
1400         if (parseContext.language == EShLangVertex)
1401             $$.qualifier.storage = EvqVaryingOut;
1402         else
1403             $$.qualifier.storage = EvqVaryingIn;
1404     }
1405     | PATCH {
1406         parseContext.globalCheck($1.loc, "patch");
1407         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTessControlMask | EShLangTessEvaluationMask), "patch");
1408         $$.init($1.loc);
1409         $$.qualifier.patch = true;
1410     }
1411     | SAMPLE {
1412         parseContext.globalCheck($1.loc, "sample");
1413         $$.init($1.loc);
1414         $$.qualifier.sample = true;
1415     }
1416     | HITATTRNV {
1417         parseContext.globalCheck($1.loc, "hitAttributeNV");
1418         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangIntersectNVMask | EShLangClosestHitNVMask
1419             | EShLangAnyHitNVMask), "hitAttributeNV");
1420         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "hitAttributeNV");
1421         $$.init($1.loc);
1422         $$.qualifier.storage = EvqHitAttrNV;
1423     }
1424     | PAYLOADNV {
1425         parseContext.globalCheck($1.loc, "rayPayloadNV");
1426         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangRayGenNVMask | EShLangClosestHitNVMask |
1427             EShLangAnyHitNVMask | EShLangMissNVMask), "rayPayloadNV");
1428         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "rayPayloadNV");
1429         $$.init($1.loc);
1430         $$.qualifier.storage = EvqPayloadNV;
1431     }
1432     | PAYLOADINNV {
1433         parseContext.globalCheck($1.loc, "rayPayloadInNV");
1434         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangClosestHitNVMask |
1435             EShLangAnyHitNVMask | EShLangMissNVMask), "rayPayloadInNV");
1436         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "rayPayloadInNV");
1437         $$.init($1.loc);
1438         $$.qualifier.storage = EvqPayloadInNV;
1439     }
1440     | CALLDATANV {
1441         parseContext.globalCheck($1.loc, "callableDataNV");
1442         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangRayGenNVMask |
1443             EShLangClosestHitNVMask | EShLangMissNVMask | EShLangCallableNVMask), "callableDataNV");
1444         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "callableDataNV");
1445         $$.init($1.loc);
1446         $$.qualifier.storage = EvqCallableDataNV;
1447     }
1448     | CALLDATAINNV {
1449         parseContext.globalCheck($1.loc, "callableDataInNV");
1450         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangCallableNVMask), "callableDataInNV");
1451         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "callableDataInNV");
1452         $$.init($1.loc);
1453         $$.qualifier.storage = EvqCallableDataInNV;
1454     }
1455     | COHERENT {
1456         $$.init($1.loc);
1457         $$.qualifier.coherent = true;
1458     }
1459     | DEVICECOHERENT {
1460         $$.init($1.loc);
1461         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "devicecoherent");
1462         $$.qualifier.devicecoherent = true;
1463     }
1464     | QUEUEFAMILYCOHERENT {
1465         $$.init($1.loc);
1466         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "queuefamilycoherent");
1467         $$.qualifier.queuefamilycoherent = true;
1468     }
1469     | WORKGROUPCOHERENT {
1470         $$.init($1.loc);
1471         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "workgroupcoherent");
1472         $$.qualifier.workgroupcoherent = true;
1473     }
1474     | SUBGROUPCOHERENT {
1475         $$.init($1.loc);
1476         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "subgroupcoherent");
1477         $$.qualifier.subgroupcoherent = true;
1478     }
1479     | NONPRIVATE {
1480         $$.init($1.loc);
1481         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "nonprivate");
1482         $$.qualifier.nonprivate = true;
1483     }
1484     | VOLATILE {
1485         $$.init($1.loc);
1486         $$.qualifier.volatil = true;
1487     }
1488     | RESTRICT {
1489         $$.init($1.loc);
1490         $$.qualifier.restrict = true;
1491     }
1492     | READONLY {
1493         $$.init($1.loc);
1494         $$.qualifier.readonly = true;
1495     }
1496     | WRITEONLY {
1497         $$.init($1.loc);
1498         $$.qualifier.writeonly = true;
1499     }
1500     | SUBROUTINE {
1501         parseContext.spvRemoved($1.loc, "subroutine");
1502         parseContext.globalCheck($1.loc, "subroutine");
1503         parseContext.unimplemented($1.loc, "subroutine");
1504         $$.init($1.loc);
1505     }
1506     | SUBROUTINE LEFT_PAREN type_name_list RIGHT_PAREN {
1507         parseContext.spvRemoved($1.loc, "subroutine");
1508         parseContext.globalCheck($1.loc, "subroutine");
1509         parseContext.unimplemented($1.loc, "subroutine");
1510         $$.init($1.loc);
1511     }
1512
1513     ;
1514
1515
1516 non_uniform_qualifier
1517     : NONUNIFORM {
1518         $$.init($1.loc);
1519         $$.qualifier.nonUniform = true;
1520     }
1521     ;
1522
1523 type_name_list
1524     : IDENTIFIER {
1525         // TODO
1526     }
1527     | type_name_list COMMA IDENTIFIER {
1528         // TODO: 4.0 semantics: subroutines
1529         // 1) make sure each identifier is a type declared earlier with SUBROUTINE
1530         // 2) save all of the identifiers for future comparison with the declared function
1531     }
1532     ;
1533
1534
1535 type_specifier
1536     : type_specifier_nonarray type_parameter_specifier_opt {
1537         $$ = $1;
1538         $$.qualifier.precision = parseContext.getDefaultPrecision($$);
1539         $$.typeParameters = $2;
1540     }
1541     | type_specifier_nonarray type_parameter_specifier_opt array_specifier {
1542         parseContext.arrayOfArrayVersionCheck($3.loc, $3.arraySizes);
1543         $$ = $1;
1544         $$.qualifier.precision = parseContext.getDefaultPrecision($$);
1545         $$.typeParameters = $2;
1546         $$.arraySizes = $3.arraySizes;
1547     }
1548     ;
1549
1550 array_specifier
1551     : LEFT_BRACKET RIGHT_BRACKET {
1552         $$.loc = $1.loc;
1553         $$.arraySizes = new TArraySizes;
1554         $$.arraySizes->addInnerSize();
1555     }
1556     | LEFT_BRACKET conditional_expression RIGHT_BRACKET {
1557         $$.loc = $1.loc;
1558         $$.arraySizes = new TArraySizes;
1559
1560         TArraySize size;
1561         parseContext.arraySizeCheck($2->getLoc(), $2, size, "array size");
1562         $$.arraySizes->addInnerSize(size);
1563     }
1564     | array_specifier LEFT_BRACKET RIGHT_BRACKET {
1565         $$ = $1;
1566         $$.arraySizes->addInnerSize();
1567     }
1568     | array_specifier LEFT_BRACKET conditional_expression RIGHT_BRACKET {
1569         $$ = $1;
1570
1571         TArraySize size;
1572         parseContext.arraySizeCheck($3->getLoc(), $3, size, "array size");
1573         $$.arraySizes->addInnerSize(size);
1574     }
1575     ;
1576
1577 type_parameter_specifier_opt
1578     : type_parameter_specifier {
1579         $$ = $1;
1580     }
1581     | /* May be null */ {
1582         $$ = 0;
1583     }
1584     ;
1585
1586 type_parameter_specifier
1587     : LEFT_ANGLE type_parameter_specifier_list RIGHT_ANGLE {
1588         $$ = $2;
1589     }
1590     ;
1591
1592 type_parameter_specifier_list
1593     : unary_expression {
1594         $$ = new TArraySizes;
1595
1596         TArraySize size;
1597         parseContext.arraySizeCheck($1->getLoc(), $1, size, "type parameter");
1598         $$->addInnerSize(size);
1599     }
1600     | type_parameter_specifier_list COMMA unary_expression {
1601         $$ = $1;
1602
1603         TArraySize size;
1604         parseContext.arraySizeCheck($3->getLoc(), $3, size, "type parameter");
1605         $$->addInnerSize(size);
1606     }
1607     ;
1608
1609 type_specifier_nonarray
1610     : VOID {
1611         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1612         $$.basicType = EbtVoid;
1613     }
1614     | FLOAT {
1615         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1616         $$.basicType = EbtFloat;
1617     }
1618     | INT {
1619         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1620         $$.basicType = EbtInt;
1621     }
1622     | UINT {
1623         parseContext.fullIntegerCheck($1.loc, "unsigned integer");
1624         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1625         $$.basicType = EbtUint;
1626     }
1627     | BOOL {
1628         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1629         $$.basicType = EbtBool;
1630     }
1631     | VEC2 {
1632         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1633         $$.basicType = EbtFloat;
1634         $$.setVector(2);
1635     }
1636     | VEC3 {
1637         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1638         $$.basicType = EbtFloat;
1639         $$.setVector(3);
1640     }
1641     | VEC4 {
1642         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1643         $$.basicType = EbtFloat;
1644         $$.setVector(4);
1645     }
1646     | BVEC2 {
1647         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1648         $$.basicType = EbtBool;
1649         $$.setVector(2);
1650     }
1651     | BVEC3 {
1652         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1653         $$.basicType = EbtBool;
1654         $$.setVector(3);
1655     }
1656     | BVEC4 {
1657         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1658         $$.basicType = EbtBool;
1659         $$.setVector(4);
1660     }
1661     | IVEC2 {
1662         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1663         $$.basicType = EbtInt;
1664         $$.setVector(2);
1665     }
1666     | IVEC3 {
1667         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1668         $$.basicType = EbtInt;
1669         $$.setVector(3);
1670     }
1671     | IVEC4 {
1672         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1673         $$.basicType = EbtInt;
1674         $$.setVector(4);
1675     }
1676     | UVEC2 {
1677         parseContext.fullIntegerCheck($1.loc, "unsigned integer vector");
1678         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1679         $$.basicType = EbtUint;
1680         $$.setVector(2);
1681     }
1682     | UVEC3 {
1683         parseContext.fullIntegerCheck($1.loc, "unsigned integer vector");
1684         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1685         $$.basicType = EbtUint;
1686         $$.setVector(3);
1687     }
1688     | UVEC4 {
1689         parseContext.fullIntegerCheck($1.loc, "unsigned integer vector");
1690         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1691         $$.basicType = EbtUint;
1692         $$.setVector(4);
1693     }
1694     | MAT2 {
1695         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1696         $$.basicType = EbtFloat;
1697         $$.setMatrix(2, 2);
1698     }
1699     | MAT3 {
1700         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1701         $$.basicType = EbtFloat;
1702         $$.setMatrix(3, 3);
1703     }
1704     | MAT4 {
1705         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1706         $$.basicType = EbtFloat;
1707         $$.setMatrix(4, 4);
1708     }
1709     | MAT2X2 {
1710         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1711         $$.basicType = EbtFloat;
1712         $$.setMatrix(2, 2);
1713     }
1714     | MAT2X3 {
1715         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1716         $$.basicType = EbtFloat;
1717         $$.setMatrix(2, 3);
1718     }
1719     | MAT2X4 {
1720         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1721         $$.basicType = EbtFloat;
1722         $$.setMatrix(2, 4);
1723     }
1724     | MAT3X2 {
1725         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1726         $$.basicType = EbtFloat;
1727         $$.setMatrix(3, 2);
1728     }
1729     | MAT3X3 {
1730         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1731         $$.basicType = EbtFloat;
1732         $$.setMatrix(3, 3);
1733     }
1734     | MAT3X4 {
1735         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1736         $$.basicType = EbtFloat;
1737         $$.setMatrix(3, 4);
1738     }
1739     | MAT4X2 {
1740         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1741         $$.basicType = EbtFloat;
1742         $$.setMatrix(4, 2);
1743     }
1744     | MAT4X3 {
1745         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1746         $$.basicType = EbtFloat;
1747         $$.setMatrix(4, 3);
1748     }
1749     | MAT4X4 {
1750         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1751         $$.basicType = EbtFloat;
1752         $$.setMatrix(4, 4);
1753     }
1754
1755     | DOUBLE {
1756         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double");
1757         if (! parseContext.symbolTable.atBuiltInLevel())
1758             parseContext.doubleCheck($1.loc, "double");
1759         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1760         $$.basicType = EbtDouble;
1761     }
1762     | FLOAT16_T {
1763         parseContext.float16ScalarVectorCheck($1.loc, "float16_t", parseContext.symbolTable.atBuiltInLevel());
1764         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1765         $$.basicType = EbtFloat16;
1766     }
1767     | FLOAT32_T {
1768         parseContext.explicitFloat32Check($1.loc, "float32_t", parseContext.symbolTable.atBuiltInLevel());
1769         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1770         $$.basicType = EbtFloat;
1771     }
1772     | FLOAT64_T {
1773         parseContext.explicitFloat64Check($1.loc, "float64_t", parseContext.symbolTable.atBuiltInLevel());
1774         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1775         $$.basicType = EbtDouble;
1776     }
1777     | INT8_T {
1778         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer", parseContext.symbolTable.atBuiltInLevel());
1779         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1780         $$.basicType = EbtInt8;
1781     }
1782     | UINT8_T {
1783         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1784         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1785         $$.basicType = EbtUint8;
1786     }
1787     | INT16_T {
1788         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer", parseContext.symbolTable.atBuiltInLevel());
1789         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1790         $$.basicType = EbtInt16;
1791     }
1792     | UINT16_T {
1793         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1794         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1795         $$.basicType = EbtUint16;
1796     }
1797     | INT32_T {
1798         parseContext.explicitInt32Check($1.loc, "32-bit signed integer", parseContext.symbolTable.atBuiltInLevel());
1799         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1800         $$.basicType = EbtInt;
1801     }
1802     | UINT32_T {
1803         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1804         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1805         $$.basicType = EbtUint;
1806     }
1807     | INT64_T {
1808         parseContext.int64Check($1.loc, "64-bit integer", parseContext.symbolTable.atBuiltInLevel());
1809         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1810         $$.basicType = EbtInt64;
1811     }
1812     | UINT64_T {
1813         parseContext.int64Check($1.loc, "64-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1814         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1815         $$.basicType = EbtUint64;
1816     }
1817     | DVEC2 {
1818         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
1819         if (! parseContext.symbolTable.atBuiltInLevel())
1820             parseContext.doubleCheck($1.loc, "double vector");
1821         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1822         $$.basicType = EbtDouble;
1823         $$.setVector(2);
1824     }
1825     | DVEC3 {
1826         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
1827         if (! parseContext.symbolTable.atBuiltInLevel())
1828             parseContext.doubleCheck($1.loc, "double vector");
1829         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1830         $$.basicType = EbtDouble;
1831         $$.setVector(3);
1832     }
1833     | DVEC4 {
1834         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
1835         if (! parseContext.symbolTable.atBuiltInLevel())
1836             parseContext.doubleCheck($1.loc, "double vector");
1837         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1838         $$.basicType = EbtDouble;
1839         $$.setVector(4);
1840     }
1841     | F16VEC2 {
1842         parseContext.float16ScalarVectorCheck($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
1843         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1844         $$.basicType = EbtFloat16;
1845         $$.setVector(2);
1846     }
1847     | F16VEC3 {
1848         parseContext.float16ScalarVectorCheck($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
1849         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1850         $$.basicType = EbtFloat16;
1851         $$.setVector(3);
1852     }
1853     | F16VEC4 {
1854         parseContext.float16ScalarVectorCheck($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
1855         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1856         $$.basicType = EbtFloat16;
1857         $$.setVector(4);
1858     }
1859     | F32VEC2 {
1860         parseContext.explicitFloat32Check($1.loc, "float32_t vector", parseContext.symbolTable.atBuiltInLevel());
1861         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1862         $$.basicType = EbtFloat;
1863         $$.setVector(2);
1864     }
1865     | F32VEC3 {
1866         parseContext.explicitFloat32Check($1.loc, "float32_t vector", parseContext.symbolTable.atBuiltInLevel());
1867         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1868         $$.basicType = EbtFloat;
1869         $$.setVector(3);
1870     }
1871     | F32VEC4 {
1872         parseContext.explicitFloat32Check($1.loc, "float32_t vector", parseContext.symbolTable.atBuiltInLevel());
1873         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1874         $$.basicType = EbtFloat;
1875         $$.setVector(4);
1876     }
1877     | F64VEC2 {
1878         parseContext.explicitFloat64Check($1.loc, "float64_t vector", parseContext.symbolTable.atBuiltInLevel());
1879         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1880         $$.basicType = EbtDouble;
1881         $$.setVector(2);
1882     }
1883     | F64VEC3 {
1884         parseContext.explicitFloat64Check($1.loc, "float64_t vector", parseContext.symbolTable.atBuiltInLevel());
1885         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1886         $$.basicType = EbtDouble;
1887         $$.setVector(3);
1888     }
1889     | F64VEC4 {
1890         parseContext.explicitFloat64Check($1.loc, "float64_t vector", parseContext.symbolTable.atBuiltInLevel());
1891         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1892         $$.basicType = EbtDouble;
1893         $$.setVector(4);
1894     }
1895     | I8VEC2 {
1896         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1897         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1898         $$.basicType = EbtInt8;
1899         $$.setVector(2);
1900     }
1901     | I8VEC3 {
1902         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1903         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1904         $$.basicType = EbtInt8;
1905         $$.setVector(3);
1906     }
1907     | I8VEC4 {
1908         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1909         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1910         $$.basicType = EbtInt8;
1911         $$.setVector(4);
1912     }
1913     | I16VEC2 {
1914         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1915         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1916         $$.basicType = EbtInt16;
1917         $$.setVector(2);
1918     }
1919     | I16VEC3 {
1920         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1921         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1922         $$.basicType = EbtInt16;
1923         $$.setVector(3);
1924     }
1925     | I16VEC4 {
1926         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1927         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1928         $$.basicType = EbtInt16;
1929         $$.setVector(4);
1930     }
1931     | I32VEC2 {
1932         parseContext.explicitInt32Check($1.loc, "32-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1933         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1934         $$.basicType = EbtInt;
1935         $$.setVector(2);
1936     }
1937     | I32VEC3 {
1938         parseContext.explicitInt32Check($1.loc, "32-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1939         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1940         $$.basicType = EbtInt;
1941         $$.setVector(3);
1942     }
1943     | I32VEC4 {
1944         parseContext.explicitInt32Check($1.loc, "32-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
1945         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1946         $$.basicType = EbtInt;
1947         $$.setVector(4);
1948     }
1949     | I64VEC2 {
1950         parseContext.int64Check($1.loc, "64-bit integer vector", parseContext.symbolTable.atBuiltInLevel());
1951         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1952         $$.basicType = EbtInt64;
1953         $$.setVector(2);
1954     }
1955     | I64VEC3 {
1956         parseContext.int64Check($1.loc, "64-bit integer vector", parseContext.symbolTable.atBuiltInLevel());
1957         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1958         $$.basicType = EbtInt64;
1959         $$.setVector(3);
1960     }
1961     | I64VEC4 {
1962         parseContext.int64Check($1.loc, "64-bit integer vector", parseContext.symbolTable.atBuiltInLevel());
1963         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1964         $$.basicType = EbtInt64;
1965         $$.setVector(4);
1966     }
1967     | U8VEC2 {
1968         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
1969         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1970         $$.basicType = EbtUint8;
1971         $$.setVector(2);
1972     }
1973     | U8VEC3 {
1974         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
1975         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1976         $$.basicType = EbtUint8;
1977         $$.setVector(3);
1978     }
1979     | U8VEC4 {
1980         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
1981         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1982         $$.basicType = EbtUint8;
1983         $$.setVector(4);
1984     }
1985     | U16VEC2 {
1986         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
1987         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1988         $$.basicType = EbtUint16;
1989         $$.setVector(2);
1990     }
1991     | U16VEC3 {
1992         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
1993         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1994         $$.basicType = EbtUint16;
1995         $$.setVector(3);
1996     }
1997     | U16VEC4 {
1998         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
1999         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2000         $$.basicType = EbtUint16;
2001         $$.setVector(4);
2002     }
2003     | U32VEC2 {
2004         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2005         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2006         $$.basicType = EbtUint;
2007         $$.setVector(2);
2008     }
2009     | U32VEC3 {
2010         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2011         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2012         $$.basicType = EbtUint;
2013         $$.setVector(3);
2014     }
2015     | U32VEC4 {
2016         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2017         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2018         $$.basicType = EbtUint;
2019         $$.setVector(4);
2020     }
2021     | U64VEC2 {
2022         parseContext.int64Check($1.loc, "64-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2023         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2024         $$.basicType = EbtUint64;
2025         $$.setVector(2);
2026     }
2027     | U64VEC3 {
2028         parseContext.int64Check($1.loc, "64-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2029         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2030         $$.basicType = EbtUint64;
2031         $$.setVector(3);
2032     }
2033     | U64VEC4 {
2034         parseContext.int64Check($1.loc, "64-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2035         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2036         $$.basicType = EbtUint64;
2037         $$.setVector(4);
2038     }
2039     | DMAT2 {
2040         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2041         if (! parseContext.symbolTable.atBuiltInLevel())
2042             parseContext.doubleCheck($1.loc, "double matrix");
2043         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2044         $$.basicType = EbtDouble;
2045         $$.setMatrix(2, 2);
2046     }
2047     | DMAT3 {
2048         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2049         if (! parseContext.symbolTable.atBuiltInLevel())
2050             parseContext.doubleCheck($1.loc, "double matrix");
2051         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2052         $$.basicType = EbtDouble;
2053         $$.setMatrix(3, 3);
2054     }
2055     | DMAT4 {
2056         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2057         if (! parseContext.symbolTable.atBuiltInLevel())
2058             parseContext.doubleCheck($1.loc, "double matrix");
2059         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2060         $$.basicType = EbtDouble;
2061         $$.setMatrix(4, 4);
2062     }
2063     | DMAT2X2 {
2064         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2065         if (! parseContext.symbolTable.atBuiltInLevel())
2066             parseContext.doubleCheck($1.loc, "double matrix");
2067         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2068         $$.basicType = EbtDouble;
2069         $$.setMatrix(2, 2);
2070     }
2071     | DMAT2X3 {
2072         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2073         if (! parseContext.symbolTable.atBuiltInLevel())
2074             parseContext.doubleCheck($1.loc, "double matrix");
2075         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2076         $$.basicType = EbtDouble;
2077         $$.setMatrix(2, 3);
2078     }
2079     | DMAT2X4 {
2080         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2081         if (! parseContext.symbolTable.atBuiltInLevel())
2082             parseContext.doubleCheck($1.loc, "double matrix");
2083         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2084         $$.basicType = EbtDouble;
2085         $$.setMatrix(2, 4);
2086     }
2087     | DMAT3X2 {
2088         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2089         if (! parseContext.symbolTable.atBuiltInLevel())
2090             parseContext.doubleCheck($1.loc, "double matrix");
2091         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2092         $$.basicType = EbtDouble;
2093         $$.setMatrix(3, 2);
2094     }
2095     | DMAT3X3 {
2096         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2097         if (! parseContext.symbolTable.atBuiltInLevel())
2098             parseContext.doubleCheck($1.loc, "double matrix");
2099         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2100         $$.basicType = EbtDouble;
2101         $$.setMatrix(3, 3);
2102     }
2103     | DMAT3X4 {
2104         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2105         if (! parseContext.symbolTable.atBuiltInLevel())
2106             parseContext.doubleCheck($1.loc, "double matrix");
2107         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2108         $$.basicType = EbtDouble;
2109         $$.setMatrix(3, 4);
2110     }
2111     | DMAT4X2 {
2112         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2113         if (! parseContext.symbolTable.atBuiltInLevel())
2114             parseContext.doubleCheck($1.loc, "double matrix");
2115         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2116         $$.basicType = EbtDouble;
2117         $$.setMatrix(4, 2);
2118     }
2119     | DMAT4X3 {
2120         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2121         if (! parseContext.symbolTable.atBuiltInLevel())
2122             parseContext.doubleCheck($1.loc, "double matrix");
2123         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2124         $$.basicType = EbtDouble;
2125         $$.setMatrix(4, 3);
2126     }
2127     | DMAT4X4 {
2128         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2129         if (! parseContext.symbolTable.atBuiltInLevel())
2130             parseContext.doubleCheck($1.loc, "double matrix");
2131         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2132         $$.basicType = EbtDouble;
2133         $$.setMatrix(4, 4);
2134     }
2135     | F16MAT2 {
2136         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2137         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2138         $$.basicType = EbtFloat16;
2139         $$.setMatrix(2, 2);
2140     }
2141     | F16MAT3 {
2142         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2143         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2144         $$.basicType = EbtFloat16;
2145         $$.setMatrix(3, 3);
2146     }
2147     | F16MAT4 {
2148         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2149         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2150         $$.basicType = EbtFloat16;
2151         $$.setMatrix(4, 4);
2152     }
2153     | F16MAT2X2 {
2154         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2155         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2156         $$.basicType = EbtFloat16;
2157         $$.setMatrix(2, 2);
2158     }
2159     | F16MAT2X3 {
2160         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2161         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2162         $$.basicType = EbtFloat16;
2163         $$.setMatrix(2, 3);
2164     }
2165     | F16MAT2X4 {
2166         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2167         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2168         $$.basicType = EbtFloat16;
2169         $$.setMatrix(2, 4);
2170     }
2171     | F16MAT3X2 {
2172         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2173         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2174         $$.basicType = EbtFloat16;
2175         $$.setMatrix(3, 2);
2176     }
2177     | F16MAT3X3 {
2178         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2179         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2180         $$.basicType = EbtFloat16;
2181         $$.setMatrix(3, 3);
2182     }
2183     | F16MAT3X4 {
2184         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2185         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2186         $$.basicType = EbtFloat16;
2187         $$.setMatrix(3, 4);
2188     }
2189     | F16MAT4X2 {
2190         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2191         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2192         $$.basicType = EbtFloat16;
2193         $$.setMatrix(4, 2);
2194     }
2195     | F16MAT4X3 {
2196         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2197         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2198         $$.basicType = EbtFloat16;
2199         $$.setMatrix(4, 3);
2200     }
2201     | F16MAT4X4 {
2202         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2203         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2204         $$.basicType = EbtFloat16;
2205         $$.setMatrix(4, 4);
2206     }
2207     | F32MAT2 {
2208         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2209         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2210         $$.basicType = EbtFloat;
2211         $$.setMatrix(2, 2);
2212     }
2213     | F32MAT3 {
2214         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2215         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2216         $$.basicType = EbtFloat;
2217         $$.setMatrix(3, 3);
2218     }
2219     | F32MAT4 {
2220         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2221         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2222         $$.basicType = EbtFloat;
2223         $$.setMatrix(4, 4);
2224     }
2225     | F32MAT2X2 {
2226         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2227         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2228         $$.basicType = EbtFloat;
2229         $$.setMatrix(2, 2);
2230     }
2231     | F32MAT2X3 {
2232         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2233         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2234         $$.basicType = EbtFloat;
2235         $$.setMatrix(2, 3);
2236     }
2237     | F32MAT2X4 {
2238         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2239         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2240         $$.basicType = EbtFloat;
2241         $$.setMatrix(2, 4);
2242     }
2243     | F32MAT3X2 {
2244         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2245         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2246         $$.basicType = EbtFloat;
2247         $$.setMatrix(3, 2);
2248     }
2249     | F32MAT3X3 {
2250         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2251         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2252         $$.basicType = EbtFloat;
2253         $$.setMatrix(3, 3);
2254     }
2255     | F32MAT3X4 {
2256         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2257         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2258         $$.basicType = EbtFloat;
2259         $$.setMatrix(3, 4);
2260     }
2261     | F32MAT4X2 {
2262         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2263         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2264         $$.basicType = EbtFloat;
2265         $$.setMatrix(4, 2);
2266     }
2267     | F32MAT4X3 {
2268         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2269         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2270         $$.basicType = EbtFloat;
2271         $$.setMatrix(4, 3);
2272     }
2273     | F32MAT4X4 {
2274         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2275         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2276         $$.basicType = EbtFloat;
2277         $$.setMatrix(4, 4);
2278     }
2279     | F64MAT2 {
2280         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2281         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2282         $$.basicType = EbtDouble;
2283         $$.setMatrix(2, 2);
2284     }
2285     | F64MAT3 {
2286         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2287         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2288         $$.basicType = EbtDouble;
2289         $$.setMatrix(3, 3);
2290     }
2291     | F64MAT4 {
2292         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2293         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2294         $$.basicType = EbtDouble;
2295         $$.setMatrix(4, 4);
2296     }
2297     | F64MAT2X2 {
2298         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2299         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2300         $$.basicType = EbtDouble;
2301         $$.setMatrix(2, 2);
2302     }
2303     | F64MAT2X3 {
2304         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2305         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2306         $$.basicType = EbtDouble;
2307         $$.setMatrix(2, 3);
2308     }
2309     | F64MAT2X4 {
2310         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2311         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2312         $$.basicType = EbtDouble;
2313         $$.setMatrix(2, 4);
2314     }
2315     | F64MAT3X2 {
2316         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2317         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2318         $$.basicType = EbtDouble;
2319         $$.setMatrix(3, 2);
2320     }
2321     | F64MAT3X3 {
2322         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2323         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2324         $$.basicType = EbtDouble;
2325         $$.setMatrix(3, 3);
2326     }
2327     | F64MAT3X4 {
2328         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2329         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2330         $$.basicType = EbtDouble;
2331         $$.setMatrix(3, 4);
2332     }
2333     | F64MAT4X2 {
2334         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2335         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2336         $$.basicType = EbtDouble;
2337         $$.setMatrix(4, 2);
2338     }
2339     | F64MAT4X3 {
2340         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2341         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2342         $$.basicType = EbtDouble;
2343         $$.setMatrix(4, 3);
2344     }
2345     | F64MAT4X4 {
2346         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2347         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2348         $$.basicType = EbtDouble;
2349         $$.setMatrix(4, 4);
2350     }
2351     | ACCSTRUCTNV {
2352        $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2353        $$.basicType = EbtAccStructNV;
2354     }
2355     | ATOMIC_UINT {
2356         parseContext.vulkanRemoved($1.loc, "atomic counter types");
2357         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2358         $$.basicType = EbtAtomicUint;
2359     }
2360     | SAMPLER1D {
2361         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2362         $$.basicType = EbtSampler;
2363         $$.sampler.set(EbtFloat, Esd1D);
2364     }
2365
2366     | SAMPLER2D {
2367         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2368         $$.basicType = EbtSampler;
2369         $$.sampler.set(EbtFloat, Esd2D);
2370     }
2371     | SAMPLER3D {
2372         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2373         $$.basicType = EbtSampler;
2374         $$.sampler.set(EbtFloat, Esd3D);
2375     }
2376     | SAMPLERCUBE {
2377         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2378         $$.basicType = EbtSampler;
2379         $$.sampler.set(EbtFloat, EsdCube);
2380     }
2381     | SAMPLER2DSHADOW {
2382         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2383         $$.basicType = EbtSampler;
2384         $$.sampler.set(EbtFloat, Esd2D, false, true);
2385     }
2386     | SAMPLERCUBESHADOW {
2387         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2388         $$.basicType = EbtSampler;
2389         $$.sampler.set(EbtFloat, EsdCube, false, true);
2390     }
2391     | SAMPLER2DARRAY {
2392         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2393         $$.basicType = EbtSampler;
2394         $$.sampler.set(EbtFloat, Esd2D, true);
2395     }
2396     | SAMPLER2DARRAYSHADOW {
2397         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2398         $$.basicType = EbtSampler;
2399         $$.sampler.set(EbtFloat, Esd2D, true, true);
2400     }
2401
2402     | SAMPLER1DSHADOW {
2403         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2404         $$.basicType = EbtSampler;
2405         $$.sampler.set(EbtFloat, Esd1D, false, true);
2406     }
2407     | SAMPLER1DARRAY {
2408         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2409         $$.basicType = EbtSampler;
2410         $$.sampler.set(EbtFloat, Esd1D, true);
2411     }
2412     | SAMPLER1DARRAYSHADOW {
2413         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2414         $$.basicType = EbtSampler;
2415         $$.sampler.set(EbtFloat, Esd1D, true, true);
2416     }
2417     | SAMPLERCUBEARRAY {
2418         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2419         $$.basicType = EbtSampler;
2420         $$.sampler.set(EbtFloat, EsdCube, true);
2421     }
2422     | SAMPLERCUBEARRAYSHADOW {
2423         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2424         $$.basicType = EbtSampler;
2425         $$.sampler.set(EbtFloat, EsdCube, true, true);
2426     }
2427     | F16SAMPLER1D {
2428         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2429         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2430         $$.basicType = EbtSampler;
2431         $$.sampler.set(EbtFloat16, Esd1D);
2432     }
2433     | F16SAMPLER2D {
2434         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2435         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2436         $$.basicType = EbtSampler;
2437         $$.sampler.set(EbtFloat16, Esd2D);
2438     }
2439     | F16SAMPLER3D {
2440         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2441         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2442         $$.basicType = EbtSampler;
2443         $$.sampler.set(EbtFloat16, Esd3D);
2444     }
2445     | F16SAMPLERCUBE {
2446         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2447         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2448         $$.basicType = EbtSampler;
2449         $$.sampler.set(EbtFloat16, EsdCube);
2450     }
2451     | F16SAMPLER1DSHADOW {
2452         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2453         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2454         $$.basicType = EbtSampler;
2455         $$.sampler.set(EbtFloat16, Esd1D, false, true);
2456     }
2457     | F16SAMPLER2DSHADOW {
2458         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2459         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2460         $$.basicType = EbtSampler;
2461         $$.sampler.set(EbtFloat16, Esd2D, false, true);
2462     }
2463     | F16SAMPLERCUBESHADOW {
2464         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2465         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2466         $$.basicType = EbtSampler;
2467         $$.sampler.set(EbtFloat16, EsdCube, false, true);
2468     }
2469     | F16SAMPLER1DARRAY {
2470         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2471         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2472         $$.basicType = EbtSampler;
2473         $$.sampler.set(EbtFloat16, Esd1D, true);
2474     }
2475     | F16SAMPLER2DARRAY {
2476         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2477         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2478         $$.basicType = EbtSampler;
2479         $$.sampler.set(EbtFloat16, Esd2D, true);
2480     }
2481     | F16SAMPLER1DARRAYSHADOW {
2482         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2483         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2484         $$.basicType = EbtSampler;
2485         $$.sampler.set(EbtFloat16, Esd1D, true, true);
2486     }
2487     | F16SAMPLER2DARRAYSHADOW {
2488         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2489         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2490         $$.basicType = EbtSampler;
2491         $$.sampler.set(EbtFloat16, Esd2D, true, true);
2492     }
2493     | F16SAMPLERCUBEARRAY {
2494         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2495         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2496         $$.basicType = EbtSampler;
2497         $$.sampler.set(EbtFloat16, EsdCube, true);
2498     }
2499     | F16SAMPLERCUBEARRAYSHADOW {
2500         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2501         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2502         $$.basicType = EbtSampler;
2503         $$.sampler.set(EbtFloat16, EsdCube, true, true);
2504     }
2505     | ISAMPLER1D {
2506         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2507         $$.basicType = EbtSampler;
2508         $$.sampler.set(EbtInt, Esd1D);
2509     }
2510
2511     | ISAMPLER2D {
2512         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2513         $$.basicType = EbtSampler;
2514         $$.sampler.set(EbtInt, Esd2D);
2515     }
2516     | ISAMPLER3D {
2517         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2518         $$.basicType = EbtSampler;
2519         $$.sampler.set(EbtInt, Esd3D);
2520     }
2521     | ISAMPLERCUBE {
2522         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2523         $$.basicType = EbtSampler;
2524         $$.sampler.set(EbtInt, EsdCube);
2525     }
2526     | ISAMPLER2DARRAY {
2527         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2528         $$.basicType = EbtSampler;
2529         $$.sampler.set(EbtInt, Esd2D, true);
2530     }
2531     | USAMPLER2D {
2532         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2533         $$.basicType = EbtSampler;
2534         $$.sampler.set(EbtUint, Esd2D);
2535     }
2536     | USAMPLER3D {
2537         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2538         $$.basicType = EbtSampler;
2539         $$.sampler.set(EbtUint, Esd3D);
2540     }
2541     | USAMPLERCUBE {
2542         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2543         $$.basicType = EbtSampler;
2544         $$.sampler.set(EbtUint, EsdCube);
2545     }
2546
2547     | ISAMPLER1DARRAY {
2548         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2549         $$.basicType = EbtSampler;
2550         $$.sampler.set(EbtInt, Esd1D, true);
2551     }
2552     | ISAMPLERCUBEARRAY {
2553         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2554         $$.basicType = EbtSampler;
2555         $$.sampler.set(EbtInt, EsdCube, true);
2556     }
2557     | USAMPLER1D {
2558         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2559         $$.basicType = EbtSampler;
2560         $$.sampler.set(EbtUint, Esd1D);
2561     }
2562     | USAMPLER1DARRAY {
2563         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2564         $$.basicType = EbtSampler;
2565         $$.sampler.set(EbtUint, Esd1D, true);
2566     }
2567     | USAMPLERCUBEARRAY {
2568         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2569         $$.basicType = EbtSampler;
2570         $$.sampler.set(EbtUint, EsdCube, true);
2571     }
2572     | TEXTURECUBEARRAY {
2573         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2574         $$.basicType = EbtSampler;
2575         $$.sampler.setTexture(EbtFloat, EsdCube, true);
2576     }
2577     | ITEXTURECUBEARRAY {
2578         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2579         $$.basicType = EbtSampler;
2580         $$.sampler.setTexture(EbtInt, EsdCube, true);
2581     }
2582     | UTEXTURECUBEARRAY {
2583         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2584         $$.basicType = EbtSampler;
2585         $$.sampler.setTexture(EbtUint, EsdCube, true);
2586     }
2587
2588     | USAMPLER2DARRAY {
2589         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2590         $$.basicType = EbtSampler;
2591         $$.sampler.set(EbtUint, Esd2D, true);
2592     }
2593     | TEXTURE2D {
2594         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2595         $$.basicType = EbtSampler;
2596         $$.sampler.setTexture(EbtFloat, Esd2D);
2597     }
2598     | TEXTURE3D {
2599         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2600         $$.basicType = EbtSampler;
2601         $$.sampler.setTexture(EbtFloat, Esd3D);
2602     }
2603     | TEXTURE2DARRAY {
2604         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2605         $$.basicType = EbtSampler;
2606         $$.sampler.setTexture(EbtFloat, Esd2D, true);
2607     }
2608     | TEXTURECUBE {
2609         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2610         $$.basicType = EbtSampler;
2611         $$.sampler.setTexture(EbtFloat, EsdCube);
2612     }
2613     | ITEXTURE2D {
2614         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2615         $$.basicType = EbtSampler;
2616         $$.sampler.setTexture(EbtInt, Esd2D);
2617     }
2618     | ITEXTURE3D {
2619         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2620         $$.basicType = EbtSampler;
2621         $$.sampler.setTexture(EbtInt, Esd3D);
2622     }
2623     | ITEXTURECUBE {
2624         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2625         $$.basicType = EbtSampler;
2626         $$.sampler.setTexture(EbtInt, EsdCube);
2627     }
2628     | ITEXTURE2DARRAY {
2629         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2630         $$.basicType = EbtSampler;
2631         $$.sampler.setTexture(EbtInt, Esd2D, true);
2632     }
2633     | UTEXTURE2D {
2634         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2635         $$.basicType = EbtSampler;
2636         $$.sampler.setTexture(EbtUint, Esd2D);
2637     }
2638     | UTEXTURE3D {
2639         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2640         $$.basicType = EbtSampler;
2641         $$.sampler.setTexture(EbtUint, Esd3D);
2642     }
2643     | UTEXTURECUBE {
2644         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2645         $$.basicType = EbtSampler;
2646         $$.sampler.setTexture(EbtUint, EsdCube);
2647     }
2648     | UTEXTURE2DARRAY {
2649         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2650         $$.basicType = EbtSampler;
2651         $$.sampler.setTexture(EbtUint, Esd2D, true);
2652     }
2653     | SAMPLER {
2654         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2655         $$.basicType = EbtSampler;
2656         $$.sampler.setPureSampler(false);
2657     }
2658     | SAMPLERSHADOW {
2659         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2660         $$.basicType = EbtSampler;
2661         $$.sampler.setPureSampler(true);
2662     }
2663
2664     | SAMPLER2DRECT {
2665         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2666         $$.basicType = EbtSampler;
2667         $$.sampler.set(EbtFloat, EsdRect);
2668     }
2669     | SAMPLER2DRECTSHADOW {
2670         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2671         $$.basicType = EbtSampler;
2672         $$.sampler.set(EbtFloat, EsdRect, false, true);
2673     }
2674     | F16SAMPLER2DRECT {
2675         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2676         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2677         $$.basicType = EbtSampler;
2678         $$.sampler.set(EbtFloat16, EsdRect);
2679     }
2680     | F16SAMPLER2DRECTSHADOW {
2681         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2682         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2683         $$.basicType = EbtSampler;
2684         $$.sampler.set(EbtFloat16, EsdRect, false, true);
2685     }
2686     | ISAMPLER2DRECT {
2687         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2688         $$.basicType = EbtSampler;
2689         $$.sampler.set(EbtInt, EsdRect);
2690     }
2691     | USAMPLER2DRECT {
2692         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2693         $$.basicType = EbtSampler;
2694         $$.sampler.set(EbtUint, EsdRect);
2695     }
2696     | SAMPLERBUFFER {
2697         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2698         $$.basicType = EbtSampler;
2699         $$.sampler.set(EbtFloat, EsdBuffer);
2700     }
2701     | F16SAMPLERBUFFER {
2702         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2703         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2704         $$.basicType = EbtSampler;
2705         $$.sampler.set(EbtFloat16, EsdBuffer);
2706     }
2707     | ISAMPLERBUFFER {
2708         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2709         $$.basicType = EbtSampler;
2710         $$.sampler.set(EbtInt, EsdBuffer);
2711     }
2712     | USAMPLERBUFFER {
2713         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2714         $$.basicType = EbtSampler;
2715         $$.sampler.set(EbtUint, EsdBuffer);
2716     }
2717     | SAMPLER2DMS {
2718         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2719         $$.basicType = EbtSampler;
2720         $$.sampler.set(EbtFloat, Esd2D, false, false, true);
2721     }
2722     | F16SAMPLER2DMS {
2723         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2724         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2725         $$.basicType = EbtSampler;
2726         $$.sampler.set(EbtFloat16, Esd2D, false, false, true);
2727     }
2728     | ISAMPLER2DMS {
2729         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2730         $$.basicType = EbtSampler;
2731         $$.sampler.set(EbtInt, Esd2D, false, false, true);
2732     }
2733     | USAMPLER2DMS {
2734         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2735         $$.basicType = EbtSampler;
2736         $$.sampler.set(EbtUint, Esd2D, false, false, true);
2737     }
2738     | SAMPLER2DMSARRAY {
2739         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2740         $$.basicType = EbtSampler;
2741         $$.sampler.set(EbtFloat, Esd2D, true, false, true);
2742     }
2743     | F16SAMPLER2DMSARRAY {
2744         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2745         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2746         $$.basicType = EbtSampler;
2747         $$.sampler.set(EbtFloat16, Esd2D, true, false, true);
2748     }
2749     | ISAMPLER2DMSARRAY {
2750         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2751         $$.basicType = EbtSampler;
2752         $$.sampler.set(EbtInt, Esd2D, true, false, true);
2753     }
2754     | USAMPLER2DMSARRAY {
2755         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2756         $$.basicType = EbtSampler;
2757         $$.sampler.set(EbtUint, Esd2D, true, false, true);
2758     }
2759     | TEXTURE1D {
2760         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2761         $$.basicType = EbtSampler;
2762         $$.sampler.setTexture(EbtFloat, Esd1D);
2763     }
2764     | F16TEXTURE1D {
2765         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2766         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2767         $$.basicType = EbtSampler;
2768         $$.sampler.setTexture(EbtFloat16, Esd1D);
2769     }
2770     | F16TEXTURE2D {
2771         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2772         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2773         $$.basicType = EbtSampler;
2774         $$.sampler.setTexture(EbtFloat16, Esd2D);
2775     }
2776     | F16TEXTURE3D {
2777         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2778         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2779         $$.basicType = EbtSampler;
2780         $$.sampler.setTexture(EbtFloat16, Esd3D);
2781     }
2782     | F16TEXTURECUBE {
2783         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2784         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2785         $$.basicType = EbtSampler;
2786         $$.sampler.setTexture(EbtFloat16, EsdCube);
2787     }
2788     | TEXTURE1DARRAY {
2789         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2790         $$.basicType = EbtSampler;
2791         $$.sampler.setTexture(EbtFloat, Esd1D, true);
2792     }
2793     | F16TEXTURE1DARRAY {
2794         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2795         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2796         $$.basicType = EbtSampler;
2797         $$.sampler.setTexture(EbtFloat16, Esd1D, true);
2798     }
2799     | F16TEXTURE2DARRAY {
2800         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2801         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2802         $$.basicType = EbtSampler;
2803         $$.sampler.setTexture(EbtFloat16, Esd2D, true);
2804     }
2805     | F16TEXTURECUBEARRAY {
2806         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2807         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2808         $$.basicType = EbtSampler;
2809         $$.sampler.setTexture(EbtFloat16, EsdCube, true);
2810     }
2811     | ITEXTURE1D {
2812         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2813         $$.basicType = EbtSampler;
2814         $$.sampler.setTexture(EbtInt, Esd1D);
2815     }
2816     | ITEXTURE1DARRAY {
2817         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2818         $$.basicType = EbtSampler;
2819         $$.sampler.setTexture(EbtInt, Esd1D, true);
2820     }
2821     | UTEXTURE1D {
2822         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2823         $$.basicType = EbtSampler;
2824         $$.sampler.setTexture(EbtUint, Esd1D);
2825     }
2826     | UTEXTURE1DARRAY {
2827         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2828         $$.basicType = EbtSampler;
2829         $$.sampler.setTexture(EbtUint, Esd1D, true);
2830     }
2831     | TEXTURE2DRECT {
2832         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2833         $$.basicType = EbtSampler;
2834         $$.sampler.setTexture(EbtFloat, EsdRect);
2835     }
2836     | F16TEXTURE2DRECT {
2837         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2838         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2839         $$.basicType = EbtSampler;
2840         $$.sampler.setTexture(EbtFloat16, EsdRect);
2841     }
2842     | ITEXTURE2DRECT {
2843         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2844         $$.basicType = EbtSampler;
2845         $$.sampler.setTexture(EbtInt, EsdRect);
2846     }
2847     | UTEXTURE2DRECT {
2848         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2849         $$.basicType = EbtSampler;
2850         $$.sampler.setTexture(EbtUint, EsdRect);
2851     }
2852     | TEXTUREBUFFER {
2853         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2854         $$.basicType = EbtSampler;
2855         $$.sampler.setTexture(EbtFloat, EsdBuffer);
2856     }
2857     | F16TEXTUREBUFFER {
2858         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2859         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2860         $$.basicType = EbtSampler;
2861         $$.sampler.setTexture(EbtFloat16, EsdBuffer);
2862     }
2863     | ITEXTUREBUFFER {
2864         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2865         $$.basicType = EbtSampler;
2866         $$.sampler.setTexture(EbtInt, EsdBuffer);
2867     }
2868     | UTEXTUREBUFFER {
2869         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2870         $$.basicType = EbtSampler;
2871         $$.sampler.setTexture(EbtUint, EsdBuffer);
2872     }
2873     | TEXTURE2DMS {
2874         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2875         $$.basicType = EbtSampler;
2876         $$.sampler.setTexture(EbtFloat, Esd2D, false, false, true);
2877     }
2878     | F16TEXTURE2DMS {
2879         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2880         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2881         $$.basicType = EbtSampler;
2882         $$.sampler.setTexture(EbtFloat16, Esd2D, false, false, true);
2883     }
2884     | ITEXTURE2DMS {
2885         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2886         $$.basicType = EbtSampler;
2887         $$.sampler.setTexture(EbtInt, Esd2D, false, false, true);
2888     }
2889     | UTEXTURE2DMS {
2890         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2891         $$.basicType = EbtSampler;
2892         $$.sampler.setTexture(EbtUint, Esd2D, false, false, true);
2893     }
2894     | TEXTURE2DMSARRAY {
2895         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2896         $$.basicType = EbtSampler;
2897         $$.sampler.setTexture(EbtFloat, Esd2D, true, false, true);
2898     }
2899     | F16TEXTURE2DMSARRAY {
2900         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2901         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2902         $$.basicType = EbtSampler;
2903         $$.sampler.setTexture(EbtFloat16, Esd2D, true, false, true);
2904     }
2905     | ITEXTURE2DMSARRAY {
2906         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2907         $$.basicType = EbtSampler;
2908         $$.sampler.setTexture(EbtInt, Esd2D, true, false, true);
2909     }
2910     | UTEXTURE2DMSARRAY {
2911         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2912         $$.basicType = EbtSampler;
2913         $$.sampler.setTexture(EbtUint, Esd2D, true, false, true);
2914     }
2915     | IMAGE1D {
2916         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2917         $$.basicType = EbtSampler;
2918         $$.sampler.setImage(EbtFloat, Esd1D);
2919     }
2920     | F16IMAGE1D {
2921         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
2922         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2923         $$.basicType = EbtSampler;
2924         $$.sampler.setImage(EbtFloat16, Esd1D);
2925     }
2926     | IIMAGE1D {
2927         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2928         $$.basicType = EbtSampler;
2929         $$.sampler.setImage(EbtInt, Esd1D);
2930     }
2931     | UIMAGE1D {
2932         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2933         $$.basicType = EbtSampler;
2934         $$.sampler.setImage(EbtUint, Esd1D);
2935     }
2936     | IMAGE2D {
2937         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2938         $$.basicType = EbtSampler;
2939         $$.sampler.setImage(EbtFloat, Esd2D);
2940     }
2941     | F16IMAGE2D {
2942         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
2943         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2944         $$.basicType = EbtSampler;
2945         $$.sampler.setImage(EbtFloat16, Esd2D);
2946     }
2947     | IIMAGE2D {
2948         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2949         $$.basicType = EbtSampler;
2950         $$.sampler.setImage(EbtInt, Esd2D);
2951     }
2952     | UIMAGE2D {
2953         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2954         $$.basicType = EbtSampler;
2955         $$.sampler.setImage(EbtUint, Esd2D);
2956     }
2957     | IMAGE3D {
2958         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2959         $$.basicType = EbtSampler;
2960         $$.sampler.setImage(EbtFloat, Esd3D);
2961     }
2962     | F16IMAGE3D {
2963         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
2964         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2965         $$.basicType = EbtSampler;
2966         $$.sampler.setImage(EbtFloat16, Esd3D);
2967     }
2968     | IIMAGE3D {
2969         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2970         $$.basicType = EbtSampler;
2971         $$.sampler.setImage(EbtInt, Esd3D);
2972     }
2973     | UIMAGE3D {
2974         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2975         $$.basicType = EbtSampler;
2976         $$.sampler.setImage(EbtUint, Esd3D);
2977     }
2978     | IMAGE2DRECT {
2979         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2980         $$.basicType = EbtSampler;
2981         $$.sampler.setImage(EbtFloat, EsdRect);
2982     }
2983     | F16IMAGE2DRECT {
2984         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
2985         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2986         $$.basicType = EbtSampler;
2987         $$.sampler.setImage(EbtFloat16, EsdRect);
2988     }
2989     | IIMAGE2DRECT {
2990         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2991         $$.basicType = EbtSampler;
2992         $$.sampler.setImage(EbtInt, EsdRect);
2993     }
2994     | UIMAGE2DRECT {
2995         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2996         $$.basicType = EbtSampler;
2997         $$.sampler.setImage(EbtUint, EsdRect);
2998     }
2999     | IMAGECUBE {
3000         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3001         $$.basicType = EbtSampler;
3002         $$.sampler.setImage(EbtFloat, EsdCube);
3003     }
3004     | F16IMAGECUBE {
3005         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3006         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3007         $$.basicType = EbtSampler;
3008         $$.sampler.setImage(EbtFloat16, EsdCube);
3009     }
3010     | IIMAGECUBE {
3011         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3012         $$.basicType = EbtSampler;
3013         $$.sampler.setImage(EbtInt, EsdCube);
3014     }
3015     | UIMAGECUBE {
3016         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3017         $$.basicType = EbtSampler;
3018         $$.sampler.setImage(EbtUint, EsdCube);
3019     }
3020     | IMAGEBUFFER {
3021         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3022         $$.basicType = EbtSampler;
3023         $$.sampler.setImage(EbtFloat, EsdBuffer);
3024     }
3025     | F16IMAGEBUFFER {
3026         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3027         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3028         $$.basicType = EbtSampler;
3029         $$.sampler.setImage(EbtFloat16, EsdBuffer);
3030     }
3031     | IIMAGEBUFFER {
3032         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3033         $$.basicType = EbtSampler;
3034         $$.sampler.setImage(EbtInt, EsdBuffer);
3035     }
3036     | UIMAGEBUFFER {
3037         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3038         $$.basicType = EbtSampler;
3039         $$.sampler.setImage(EbtUint, EsdBuffer);
3040     }
3041     | IMAGE1DARRAY {
3042         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3043         $$.basicType = EbtSampler;
3044         $$.sampler.setImage(EbtFloat, Esd1D, true);
3045     }
3046     | F16IMAGE1DARRAY {
3047         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3048         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3049         $$.basicType = EbtSampler;
3050         $$.sampler.setImage(EbtFloat16, Esd1D, true);
3051     }
3052     | IIMAGE1DARRAY {
3053         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3054         $$.basicType = EbtSampler;
3055         $$.sampler.setImage(EbtInt, Esd1D, true);
3056     }
3057     | UIMAGE1DARRAY {
3058         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3059         $$.basicType = EbtSampler;
3060         $$.sampler.setImage(EbtUint, Esd1D, true);
3061     }
3062     | IMAGE2DARRAY {
3063         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3064         $$.basicType = EbtSampler;
3065         $$.sampler.setImage(EbtFloat, Esd2D, true);
3066     }
3067     | F16IMAGE2DARRAY {
3068         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3069         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3070         $$.basicType = EbtSampler;
3071         $$.sampler.setImage(EbtFloat16, Esd2D, true);
3072     }
3073     | IIMAGE2DARRAY {
3074         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3075         $$.basicType = EbtSampler;
3076         $$.sampler.setImage(EbtInt, Esd2D, true);
3077     }
3078     | UIMAGE2DARRAY {
3079         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3080         $$.basicType = EbtSampler;
3081         $$.sampler.setImage(EbtUint, Esd2D, true);
3082     }
3083     | IMAGECUBEARRAY {
3084         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3085         $$.basicType = EbtSampler;
3086         $$.sampler.setImage(EbtFloat, EsdCube, true);
3087     }
3088     | F16IMAGECUBEARRAY {
3089         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3090         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3091         $$.basicType = EbtSampler;
3092         $$.sampler.setImage(EbtFloat16, EsdCube, true);
3093     }
3094     | IIMAGECUBEARRAY {
3095         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3096         $$.basicType = EbtSampler;
3097         $$.sampler.setImage(EbtInt, EsdCube, true);
3098     }
3099     | UIMAGECUBEARRAY {
3100         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3101         $$.basicType = EbtSampler;
3102         $$.sampler.setImage(EbtUint, EsdCube, true);
3103     }
3104     | IMAGE2DMS {
3105         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3106         $$.basicType = EbtSampler;
3107         $$.sampler.setImage(EbtFloat, Esd2D, false, false, true);
3108     }
3109     | F16IMAGE2DMS {
3110         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3111         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3112         $$.basicType = EbtSampler;
3113         $$.sampler.setImage(EbtFloat16, Esd2D, false, false, true);
3114     }
3115     | IIMAGE2DMS {
3116         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3117         $$.basicType = EbtSampler;
3118         $$.sampler.setImage(EbtInt, Esd2D, false, false, true);
3119     }
3120     | UIMAGE2DMS {
3121         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3122         $$.basicType = EbtSampler;
3123         $$.sampler.setImage(EbtUint, Esd2D, false, false, true);
3124     }
3125     | IMAGE2DMSARRAY {
3126         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3127         $$.basicType = EbtSampler;
3128         $$.sampler.setImage(EbtFloat, Esd2D, true, false, true);
3129     }
3130     | F16IMAGE2DMSARRAY {
3131         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3132         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3133         $$.basicType = EbtSampler;
3134         $$.sampler.setImage(EbtFloat16, Esd2D, true, false, true);
3135     }
3136     | IIMAGE2DMSARRAY {
3137         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3138         $$.basicType = EbtSampler;
3139         $$.sampler.setImage(EbtInt, Esd2D, true, false, true);
3140     }
3141     | UIMAGE2DMSARRAY {
3142         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3143         $$.basicType = EbtSampler;
3144         $$.sampler.setImage(EbtUint, Esd2D, true, false, true);
3145     }
3146     | SAMPLEREXTERNALOES {  // GL_OES_EGL_image_external
3147         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3148         $$.basicType = EbtSampler;
3149         $$.sampler.set(EbtFloat, Esd2D);
3150         $$.sampler.external = true;
3151     }
3152     | SAMPLEREXTERNAL2DY2YEXT { // GL_EXT_YUV_target
3153         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3154         $$.basicType = EbtSampler;
3155         $$.sampler.set(EbtFloat, Esd2D);
3156         $$.sampler.yuv = true;
3157     }
3158     | SUBPASSINPUT {
3159         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3160         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3161         $$.basicType = EbtSampler;
3162         $$.sampler.setSubpass(EbtFloat);
3163     }
3164     | SUBPASSINPUTMS {
3165         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3166         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3167         $$.basicType = EbtSampler;
3168         $$.sampler.setSubpass(EbtFloat, true);
3169     }
3170     | F16SUBPASSINPUT {
3171         parseContext.float16OpaqueCheck($1.loc, "half float subpass input", parseContext.symbolTable.atBuiltInLevel());
3172         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3173         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3174         $$.basicType = EbtSampler;
3175         $$.sampler.setSubpass(EbtFloat16);
3176     }
3177     | F16SUBPASSINPUTMS {
3178         parseContext.float16OpaqueCheck($1.loc, "half float subpass input", parseContext.symbolTable.atBuiltInLevel());
3179         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3180         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3181         $$.basicType = EbtSampler;
3182         $$.sampler.setSubpass(EbtFloat16, true);
3183     }
3184     | ISUBPASSINPUT {
3185         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3186         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3187         $$.basicType = EbtSampler;
3188         $$.sampler.setSubpass(EbtInt);
3189     }
3190     | ISUBPASSINPUTMS {
3191         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3192         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3193         $$.basicType = EbtSampler;
3194         $$.sampler.setSubpass(EbtInt, true);
3195     }
3196     | USUBPASSINPUT {
3197         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3198         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3199         $$.basicType = EbtSampler;
3200         $$.sampler.setSubpass(EbtUint);
3201     }
3202     | USUBPASSINPUTMS {
3203         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3204         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3205         $$.basicType = EbtSampler;
3206         $$.sampler.setSubpass(EbtUint, true);
3207     }
3208     | FCOOPMATNV {
3209         parseContext.fcoopmatCheck($1.loc, "fcoopmatNV", parseContext.symbolTable.atBuiltInLevel());
3210         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3211         $$.basicType = EbtFloat;
3212         $$.coopmat = true;
3213     }
3214     | ICOOPMATNV {
3215         parseContext.intcoopmatCheck($1.loc, "icoopmatNV", parseContext.symbolTable.atBuiltInLevel());
3216         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3217         $$.basicType = EbtInt;
3218         $$.coopmat = true;
3219     }
3220     | UCOOPMATNV {
3221         parseContext.intcoopmatCheck($1.loc, "ucoopmatNV", parseContext.symbolTable.atBuiltInLevel());
3222         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3223         $$.basicType = EbtUint;
3224         $$.coopmat = true;
3225     }
3226
3227     | struct_specifier {
3228         $$ = $1;
3229         $$.qualifier.storage = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
3230         parseContext.structTypeCheck($$.loc, $$);
3231     }
3232     | TYPE_NAME {
3233         //
3234         // This is for user defined type names.  The lexical phase looked up the
3235         // type.
3236         //
3237         if (const TVariable* variable = ($1.symbol)->getAsVariable()) {
3238             const TType& structure = variable->getType();
3239             $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3240             $$.basicType = EbtStruct;
3241             $$.userDef = &structure;
3242         } else
3243             parseContext.error($1.loc, "expected type name", $1.string->c_str(), "");
3244     }
3245     ;
3246
3247 precision_qualifier
3248     : HIGH_PRECISION {
3249         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "highp precision qualifier");
3250         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3251         parseContext.handlePrecisionQualifier($1.loc, $$.qualifier, EpqHigh);
3252     }
3253     | MEDIUM_PRECISION {
3254         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "mediump precision qualifier");
3255         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3256         parseContext.handlePrecisionQualifier($1.loc, $$.qualifier, EpqMedium);
3257     }
3258     | LOW_PRECISION {
3259         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "lowp precision qualifier");
3260         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3261         parseContext.handlePrecisionQualifier($1.loc, $$.qualifier, EpqLow);
3262     }
3263     ;
3264
3265 struct_specifier
3266     : STRUCT IDENTIFIER LEFT_BRACE { parseContext.nestedStructCheck($1.loc); } struct_declaration_list RIGHT_BRACE {
3267         TType* structure = new TType($5, *$2.string);
3268         parseContext.structArrayCheck($2.loc, *structure);
3269         TVariable* userTypeDef = new TVariable($2.string, *structure, true);
3270         if (! parseContext.symbolTable.insert(*userTypeDef))
3271             parseContext.error($2.loc, "redefinition", $2.string->c_str(), "struct");
3272         $$.init($1.loc);
3273         $$.basicType = EbtStruct;
3274         $$.userDef = structure;
3275         --parseContext.structNestingLevel;
3276     }
3277     | STRUCT LEFT_BRACE { parseContext.nestedStructCheck($1.loc); } struct_declaration_list RIGHT_BRACE {
3278         TType* structure = new TType($4, TString(""));
3279         $$.init($1.loc);
3280         $$.basicType = EbtStruct;
3281         $$.userDef = structure;
3282         --parseContext.structNestingLevel;
3283     }
3284     ;
3285
3286 struct_declaration_list
3287     : struct_declaration {
3288         $$ = $1;
3289     }
3290     | struct_declaration_list struct_declaration {
3291         $$ = $1;
3292         for (unsigned int i = 0; i < $2->size(); ++i) {
3293             for (unsigned int j = 0; j < $$->size(); ++j) {
3294                 if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName())
3295                     parseContext.error((*$2)[i].loc, "duplicate member name:", "", (*$2)[i].type->getFieldName().c_str());
3296             }
3297             $$->push_back((*$2)[i]);
3298         }
3299     }
3300     ;
3301
3302 struct_declaration
3303     : type_specifier struct_declarator_list SEMICOLON {
3304         if ($1.arraySizes) {
3305             parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
3306             parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
3307             if (parseContext.isEsProfile())
3308                 parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
3309         }
3310
3311         $$ = $2;
3312
3313         parseContext.voidErrorCheck($1.loc, (*$2)[0].type->getFieldName(), $1.basicType);
3314         parseContext.precisionQualifierCheck($1.loc, $1.basicType, $1.qualifier);
3315
3316         for (unsigned int i = 0; i < $$->size(); ++i) {
3317             TType type($1);
3318             type.setFieldName((*$$)[i].type->getFieldName());
3319             type.transferArraySizes((*$$)[i].type->getArraySizes());
3320             type.copyArrayInnerSizes($1.arraySizes);
3321             parseContext.arrayOfArrayVersionCheck((*$$)[i].loc, type.getArraySizes());
3322             (*$$)[i].type->shallowCopy(type);
3323         }
3324     }
3325     | type_qualifier type_specifier struct_declarator_list SEMICOLON {
3326         if ($2.arraySizes) {
3327             parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
3328             parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
3329             if (parseContext.isEsProfile())
3330                 parseContext.arraySizeRequiredCheck($2.loc, *$2.arraySizes);
3331         }
3332
3333         $$ = $3;
3334
3335         parseContext.memberQualifierCheck($1);
3336         parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType);
3337         parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true);
3338         parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
3339
3340         for (unsigned int i = 0; i < $$->size(); ++i) {
3341             TType type($2);
3342             type.setFieldName((*$$)[i].type->getFieldName());
3343             type.transferArraySizes((*$$)[i].type->getArraySizes());
3344             type.copyArrayInnerSizes($2.arraySizes);
3345             parseContext.arrayOfArrayVersionCheck((*$$)[i].loc, type.getArraySizes());
3346             (*$$)[i].type->shallowCopy(type);
3347         }
3348     }
3349     ;
3350
3351 struct_declarator_list
3352     : struct_declarator {
3353         $$ = new TTypeList;
3354         $$->push_back($1);
3355     }
3356     | struct_declarator_list COMMA struct_declarator {
3357         $$->push_back($3);
3358     }
3359     ;
3360
3361 struct_declarator
3362     : IDENTIFIER {
3363         $$.type = new TType(EbtVoid);
3364         $$.loc = $1.loc;
3365         $$.type->setFieldName(*$1.string);
3366     }
3367     | IDENTIFIER array_specifier {
3368         parseContext.arrayOfArrayVersionCheck($1.loc, $2.arraySizes);
3369
3370         $$.type = new TType(EbtVoid);
3371         $$.loc = $1.loc;
3372         $$.type->setFieldName(*$1.string);
3373         $$.type->transferArraySizes($2.arraySizes);
3374     }
3375     ;
3376
3377 initializer
3378     : assignment_expression {
3379         $$ = $1;
3380     }
3381
3382     | LEFT_BRACE initializer_list RIGHT_BRACE {
3383         const char* initFeature = "{ } style initializers";
3384         parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
3385         parseContext.profileRequires($1.loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, initFeature);
3386         $$ = $2;
3387     }
3388     | LEFT_BRACE initializer_list COMMA RIGHT_BRACE {
3389         const char* initFeature = "{ } style initializers";
3390         parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
3391         parseContext.profileRequires($1.loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, initFeature);
3392         $$ = $2;
3393     }
3394
3395     ;
3396
3397
3398 initializer_list
3399     : initializer {
3400         $$ = parseContext.intermediate.growAggregate(0, $1, $1->getLoc());
3401     }
3402     | initializer_list COMMA initializer {
3403         $$ = parseContext.intermediate.growAggregate($1, $3);
3404     }
3405     ;
3406
3407
3408 declaration_statement
3409     : declaration { $$ = $1; }
3410     ;
3411
3412 statement
3413     : compound_statement  { $$ = $1; }
3414     | simple_statement    { $$ = $1; }
3415     ;
3416
3417 // Grammar Note:  labeled statements for switch statements only; 'goto' is not supported.
3418
3419 simple_statement
3420     : declaration_statement { $$ = $1; }
3421     | expression_statement  { $$ = $1; }
3422     | selection_statement   { $$ = $1; }
3423     | switch_statement      { $$ = $1; }
3424     | case_label            { $$ = $1; }
3425     | iteration_statement   { $$ = $1; }
3426     | jump_statement        { $$ = $1; }
3427
3428     | demote_statement      { $$ = $1; }
3429
3430     ;
3431
3432
3433 demote_statement
3434     : DEMOTE SEMICOLON {
3435         parseContext.requireStage($1.loc, EShLangFragment, "demote");
3436         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_demote_to_helper_invocation, "demote");
3437         $$ = parseContext.intermediate.addBranch(EOpDemote, $1.loc);
3438     }
3439     ;
3440
3441
3442 compound_statement
3443     : LEFT_BRACE RIGHT_BRACE { $$ = 0; }
3444     | LEFT_BRACE {
3445         parseContext.symbolTable.push();
3446         ++parseContext.statementNestingLevel;
3447     }
3448       statement_list {
3449         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3450         --parseContext.statementNestingLevel;
3451     }
3452       RIGHT_BRACE {
3453         if ($3 && $3->getAsAggregate())
3454             $3->getAsAggregate()->setOperator(EOpSequence);
3455         $$ = $3;
3456     }
3457     ;
3458
3459 statement_no_new_scope
3460     : compound_statement_no_new_scope { $$ = $1; }
3461     | simple_statement                { $$ = $1; }
3462     ;
3463
3464 statement_scoped
3465     : {
3466         ++parseContext.controlFlowNestingLevel;
3467     }
3468       compound_statement  {
3469         --parseContext.controlFlowNestingLevel;
3470         $$ = $2;
3471     }
3472     | {
3473         parseContext.symbolTable.push();
3474         ++parseContext.statementNestingLevel;
3475         ++parseContext.controlFlowNestingLevel;
3476     }
3477       simple_statement {
3478         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3479         --parseContext.statementNestingLevel;
3480         --parseContext.controlFlowNestingLevel;
3481         $$ = $2;
3482     }
3483
3484 compound_statement_no_new_scope
3485     // Statement that doesn't create a new scope, for selection_statement, iteration_statement
3486     : LEFT_BRACE RIGHT_BRACE {
3487         $$ = 0;
3488     }
3489     | LEFT_BRACE statement_list RIGHT_BRACE {
3490         if ($2 && $2->getAsAggregate())
3491             $2->getAsAggregate()->setOperator(EOpSequence);
3492         $$ = $2;
3493     }
3494     ;
3495
3496 statement_list
3497     : statement {
3498         $$ = parseContext.intermediate.makeAggregate($1);
3499         if ($1 && $1->getAsBranchNode() && ($1->getAsBranchNode()->getFlowOp() == EOpCase ||
3500                                             $1->getAsBranchNode()->getFlowOp() == EOpDefault)) {
3501             parseContext.wrapupSwitchSubsequence(0, $1);
3502             $$ = 0;  // start a fresh subsequence for what's after this case
3503         }
3504     }
3505     | statement_list statement {
3506         if ($2 && $2->getAsBranchNode() && ($2->getAsBranchNode()->getFlowOp() == EOpCase ||
3507                                             $2->getAsBranchNode()->getFlowOp() == EOpDefault)) {
3508             parseContext.wrapupSwitchSubsequence($1 ? $1->getAsAggregate() : 0, $2);
3509             $$ = 0;  // start a fresh subsequence for what's after this case
3510         } else
3511             $$ = parseContext.intermediate.growAggregate($1, $2);
3512     }
3513     ;
3514
3515 expression_statement
3516     : SEMICOLON  { $$ = 0; }
3517     | expression SEMICOLON  { $$ = static_cast<TIntermNode*>($1); }
3518     ;
3519
3520 selection_statement
3521     : selection_statement_nonattributed {
3522         $$ = $1;
3523     }
3524
3525     | attribute selection_statement_nonattributed {
3526         parseContext.handleSelectionAttributes(*$1, $2);
3527         $$ = $2;
3528     }
3529
3530
3531 selection_statement_nonattributed
3532     : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement {
3533         parseContext.boolCheck($1.loc, $3);
3534         $$ = parseContext.intermediate.addSelection($3, $5, $1.loc);
3535     }
3536     ;
3537
3538 selection_rest_statement
3539     : statement_scoped ELSE statement_scoped {
3540         $$.node1 = $1;
3541         $$.node2 = $3;
3542     }
3543     | statement_scoped {
3544         $$.node1 = $1;
3545         $$.node2 = 0;
3546     }
3547     ;
3548
3549 condition
3550     // In 1996 c++ draft, conditions can include single declarations
3551     : expression {
3552         $$ = $1;
3553         parseContext.boolCheck($1->getLoc(), $1);
3554     }
3555     | fully_specified_type IDENTIFIER EQUAL initializer {
3556         parseContext.boolCheck($2.loc, $1);
3557
3558         TType type($1);
3559         TIntermNode* initNode = parseContext.declareVariable($2.loc, *$2.string, $1, 0, $4);
3560         if (initNode)
3561             $$ = initNode->getAsTyped();
3562         else
3563             $$ = 0;
3564     }
3565     ;
3566
3567 switch_statement
3568     : switch_statement_nonattributed {
3569         $$ = $1;
3570     }
3571
3572     | attribute switch_statement_nonattributed {
3573         parseContext.handleSwitchAttributes(*$1, $2);
3574         $$ = $2;
3575     }
3576
3577
3578 switch_statement_nonattributed
3579     : SWITCH LEFT_PAREN expression RIGHT_PAREN {
3580         // start new switch sequence on the switch stack
3581         ++parseContext.controlFlowNestingLevel;
3582         ++parseContext.statementNestingLevel;
3583         parseContext.switchSequenceStack.push_back(new TIntermSequence);
3584         parseContext.switchLevel.push_back(parseContext.statementNestingLevel);
3585         parseContext.symbolTable.push();
3586     }
3587     LEFT_BRACE switch_statement_list RIGHT_BRACE {
3588         $$ = parseContext.addSwitch($1.loc, $3, $7 ? $7->getAsAggregate() : 0);
3589         delete parseContext.switchSequenceStack.back();
3590         parseContext.switchSequenceStack.pop_back();
3591         parseContext.switchLevel.pop_back();
3592         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3593         --parseContext.statementNestingLevel;
3594         --parseContext.controlFlowNestingLevel;
3595     }
3596     ;
3597
3598 switch_statement_list
3599     : /* nothing */ {
3600         $$ = 0;
3601     }
3602     | statement_list {
3603         $$ = $1;
3604     }
3605     ;
3606
3607 case_label
3608     : CASE expression COLON {
3609         $$ = 0;
3610         if (parseContext.switchLevel.size() == 0)
3611             parseContext.error($1.loc, "cannot appear outside switch statement", "case", "");
3612         else if (parseContext.switchLevel.back() != parseContext.statementNestingLevel)
3613             parseContext.error($1.loc, "cannot be nested inside control flow", "case", "");
3614         else {
3615             parseContext.constantValueCheck($2, "case");
3616             parseContext.integerCheck($2, "case");
3617             $$ = parseContext.intermediate.addBranch(EOpCase, $2, $1.loc);
3618         }
3619     }
3620     | DEFAULT COLON {
3621         $$ = 0;
3622         if (parseContext.switchLevel.size() == 0)
3623             parseContext.error($1.loc, "cannot appear outside switch statement", "default", "");
3624         else if (parseContext.switchLevel.back() != parseContext.statementNestingLevel)
3625             parseContext.error($1.loc, "cannot be nested inside control flow", "default", "");
3626         else
3627             $$ = parseContext.intermediate.addBranch(EOpDefault, $1.loc);
3628     }
3629     ;
3630
3631 iteration_statement
3632     : iteration_statement_nonattributed {
3633         $$ = $1;
3634     }
3635
3636     | attribute iteration_statement_nonattributed {
3637         parseContext.handleLoopAttributes(*$1, $2);
3638         $$ = $2;
3639     }
3640
3641
3642 iteration_statement_nonattributed
3643     : WHILE LEFT_PAREN {
3644         if (! parseContext.limits.whileLoops)
3645             parseContext.error($1.loc, "while loops not available", "limitation", "");
3646         parseContext.symbolTable.push();
3647         ++parseContext.loopNestingLevel;
3648         ++parseContext.statementNestingLevel;
3649         ++parseContext.controlFlowNestingLevel;
3650     }
3651       condition RIGHT_PAREN statement_no_new_scope {
3652         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3653         $$ = parseContext.intermediate.addLoop($6, $4, 0, true, $1.loc);
3654         --parseContext.loopNestingLevel;
3655         --parseContext.statementNestingLevel;
3656         --parseContext.controlFlowNestingLevel;
3657     }
3658     | DO {
3659         ++parseContext.loopNestingLevel;
3660         ++parseContext.statementNestingLevel;
3661         ++parseContext.controlFlowNestingLevel;
3662     }
3663       statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
3664         if (! parseContext.limits.whileLoops)
3665             parseContext.error($1.loc, "do-while loops not available", "limitation", "");
3666
3667         parseContext.boolCheck($8.loc, $6);
3668
3669         $$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.loc);
3670         --parseContext.loopNestingLevel;
3671         --parseContext.statementNestingLevel;
3672         --parseContext.controlFlowNestingLevel;
3673     }
3674     | FOR LEFT_PAREN {
3675         parseContext.symbolTable.push();
3676         ++parseContext.loopNestingLevel;
3677         ++parseContext.statementNestingLevel;
3678         ++parseContext.controlFlowNestingLevel;
3679     }
3680       for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
3681         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3682         $$ = parseContext.intermediate.makeAggregate($4, $2.loc);
3683         TIntermLoop* forLoop = parseContext.intermediate.addLoop($7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.loc);
3684         if (! parseContext.limits.nonInductiveForLoops)
3685             parseContext.inductiveLoopCheck($1.loc, $4, forLoop);
3686         $$ = parseContext.intermediate.growAggregate($$, forLoop, $1.loc);
3687         $$->getAsAggregate()->setOperator(EOpSequence);
3688         --parseContext.loopNestingLevel;
3689         --parseContext.statementNestingLevel;
3690         --parseContext.controlFlowNestingLevel;
3691     }
3692     ;
3693
3694 for_init_statement
3695     : expression_statement {
3696         $$ = $1;
3697     }
3698     | declaration_statement {
3699         $$ = $1;
3700     }
3701     ;
3702
3703 conditionopt
3704     : condition {
3705         $$ = $1;
3706     }
3707     | /* May be null */ {
3708         $$ = 0;
3709     }
3710     ;
3711
3712 for_rest_statement
3713     : conditionopt SEMICOLON {
3714         $$.node1 = $1;
3715         $$.node2 = 0;
3716     }
3717     | conditionopt SEMICOLON expression  {
3718         $$.node1 = $1;
3719         $$.node2 = $3;
3720     }
3721     ;
3722
3723 jump_statement
3724     : CONTINUE SEMICOLON {
3725         if (parseContext.loopNestingLevel <= 0)
3726             parseContext.error($1.loc, "continue statement only allowed in loops", "", "");
3727         $$ = parseContext.intermediate.addBranch(EOpContinue, $1.loc);
3728     }
3729     | BREAK SEMICOLON {
3730         if (parseContext.loopNestingLevel + parseContext.switchSequenceStack.size() <= 0)
3731             parseContext.error($1.loc, "break statement only allowed in switch and loops", "", "");
3732         $$ = parseContext.intermediate.addBranch(EOpBreak, $1.loc);
3733     }
3734     | RETURN SEMICOLON {
3735         $$ = parseContext.intermediate.addBranch(EOpReturn, $1.loc);
3736         if (parseContext.currentFunctionType->getBasicType() != EbtVoid)
3737             parseContext.error($1.loc, "non-void function must return a value", "return", "");
3738         if (parseContext.inMain)
3739             parseContext.postEntryPointReturn = true;
3740     }
3741     | RETURN expression SEMICOLON {
3742         $$ = parseContext.handleReturnValue($1.loc, $2);
3743     }
3744     | DISCARD SEMICOLON {
3745         parseContext.requireStage($1.loc, EShLangFragment, "discard");
3746         $$ = parseContext.intermediate.addBranch(EOpKill, $1.loc);
3747     }
3748     ;
3749
3750 // Grammar Note:  No 'goto'.  Gotos are not supported.
3751
3752 translation_unit
3753     : external_declaration {
3754         $$ = $1;
3755         parseContext.intermediate.setTreeRoot($$);
3756     }
3757     | translation_unit external_declaration {
3758         if ($2 != nullptr) {
3759             $$ = parseContext.intermediate.growAggregate($1, $2);
3760             parseContext.intermediate.setTreeRoot($$);
3761         }
3762     }
3763     ;
3764
3765 external_declaration
3766     : function_definition {
3767         $$ = $1;
3768     }
3769     | declaration {
3770         $$ = $1;
3771     }
3772
3773     | SEMICOLON {
3774         parseContext.requireProfile($1.loc, ~EEsProfile, "extraneous semicolon");
3775         parseContext.profileRequires($1.loc, ~EEsProfile, 460, nullptr, "extraneous semicolon");
3776         $$ = nullptr;
3777     }
3778
3779     ;
3780
3781 function_definition
3782     : function_prototype {
3783         $1.function = parseContext.handleFunctionDeclarator($1.loc, *$1.function, false /* not prototype */);
3784         $1.intermNode = parseContext.handleFunctionDefinition($1.loc, *$1.function);
3785     }
3786     compound_statement_no_new_scope {
3787         //   May be best done as post process phase on intermediate code
3788         if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue)
3789             parseContext.error($1.loc, "function does not return a value:", "", $1.function->getName().c_str());
3790         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3791         $$ = parseContext.intermediate.growAggregate($1.intermNode, $3);
3792         parseContext.intermediate.setAggregateOperator($$, EOpFunction, $1.function->getType(), $1.loc);
3793         $$->getAsAggregate()->setName($1.function->getMangledName().c_str());
3794
3795         // store the pragma information for debug and optimize and other vendor specific
3796         // information. This information can be queried from the parse tree
3797         $$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
3798         $$->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
3799         $$->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable);
3800     }
3801     ;
3802
3803
3804 attribute
3805     : LEFT_BRACKET LEFT_BRACKET attribute_list RIGHT_BRACKET RIGHT_BRACKET {
3806         $$ = $3;
3807         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_control_flow_attributes, "attribute");
3808     }
3809
3810 attribute_list
3811     : single_attribute {
3812         $$ = $1;
3813     }
3814     | attribute_list COMMA single_attribute {
3815         $$ = parseContext.mergeAttributes($1, $3);
3816     }
3817
3818 single_attribute
3819     : IDENTIFIER {
3820         $$ = parseContext.makeAttributes(*$1.string);
3821     }
3822     | IDENTIFIER LEFT_PAREN constant_expression RIGHT_PAREN {
3823         $$ = parseContext.makeAttributes(*$1.string, $3);
3824     }
3825
3826
3827 %%