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