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