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