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