Fix variable scoping of do-while
[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 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(), $6->getCompleteString());
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(), $3->getCompleteString());
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(), $3->getCompleteString());
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     | PERPRIMITIVENV {
1294         // No need for profile version or extension check. Shader stage already checks both.
1295         parseContext.globalCheck($1.loc, "perprimitiveNV");
1296         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
1297         // Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
1298         if (parseContext.language == EShLangFragment)
1299             parseContext.requireExtensions($1.loc, 1, &E_GL_NV_mesh_shader, "perprimitiveNV");
1300         $$.init($1.loc);
1301         $$.qualifier.perPrimitiveNV = true;
1302     }
1303     | PERVIEWNV {
1304         // No need for profile version or extension check. Shader stage already checks both.
1305         parseContext.globalCheck($1.loc, "perviewNV");
1306         parseContext.requireStage($1.loc, EShLangMeshNV, "perviewNV");
1307         $$.init($1.loc);
1308         $$.qualifier.perViewNV = true;
1309     }
1310     | PERTASKNV {
1311         // No need for profile version or extension check. Shader stage already checks both.
1312         parseContext.globalCheck($1.loc, "taskNV");
1313         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
1314         $$.init($1.loc);
1315         $$.qualifier.perTaskNV = true;
1316     }
1317 GLSLANG_WEB_EXCLUDE_OFF
1318     ;
1319
1320 layout_qualifier
1321     : LAYOUT LEFT_PAREN layout_qualifier_id_list RIGHT_PAREN {
1322         $$ = $3;
1323     }
1324     ;
1325
1326 layout_qualifier_id_list
1327     : layout_qualifier_id {
1328         $$ = $1;
1329     }
1330     | layout_qualifier_id_list COMMA layout_qualifier_id {
1331         $$ = $1;
1332         $$.shaderQualifiers.merge($3.shaderQualifiers);
1333         parseContext.mergeObjectLayoutQualifiers($$.qualifier, $3.qualifier, false);
1334     }
1335
1336 layout_qualifier_id
1337     : IDENTIFIER {
1338         $$.init($1.loc);
1339         parseContext.setLayoutQualifier($1.loc, $$, *$1.string);
1340     }
1341     | IDENTIFIER EQUAL constant_expression {
1342         $$.init($1.loc);
1343         parseContext.setLayoutQualifier($1.loc, $$, *$1.string, $3);
1344     }
1345     | SHARED { // because "shared" is both an identifier and a keyword
1346         $$.init($1.loc);
1347         TString strShared("shared");
1348         parseContext.setLayoutQualifier($1.loc, $$, strShared);
1349     }
1350     ;
1351
1352 GLSLANG_WEB_EXCLUDE_ON
1353 precise_qualifier
1354     : PRECISE {
1355         parseContext.profileRequires($$.loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader5, "precise");
1356         parseContext.profileRequires($1.loc, EEsProfile, 320, Num_AEP_gpu_shader5, AEP_gpu_shader5, "precise");
1357         $$.init($1.loc);
1358         $$.qualifier.noContraction = true;
1359     }
1360     ;
1361 GLSLANG_WEB_EXCLUDE_OFF
1362
1363 type_qualifier
1364     : single_type_qualifier {
1365         $$ = $1;
1366     }
1367     | type_qualifier single_type_qualifier {
1368         $$ = $1;
1369         if ($$.basicType == EbtVoid)
1370             $$.basicType = $2.basicType;
1371
1372         $$.shaderQualifiers.merge($2.shaderQualifiers);
1373         parseContext.mergeQualifiers($$.loc, $$.qualifier, $2.qualifier, false);
1374     }
1375     ;
1376
1377 single_type_qualifier
1378     : storage_qualifier {
1379         $$ = $1;
1380     }
1381     | layout_qualifier {
1382         $$ = $1;
1383     }
1384     | precision_qualifier {
1385         parseContext.checkPrecisionQualifier($1.loc, $1.qualifier.precision);
1386         $$ = $1;
1387     }
1388     | interpolation_qualifier {
1389         // allow inheritance of storage qualifier from block declaration
1390         $$ = $1;
1391     }
1392     | invariant_qualifier {
1393         // allow inheritance of storage qualifier from block declaration
1394         $$ = $1;
1395     }
1396 GLSLANG_WEB_EXCLUDE_ON
1397     | precise_qualifier {
1398         // allow inheritance of storage qualifier from block declaration
1399         $$ = $1;
1400     }
1401     | non_uniform_qualifier {
1402         $$ = $1;
1403     }
1404     | spirv_storage_class_qualifier {
1405         parseContext.globalCheck($1.loc, "spirv_storage_class");
1406         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_spirv_intrinsics, "SPIR-V storage class qualifier");
1407         $$ = $1;
1408     }
1409     | spirv_decorate_qualifier {
1410         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_spirv_intrinsics, "SPIR-V decorate qualifier");
1411         $$ = $1;
1412     }
1413     | SPIRV_BY_REFERENCE {
1414         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_spirv_intrinsics, "spirv_by_reference");
1415         $$.init($1.loc);
1416         $$.qualifier.setSpirvByReference();
1417     }
1418     | SPIRV_LITERAL {
1419         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_spirv_intrinsics, "spirv_by_literal");
1420         $$.init($1.loc);
1421         $$.qualifier.setSpirvLiteral();
1422     }
1423 GLSLANG_WEB_EXCLUDE_OFF
1424     ;
1425
1426 storage_qualifier
1427     : CONST {
1428         $$.init($1.loc);
1429         $$.qualifier.storage = EvqConst;  // will later turn into EvqConstReadOnly, if the initializer is not constant
1430     }
1431     | INOUT {
1432         parseContext.globalCheck($1.loc, "inout");
1433         $$.init($1.loc);
1434         $$.qualifier.storage = EvqInOut;
1435     }
1436     | IN {
1437         parseContext.globalCheck($1.loc, "in");
1438         $$.init($1.loc);
1439         // whether this is a parameter "in" or a pipeline "in" will get sorted out a bit later
1440         $$.qualifier.storage = EvqIn;
1441     }
1442     | OUT {
1443         parseContext.globalCheck($1.loc, "out");
1444         $$.init($1.loc);
1445         // whether this is a parameter "out" or a pipeline "out" will get sorted out a bit later
1446         $$.qualifier.storage = EvqOut;
1447     }
1448     | CENTROID {
1449         parseContext.profileRequires($1.loc, ENoProfile, 120, 0, "centroid");
1450         parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "centroid");
1451         parseContext.globalCheck($1.loc, "centroid");
1452         $$.init($1.loc);
1453         $$.qualifier.centroid = true;
1454     }
1455     | UNIFORM {
1456         parseContext.globalCheck($1.loc, "uniform");
1457         $$.init($1.loc);
1458         $$.qualifier.storage = EvqUniform;
1459     }
1460     | SHARED {
1461         parseContext.globalCheck($1.loc, "shared");
1462         parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_compute_shader, "shared");
1463         parseContext.profileRequires($1.loc, EEsProfile, 310, 0, "shared");
1464         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangComputeMask | EShLangMeshNVMask | EShLangTaskNVMask), "shared");
1465         $$.init($1.loc);
1466         $$.qualifier.storage = EvqShared;
1467     }
1468     | BUFFER {
1469         parseContext.globalCheck($1.loc, "buffer");
1470         $$.init($1.loc);
1471         $$.qualifier.storage = EvqBuffer;
1472     }
1473 GLSLANG_WEB_EXCLUDE_ON
1474     | ATTRIBUTE {
1475         parseContext.requireStage($1.loc, EShLangVertex, "attribute");
1476         parseContext.checkDeprecated($1.loc, ECoreProfile, 130, "attribute");
1477         parseContext.checkDeprecated($1.loc, ENoProfile, 130, "attribute");
1478         parseContext.requireNotRemoved($1.loc, ECoreProfile, 420, "attribute");
1479         parseContext.requireNotRemoved($1.loc, EEsProfile, 300, "attribute");
1480
1481         parseContext.globalCheck($1.loc, "attribute");
1482
1483         $$.init($1.loc);
1484         $$.qualifier.storage = EvqVaryingIn;
1485     }
1486     | VARYING {
1487         parseContext.checkDeprecated($1.loc, ENoProfile, 130, "varying");
1488         parseContext.checkDeprecated($1.loc, ECoreProfile, 130, "varying");
1489         parseContext.requireNotRemoved($1.loc, ECoreProfile, 420, "varying");
1490         parseContext.requireNotRemoved($1.loc, EEsProfile, 300, "varying");
1491
1492         parseContext.globalCheck($1.loc, "varying");
1493
1494         $$.init($1.loc);
1495         if (parseContext.language == EShLangVertex)
1496             $$.qualifier.storage = EvqVaryingOut;
1497         else
1498             $$.qualifier.storage = EvqVaryingIn;
1499     }
1500     | PATCH {
1501         parseContext.globalCheck($1.loc, "patch");
1502         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTessControlMask | EShLangTessEvaluationMask), "patch");
1503         $$.init($1.loc);
1504         $$.qualifier.patch = true;
1505     }
1506     | SAMPLE {
1507         parseContext.globalCheck($1.loc, "sample");
1508         $$.init($1.loc);
1509         $$.qualifier.sample = true;
1510     }
1511     | HITATTRNV {
1512         parseContext.globalCheck($1.loc, "hitAttributeNV");
1513         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangIntersectMask | EShLangClosestHitMask
1514             | EShLangAnyHitMask), "hitAttributeNV");
1515         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "hitAttributeNV");
1516         $$.init($1.loc);
1517         $$.qualifier.storage = EvqHitAttr;
1518     }
1519     | HITATTREXT {
1520         parseContext.globalCheck($1.loc, "hitAttributeEXT");
1521         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangIntersectMask | EShLangClosestHitMask
1522             | EShLangAnyHitMask), "hitAttributeEXT");
1523         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_EXT_ray_tracing, "hitAttributeNV");
1524         $$.init($1.loc);
1525         $$.qualifier.storage = EvqHitAttr;
1526     }
1527     | PAYLOADNV {
1528         parseContext.globalCheck($1.loc, "rayPayloadNV");
1529         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangRayGenMask | EShLangClosestHitMask |
1530             EShLangAnyHitMask | EShLangMissMask), "rayPayloadNV");
1531         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "rayPayloadNV");
1532         $$.init($1.loc);
1533         $$.qualifier.storage = EvqPayload;
1534     }
1535     | PAYLOADEXT {
1536         parseContext.globalCheck($1.loc, "rayPayloadEXT");
1537         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangRayGenMask | EShLangClosestHitMask |
1538             EShLangAnyHitMask | EShLangMissMask), "rayPayloadEXT");
1539         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_EXT_ray_tracing, "rayPayloadEXT");
1540         $$.init($1.loc);
1541         $$.qualifier.storage = EvqPayload;
1542     }
1543     | PAYLOADINNV {
1544         parseContext.globalCheck($1.loc, "rayPayloadInNV");
1545         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangClosestHitMask |
1546             EShLangAnyHitMask | EShLangMissMask), "rayPayloadInNV");
1547         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "rayPayloadInNV");
1548         $$.init($1.loc);
1549         $$.qualifier.storage = EvqPayloadIn;
1550     }
1551     | PAYLOADINEXT {
1552         parseContext.globalCheck($1.loc, "rayPayloadInEXT");
1553         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangClosestHitMask |
1554             EShLangAnyHitMask | EShLangMissMask), "rayPayloadInEXT");
1555         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_EXT_ray_tracing, "rayPayloadInEXT");
1556         $$.init($1.loc);
1557         $$.qualifier.storage = EvqPayloadIn;
1558     }
1559     | CALLDATANV {
1560         parseContext.globalCheck($1.loc, "callableDataNV");
1561         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangRayGenMask |
1562             EShLangClosestHitMask | EShLangMissMask | EShLangCallableMask), "callableDataNV");
1563         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "callableDataNV");
1564         $$.init($1.loc);
1565         $$.qualifier.storage = EvqCallableData;
1566     }
1567     | CALLDATAEXT {
1568         parseContext.globalCheck($1.loc, "callableDataEXT");
1569         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangRayGenMask |
1570             EShLangClosestHitMask | EShLangMissMask | EShLangCallableMask), "callableDataEXT");
1571         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_EXT_ray_tracing, "callableDataEXT");
1572         $$.init($1.loc);
1573         $$.qualifier.storage = EvqCallableData;
1574     }
1575     | CALLDATAINNV {
1576         parseContext.globalCheck($1.loc, "callableDataInNV");
1577         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangCallableMask), "callableDataInNV");
1578         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_NV_ray_tracing, "callableDataInNV");
1579         $$.init($1.loc);
1580         $$.qualifier.storage = EvqCallableDataIn;
1581     }
1582     | CALLDATAINEXT {
1583         parseContext.globalCheck($1.loc, "callableDataInEXT");
1584         parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangCallableMask), "callableDataInEXT");
1585         parseContext.profileRequires($1.loc, ECoreProfile, 460, E_GL_EXT_ray_tracing, "callableDataInEXT");
1586         $$.init($1.loc);
1587         $$.qualifier.storage = EvqCallableDataIn;
1588     }
1589     | COHERENT {
1590         $$.init($1.loc);
1591         $$.qualifier.coherent = true;
1592     }
1593     | DEVICECOHERENT {
1594         $$.init($1.loc);
1595         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "devicecoherent");
1596         $$.qualifier.devicecoherent = true;
1597     }
1598     | QUEUEFAMILYCOHERENT {
1599         $$.init($1.loc);
1600         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "queuefamilycoherent");
1601         $$.qualifier.queuefamilycoherent = true;
1602     }
1603     | WORKGROUPCOHERENT {
1604         $$.init($1.loc);
1605         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "workgroupcoherent");
1606         $$.qualifier.workgroupcoherent = true;
1607     }
1608     | SUBGROUPCOHERENT {
1609         $$.init($1.loc);
1610         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "subgroupcoherent");
1611         $$.qualifier.subgroupcoherent = true;
1612     }
1613     | NONPRIVATE {
1614         $$.init($1.loc);
1615         parseContext.requireExtensions($1.loc, 1, &E_GL_KHR_memory_scope_semantics, "nonprivate");
1616         $$.qualifier.nonprivate = true;
1617     }
1618     | SHADERCALLCOHERENT {
1619         $$.init($1.loc);
1620         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_ray_tracing, "shadercallcoherent");
1621         $$.qualifier.shadercallcoherent = true;
1622     }
1623     | VOLATILE {
1624         $$.init($1.loc);
1625         $$.qualifier.volatil = true;
1626     }
1627     | RESTRICT {
1628         $$.init($1.loc);
1629         $$.qualifier.restrict = true;
1630     }
1631     | READONLY {
1632         $$.init($1.loc);
1633         $$.qualifier.readonly = true;
1634     }
1635     | WRITEONLY {
1636         $$.init($1.loc);
1637         $$.qualifier.writeonly = true;
1638     }
1639     | SUBROUTINE {
1640         parseContext.spvRemoved($1.loc, "subroutine");
1641         parseContext.globalCheck($1.loc, "subroutine");
1642         parseContext.unimplemented($1.loc, "subroutine");
1643         $$.init($1.loc);
1644     }
1645     | SUBROUTINE LEFT_PAREN type_name_list RIGHT_PAREN {
1646         parseContext.spvRemoved($1.loc, "subroutine");
1647         parseContext.globalCheck($1.loc, "subroutine");
1648         parseContext.unimplemented($1.loc, "subroutine");
1649         $$.init($1.loc);
1650     }
1651 GLSLANG_WEB_EXCLUDE_OFF
1652     ;
1653
1654 GLSLANG_WEB_EXCLUDE_ON
1655 non_uniform_qualifier
1656     : NONUNIFORM {
1657         $$.init($1.loc);
1658         $$.qualifier.nonUniform = true;
1659     }
1660     ;
1661
1662 type_name_list
1663     : IDENTIFIER {
1664         // TODO
1665     }
1666     | type_name_list COMMA IDENTIFIER {
1667         // TODO: 4.0 semantics: subroutines
1668         // 1) make sure each identifier is a type declared earlier with SUBROUTINE
1669         // 2) save all of the identifiers for future comparison with the declared function
1670     }
1671     ;
1672 GLSLANG_WEB_EXCLUDE_OFF
1673
1674 type_specifier
1675     : type_specifier_nonarray type_parameter_specifier_opt {
1676         $$ = $1;
1677         $$.qualifier.precision = parseContext.getDefaultPrecision($$);
1678         $$.typeParameters = $2;
1679     }
1680     | type_specifier_nonarray type_parameter_specifier_opt array_specifier {
1681         parseContext.arrayOfArrayVersionCheck($3.loc, $3.arraySizes);
1682         $$ = $1;
1683         $$.qualifier.precision = parseContext.getDefaultPrecision($$);
1684         $$.typeParameters = $2;
1685         $$.arraySizes = $3.arraySizes;
1686     }
1687     ;
1688
1689 array_specifier
1690     : LEFT_BRACKET RIGHT_BRACKET {
1691         $$.loc = $1.loc;
1692         $$.arraySizes = new TArraySizes;
1693         $$.arraySizes->addInnerSize();
1694     }
1695     | LEFT_BRACKET conditional_expression RIGHT_BRACKET {
1696         $$.loc = $1.loc;
1697         $$.arraySizes = new TArraySizes;
1698
1699         TArraySize size;
1700         parseContext.arraySizeCheck($2->getLoc(), $2, size, "array size");
1701         $$.arraySizes->addInnerSize(size);
1702     }
1703     | array_specifier LEFT_BRACKET RIGHT_BRACKET {
1704         $$ = $1;
1705         $$.arraySizes->addInnerSize();
1706     }
1707     | array_specifier LEFT_BRACKET conditional_expression RIGHT_BRACKET {
1708         $$ = $1;
1709
1710         TArraySize size;
1711         parseContext.arraySizeCheck($3->getLoc(), $3, size, "array size");
1712         $$.arraySizes->addInnerSize(size);
1713     }
1714     ;
1715
1716 type_parameter_specifier_opt
1717     : type_parameter_specifier {
1718         $$ = $1;
1719     }
1720     | /* May be null */ {
1721         $$ = 0;
1722     }
1723     ;
1724
1725 type_parameter_specifier
1726     : LEFT_ANGLE type_parameter_specifier_list RIGHT_ANGLE {
1727         $$ = $2;
1728     }
1729     ;
1730
1731 type_parameter_specifier_list
1732     : unary_expression {
1733         $$ = new TArraySizes;
1734
1735         TArraySize size;
1736         parseContext.arraySizeCheck($1->getLoc(), $1, size, "type parameter");
1737         $$->addInnerSize(size);
1738     }
1739     | type_parameter_specifier_list COMMA unary_expression {
1740         $$ = $1;
1741
1742         TArraySize size;
1743         parseContext.arraySizeCheck($3->getLoc(), $3, size, "type parameter");
1744         $$->addInnerSize(size);
1745     }
1746     ;
1747
1748 type_specifier_nonarray
1749     : VOID {
1750         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1751         $$.basicType = EbtVoid;
1752     }
1753     | FLOAT {
1754         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1755         $$.basicType = EbtFloat;
1756     }
1757     | INT {
1758         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1759         $$.basicType = EbtInt;
1760     }
1761     | UINT {
1762         parseContext.fullIntegerCheck($1.loc, "unsigned integer");
1763         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1764         $$.basicType = EbtUint;
1765     }
1766     | BOOL {
1767         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1768         $$.basicType = EbtBool;
1769     }
1770     | VEC2 {
1771         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1772         $$.basicType = EbtFloat;
1773         $$.setVector(2);
1774     }
1775     | VEC3 {
1776         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1777         $$.basicType = EbtFloat;
1778         $$.setVector(3);
1779     }
1780     | VEC4 {
1781         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1782         $$.basicType = EbtFloat;
1783         $$.setVector(4);
1784     }
1785     | BVEC2 {
1786         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1787         $$.basicType = EbtBool;
1788         $$.setVector(2);
1789     }
1790     | BVEC3 {
1791         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1792         $$.basicType = EbtBool;
1793         $$.setVector(3);
1794     }
1795     | BVEC4 {
1796         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1797         $$.basicType = EbtBool;
1798         $$.setVector(4);
1799     }
1800     | IVEC2 {
1801         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1802         $$.basicType = EbtInt;
1803         $$.setVector(2);
1804     }
1805     | IVEC3 {
1806         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1807         $$.basicType = EbtInt;
1808         $$.setVector(3);
1809     }
1810     | IVEC4 {
1811         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1812         $$.basicType = EbtInt;
1813         $$.setVector(4);
1814     }
1815     | UVEC2 {
1816         parseContext.fullIntegerCheck($1.loc, "unsigned integer vector");
1817         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1818         $$.basicType = EbtUint;
1819         $$.setVector(2);
1820     }
1821     | UVEC3 {
1822         parseContext.fullIntegerCheck($1.loc, "unsigned integer vector");
1823         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1824         $$.basicType = EbtUint;
1825         $$.setVector(3);
1826     }
1827     | UVEC4 {
1828         parseContext.fullIntegerCheck($1.loc, "unsigned integer vector");
1829         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1830         $$.basicType = EbtUint;
1831         $$.setVector(4);
1832     }
1833     | MAT2 {
1834         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1835         $$.basicType = EbtFloat;
1836         $$.setMatrix(2, 2);
1837     }
1838     | MAT3 {
1839         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1840         $$.basicType = EbtFloat;
1841         $$.setMatrix(3, 3);
1842     }
1843     | MAT4 {
1844         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1845         $$.basicType = EbtFloat;
1846         $$.setMatrix(4, 4);
1847     }
1848     | MAT2X2 {
1849         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1850         $$.basicType = EbtFloat;
1851         $$.setMatrix(2, 2);
1852     }
1853     | MAT2X3 {
1854         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1855         $$.basicType = EbtFloat;
1856         $$.setMatrix(2, 3);
1857     }
1858     | MAT2X4 {
1859         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1860         $$.basicType = EbtFloat;
1861         $$.setMatrix(2, 4);
1862     }
1863     | MAT3X2 {
1864         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1865         $$.basicType = EbtFloat;
1866         $$.setMatrix(3, 2);
1867     }
1868     | MAT3X3 {
1869         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1870         $$.basicType = EbtFloat;
1871         $$.setMatrix(3, 3);
1872     }
1873     | MAT3X4 {
1874         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1875         $$.basicType = EbtFloat;
1876         $$.setMatrix(3, 4);
1877     }
1878     | MAT4X2 {
1879         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1880         $$.basicType = EbtFloat;
1881         $$.setMatrix(4, 2);
1882     }
1883     | MAT4X3 {
1884         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1885         $$.basicType = EbtFloat;
1886         $$.setMatrix(4, 3);
1887     }
1888     | MAT4X4 {
1889         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1890         $$.basicType = EbtFloat;
1891         $$.setMatrix(4, 4);
1892     }
1893 GLSLANG_WEB_EXCLUDE_ON
1894     | DOUBLE {
1895         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double");
1896         if (! parseContext.symbolTable.atBuiltInLevel())
1897             parseContext.doubleCheck($1.loc, "double");
1898         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1899         $$.basicType = EbtDouble;
1900     }
1901     | FLOAT16_T {
1902         parseContext.float16ScalarVectorCheck($1.loc, "float16_t", parseContext.symbolTable.atBuiltInLevel());
1903         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1904         $$.basicType = EbtFloat16;
1905     }
1906     | FLOAT32_T {
1907         parseContext.explicitFloat32Check($1.loc, "float32_t", parseContext.symbolTable.atBuiltInLevel());
1908         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1909         $$.basicType = EbtFloat;
1910     }
1911     | FLOAT64_T {
1912         parseContext.explicitFloat64Check($1.loc, "float64_t", parseContext.symbolTable.atBuiltInLevel());
1913         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1914         $$.basicType = EbtDouble;
1915     }
1916     | INT8_T {
1917         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer", parseContext.symbolTable.atBuiltInLevel());
1918         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1919         $$.basicType = EbtInt8;
1920     }
1921     | UINT8_T {
1922         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1923         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1924         $$.basicType = EbtUint8;
1925     }
1926     | INT16_T {
1927         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer", parseContext.symbolTable.atBuiltInLevel());
1928         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1929         $$.basicType = EbtInt16;
1930     }
1931     | UINT16_T {
1932         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1933         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1934         $$.basicType = EbtUint16;
1935     }
1936     | INT32_T {
1937         parseContext.explicitInt32Check($1.loc, "32-bit signed integer", parseContext.symbolTable.atBuiltInLevel());
1938         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1939         $$.basicType = EbtInt;
1940     }
1941     | UINT32_T {
1942         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1943         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1944         $$.basicType = EbtUint;
1945     }
1946     | INT64_T {
1947         parseContext.int64Check($1.loc, "64-bit integer", parseContext.symbolTable.atBuiltInLevel());
1948         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1949         $$.basicType = EbtInt64;
1950     }
1951     | UINT64_T {
1952         parseContext.int64Check($1.loc, "64-bit unsigned integer", parseContext.symbolTable.atBuiltInLevel());
1953         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1954         $$.basicType = EbtUint64;
1955     }
1956     | DVEC2 {
1957         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
1958         if (! parseContext.symbolTable.atBuiltInLevel())
1959             parseContext.doubleCheck($1.loc, "double vector");
1960         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1961         $$.basicType = EbtDouble;
1962         $$.setVector(2);
1963     }
1964     | DVEC3 {
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(3);
1971     }
1972     | DVEC4 {
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(4);
1979     }
1980     | F16VEC2 {
1981         parseContext.float16ScalarVectorCheck($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
1982         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1983         $$.basicType = EbtFloat16;
1984         $$.setVector(2);
1985     }
1986     | F16VEC3 {
1987         parseContext.float16ScalarVectorCheck($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
1988         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1989         $$.basicType = EbtFloat16;
1990         $$.setVector(3);
1991     }
1992     | F16VEC4 {
1993         parseContext.float16ScalarVectorCheck($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
1994         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
1995         $$.basicType = EbtFloat16;
1996         $$.setVector(4);
1997     }
1998     | F32VEC2 {
1999         parseContext.explicitFloat32Check($1.loc, "float32_t vector", parseContext.symbolTable.atBuiltInLevel());
2000         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2001         $$.basicType = EbtFloat;
2002         $$.setVector(2);
2003     }
2004     | F32VEC3 {
2005         parseContext.explicitFloat32Check($1.loc, "float32_t vector", parseContext.symbolTable.atBuiltInLevel());
2006         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2007         $$.basicType = EbtFloat;
2008         $$.setVector(3);
2009     }
2010     | F32VEC4 {
2011         parseContext.explicitFloat32Check($1.loc, "float32_t vector", parseContext.symbolTable.atBuiltInLevel());
2012         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2013         $$.basicType = EbtFloat;
2014         $$.setVector(4);
2015     }
2016     | F64VEC2 {
2017         parseContext.explicitFloat64Check($1.loc, "float64_t vector", parseContext.symbolTable.atBuiltInLevel());
2018         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2019         $$.basicType = EbtDouble;
2020         $$.setVector(2);
2021     }
2022     | F64VEC3 {
2023         parseContext.explicitFloat64Check($1.loc, "float64_t vector", parseContext.symbolTable.atBuiltInLevel());
2024         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2025         $$.basicType = EbtDouble;
2026         $$.setVector(3);
2027     }
2028     | F64VEC4 {
2029         parseContext.explicitFloat64Check($1.loc, "float64_t vector", parseContext.symbolTable.atBuiltInLevel());
2030         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2031         $$.basicType = EbtDouble;
2032         $$.setVector(4);
2033     }
2034     | I8VEC2 {
2035         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2036         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2037         $$.basicType = EbtInt8;
2038         $$.setVector(2);
2039     }
2040     | I8VEC3 {
2041         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2042         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2043         $$.basicType = EbtInt8;
2044         $$.setVector(3);
2045     }
2046     | I8VEC4 {
2047         parseContext.int8ScalarVectorCheck($1.loc, "8-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2048         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2049         $$.basicType = EbtInt8;
2050         $$.setVector(4);
2051     }
2052     | I16VEC2 {
2053         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2054         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2055         $$.basicType = EbtInt16;
2056         $$.setVector(2);
2057     }
2058     | I16VEC3 {
2059         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2060         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2061         $$.basicType = EbtInt16;
2062         $$.setVector(3);
2063     }
2064     | I16VEC4 {
2065         parseContext.int16ScalarVectorCheck($1.loc, "16-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2066         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2067         $$.basicType = EbtInt16;
2068         $$.setVector(4);
2069     }
2070     | I32VEC2 {
2071         parseContext.explicitInt32Check($1.loc, "32-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2072         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2073         $$.basicType = EbtInt;
2074         $$.setVector(2);
2075     }
2076     | I32VEC3 {
2077         parseContext.explicitInt32Check($1.loc, "32-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2078         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2079         $$.basicType = EbtInt;
2080         $$.setVector(3);
2081     }
2082     | I32VEC4 {
2083         parseContext.explicitInt32Check($1.loc, "32-bit signed integer vector", parseContext.symbolTable.atBuiltInLevel());
2084         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2085         $$.basicType = EbtInt;
2086         $$.setVector(4);
2087     }
2088     | I64VEC2 {
2089         parseContext.int64Check($1.loc, "64-bit integer vector", parseContext.symbolTable.atBuiltInLevel());
2090         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2091         $$.basicType = EbtInt64;
2092         $$.setVector(2);
2093     }
2094     | I64VEC3 {
2095         parseContext.int64Check($1.loc, "64-bit integer vector", parseContext.symbolTable.atBuiltInLevel());
2096         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2097         $$.basicType = EbtInt64;
2098         $$.setVector(3);
2099     }
2100     | I64VEC4 {
2101         parseContext.int64Check($1.loc, "64-bit integer vector", parseContext.symbolTable.atBuiltInLevel());
2102         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2103         $$.basicType = EbtInt64;
2104         $$.setVector(4);
2105     }
2106     | U8VEC2 {
2107         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2108         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2109         $$.basicType = EbtUint8;
2110         $$.setVector(2);
2111     }
2112     | U8VEC3 {
2113         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2114         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2115         $$.basicType = EbtUint8;
2116         $$.setVector(3);
2117     }
2118     | U8VEC4 {
2119         parseContext.int8ScalarVectorCheck($1.loc, "8-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2120         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2121         $$.basicType = EbtUint8;
2122         $$.setVector(4);
2123     }
2124     | U16VEC2 {
2125         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2126         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2127         $$.basicType = EbtUint16;
2128         $$.setVector(2);
2129     }
2130     | U16VEC3 {
2131         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2132         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2133         $$.basicType = EbtUint16;
2134         $$.setVector(3);
2135     }
2136     | U16VEC4 {
2137         parseContext.int16ScalarVectorCheck($1.loc, "16-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2138         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2139         $$.basicType = EbtUint16;
2140         $$.setVector(4);
2141     }
2142     | U32VEC2 {
2143         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2144         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2145         $$.basicType = EbtUint;
2146         $$.setVector(2);
2147     }
2148     | U32VEC3 {
2149         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2150         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2151         $$.basicType = EbtUint;
2152         $$.setVector(3);
2153     }
2154     | U32VEC4 {
2155         parseContext.explicitInt32Check($1.loc, "32-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2156         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2157         $$.basicType = EbtUint;
2158         $$.setVector(4);
2159     }
2160     | U64VEC2 {
2161         parseContext.int64Check($1.loc, "64-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2162         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2163         $$.basicType = EbtUint64;
2164         $$.setVector(2);
2165     }
2166     | U64VEC3 {
2167         parseContext.int64Check($1.loc, "64-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2168         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2169         $$.basicType = EbtUint64;
2170         $$.setVector(3);
2171     }
2172     | U64VEC4 {
2173         parseContext.int64Check($1.loc, "64-bit unsigned integer vector", parseContext.symbolTable.atBuiltInLevel());
2174         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2175         $$.basicType = EbtUint64;
2176         $$.setVector(4);
2177     }
2178     | DMAT2 {
2179         parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
2180         if (! parseContext.symbolTable.atBuiltInLevel())
2181             parseContext.doubleCheck($1.loc, "double matrix");
2182         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2183         $$.basicType = EbtDouble;
2184         $$.setMatrix(2, 2);
2185     }
2186     | DMAT3 {
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(3, 3);
2193     }
2194     | DMAT4 {
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(4, 4);
2201     }
2202     | DMAT2X2 {
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(2, 2);
2209     }
2210     | DMAT2X3 {
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, 3);
2217     }
2218     | DMAT2X4 {
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, 4);
2225     }
2226     | DMAT3X2 {
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(3, 2);
2233     }
2234     | DMAT3X3 {
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, 3);
2241     }
2242     | DMAT3X4 {
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, 4);
2249     }
2250     | DMAT4X2 {
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(4, 2);
2257     }
2258     | DMAT4X3 {
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, 3);
2265     }
2266     | DMAT4X4 {
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, 4);
2273     }
2274     | F16MAT2 {
2275         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2276         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2277         $$.basicType = EbtFloat16;
2278         $$.setMatrix(2, 2);
2279     }
2280     | F16MAT3 {
2281         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2282         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2283         $$.basicType = EbtFloat16;
2284         $$.setMatrix(3, 3);
2285     }
2286     | F16MAT4 {
2287         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2288         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2289         $$.basicType = EbtFloat16;
2290         $$.setMatrix(4, 4);
2291     }
2292     | F16MAT2X2 {
2293         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2294         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2295         $$.basicType = EbtFloat16;
2296         $$.setMatrix(2, 2);
2297     }
2298     | F16MAT2X3 {
2299         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2300         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2301         $$.basicType = EbtFloat16;
2302         $$.setMatrix(2, 3);
2303     }
2304     | F16MAT2X4 {
2305         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2306         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2307         $$.basicType = EbtFloat16;
2308         $$.setMatrix(2, 4);
2309     }
2310     | F16MAT3X2 {
2311         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2312         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2313         $$.basicType = EbtFloat16;
2314         $$.setMatrix(3, 2);
2315     }
2316     | F16MAT3X3 {
2317         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2318         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2319         $$.basicType = EbtFloat16;
2320         $$.setMatrix(3, 3);
2321     }
2322     | F16MAT3X4 {
2323         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2324         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2325         $$.basicType = EbtFloat16;
2326         $$.setMatrix(3, 4);
2327     }
2328     | F16MAT4X2 {
2329         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2330         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2331         $$.basicType = EbtFloat16;
2332         $$.setMatrix(4, 2);
2333     }
2334     | F16MAT4X3 {
2335         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2336         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2337         $$.basicType = EbtFloat16;
2338         $$.setMatrix(4, 3);
2339     }
2340     | F16MAT4X4 {
2341         parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
2342         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2343         $$.basicType = EbtFloat16;
2344         $$.setMatrix(4, 4);
2345     }
2346     | F32MAT2 {
2347         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2348         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2349         $$.basicType = EbtFloat;
2350         $$.setMatrix(2, 2);
2351     }
2352     | F32MAT3 {
2353         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2354         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2355         $$.basicType = EbtFloat;
2356         $$.setMatrix(3, 3);
2357     }
2358     | F32MAT4 {
2359         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2360         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2361         $$.basicType = EbtFloat;
2362         $$.setMatrix(4, 4);
2363     }
2364     | F32MAT2X2 {
2365         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2366         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2367         $$.basicType = EbtFloat;
2368         $$.setMatrix(2, 2);
2369     }
2370     | F32MAT2X3 {
2371         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2372         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2373         $$.basicType = EbtFloat;
2374         $$.setMatrix(2, 3);
2375     }
2376     | F32MAT2X4 {
2377         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2378         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2379         $$.basicType = EbtFloat;
2380         $$.setMatrix(2, 4);
2381     }
2382     | F32MAT3X2 {
2383         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2384         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2385         $$.basicType = EbtFloat;
2386         $$.setMatrix(3, 2);
2387     }
2388     | F32MAT3X3 {
2389         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2390         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2391         $$.basicType = EbtFloat;
2392         $$.setMatrix(3, 3);
2393     }
2394     | F32MAT3X4 {
2395         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2396         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2397         $$.basicType = EbtFloat;
2398         $$.setMatrix(3, 4);
2399     }
2400     | F32MAT4X2 {
2401         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2402         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2403         $$.basicType = EbtFloat;
2404         $$.setMatrix(4, 2);
2405     }
2406     | F32MAT4X3 {
2407         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2408         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2409         $$.basicType = EbtFloat;
2410         $$.setMatrix(4, 3);
2411     }
2412     | F32MAT4X4 {
2413         parseContext.explicitFloat32Check($1.loc, "float32_t matrix", parseContext.symbolTable.atBuiltInLevel());
2414         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2415         $$.basicType = EbtFloat;
2416         $$.setMatrix(4, 4);
2417     }
2418     | F64MAT2 {
2419         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2420         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2421         $$.basicType = EbtDouble;
2422         $$.setMatrix(2, 2);
2423     }
2424     | F64MAT3 {
2425         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2426         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2427         $$.basicType = EbtDouble;
2428         $$.setMatrix(3, 3);
2429     }
2430     | F64MAT4 {
2431         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2432         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2433         $$.basicType = EbtDouble;
2434         $$.setMatrix(4, 4);
2435     }
2436     | F64MAT2X2 {
2437         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2438         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2439         $$.basicType = EbtDouble;
2440         $$.setMatrix(2, 2);
2441     }
2442     | F64MAT2X3 {
2443         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2444         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2445         $$.basicType = EbtDouble;
2446         $$.setMatrix(2, 3);
2447     }
2448     | F64MAT2X4 {
2449         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2450         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2451         $$.basicType = EbtDouble;
2452         $$.setMatrix(2, 4);
2453     }
2454     | F64MAT3X2 {
2455         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2456         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2457         $$.basicType = EbtDouble;
2458         $$.setMatrix(3, 2);
2459     }
2460     | F64MAT3X3 {
2461         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2462         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2463         $$.basicType = EbtDouble;
2464         $$.setMatrix(3, 3);
2465     }
2466     | F64MAT3X4 {
2467         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2468         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2469         $$.basicType = EbtDouble;
2470         $$.setMatrix(3, 4);
2471     }
2472     | F64MAT4X2 {
2473         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2474         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2475         $$.basicType = EbtDouble;
2476         $$.setMatrix(4, 2);
2477     }
2478     | F64MAT4X3 {
2479         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2480         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2481         $$.basicType = EbtDouble;
2482         $$.setMatrix(4, 3);
2483     }
2484     | F64MAT4X4 {
2485         parseContext.explicitFloat64Check($1.loc, "float64_t matrix", parseContext.symbolTable.atBuiltInLevel());
2486         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2487         $$.basicType = EbtDouble;
2488         $$.setMatrix(4, 4);
2489     }
2490     | ACCSTRUCTNV {
2491        $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2492        $$.basicType = EbtAccStruct;
2493     }
2494     | ACCSTRUCTEXT {
2495        $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2496        $$.basicType = EbtAccStruct;
2497     }
2498     | RAYQUERYEXT {
2499        $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2500        $$.basicType = EbtRayQuery;
2501     }
2502     | ATOMIC_UINT {
2503         parseContext.vulkanRemoved($1.loc, "atomic counter types");
2504         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2505         $$.basicType = EbtAtomicUint;
2506     }
2507     | SAMPLER1D {
2508         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2509         $$.basicType = EbtSampler;
2510         $$.sampler.set(EbtFloat, Esd1D);
2511     }
2512 GLSLANG_WEB_EXCLUDE_OFF
2513     | SAMPLER2D {
2514         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2515         $$.basicType = EbtSampler;
2516         $$.sampler.set(EbtFloat, Esd2D);
2517     }
2518     | SAMPLER3D {
2519         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2520         $$.basicType = EbtSampler;
2521         $$.sampler.set(EbtFloat, Esd3D);
2522     }
2523     | SAMPLERCUBE {
2524         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2525         $$.basicType = EbtSampler;
2526         $$.sampler.set(EbtFloat, EsdCube);
2527     }
2528     | SAMPLER2DSHADOW {
2529         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2530         $$.basicType = EbtSampler;
2531         $$.sampler.set(EbtFloat, Esd2D, false, true);
2532     }
2533     | SAMPLERCUBESHADOW {
2534         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2535         $$.basicType = EbtSampler;
2536         $$.sampler.set(EbtFloat, EsdCube, false, true);
2537     }
2538     | SAMPLER2DARRAY {
2539         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2540         $$.basicType = EbtSampler;
2541         $$.sampler.set(EbtFloat, Esd2D, true);
2542     }
2543     | SAMPLER2DARRAYSHADOW {
2544         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2545         $$.basicType = EbtSampler;
2546         $$.sampler.set(EbtFloat, Esd2D, true, true);
2547     }
2548 GLSLANG_WEB_EXCLUDE_ON
2549     | SAMPLER1DSHADOW {
2550         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2551         $$.basicType = EbtSampler;
2552         $$.sampler.set(EbtFloat, Esd1D, false, true);
2553     }
2554     | SAMPLER1DARRAY {
2555         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2556         $$.basicType = EbtSampler;
2557         $$.sampler.set(EbtFloat, Esd1D, true);
2558     }
2559     | SAMPLER1DARRAYSHADOW {
2560         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2561         $$.basicType = EbtSampler;
2562         $$.sampler.set(EbtFloat, Esd1D, true, true);
2563     }
2564     | SAMPLERCUBEARRAY {
2565         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2566         $$.basicType = EbtSampler;
2567         $$.sampler.set(EbtFloat, EsdCube, true);
2568     }
2569     | SAMPLERCUBEARRAYSHADOW {
2570         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2571         $$.basicType = EbtSampler;
2572         $$.sampler.set(EbtFloat, EsdCube, true, true);
2573     }
2574     | F16SAMPLER1D {
2575         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2576         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2577         $$.basicType = EbtSampler;
2578         $$.sampler.set(EbtFloat16, Esd1D);
2579     }
2580     | F16SAMPLER2D {
2581         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2582         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2583         $$.basicType = EbtSampler;
2584         $$.sampler.set(EbtFloat16, Esd2D);
2585     }
2586     | F16SAMPLER3D {
2587         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2588         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2589         $$.basicType = EbtSampler;
2590         $$.sampler.set(EbtFloat16, Esd3D);
2591     }
2592     | F16SAMPLERCUBE {
2593         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2594         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2595         $$.basicType = EbtSampler;
2596         $$.sampler.set(EbtFloat16, EsdCube);
2597     }
2598     | F16SAMPLER1DSHADOW {
2599         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2600         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2601         $$.basicType = EbtSampler;
2602         $$.sampler.set(EbtFloat16, Esd1D, false, true);
2603     }
2604     | F16SAMPLER2DSHADOW {
2605         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2606         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2607         $$.basicType = EbtSampler;
2608         $$.sampler.set(EbtFloat16, Esd2D, false, true);
2609     }
2610     | F16SAMPLERCUBESHADOW {
2611         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2612         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2613         $$.basicType = EbtSampler;
2614         $$.sampler.set(EbtFloat16, EsdCube, false, true);
2615     }
2616     | F16SAMPLER1DARRAY {
2617         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2618         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2619         $$.basicType = EbtSampler;
2620         $$.sampler.set(EbtFloat16, Esd1D, true);
2621     }
2622     | F16SAMPLER2DARRAY {
2623         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2624         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2625         $$.basicType = EbtSampler;
2626         $$.sampler.set(EbtFloat16, Esd2D, true);
2627     }
2628     | F16SAMPLER1DARRAYSHADOW {
2629         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2630         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2631         $$.basicType = EbtSampler;
2632         $$.sampler.set(EbtFloat16, Esd1D, true, true);
2633     }
2634     | F16SAMPLER2DARRAYSHADOW {
2635         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2636         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2637         $$.basicType = EbtSampler;
2638         $$.sampler.set(EbtFloat16, Esd2D, true, true);
2639     }
2640     | F16SAMPLERCUBEARRAY {
2641         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2642         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2643         $$.basicType = EbtSampler;
2644         $$.sampler.set(EbtFloat16, EsdCube, true);
2645     }
2646     | F16SAMPLERCUBEARRAYSHADOW {
2647         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2648         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2649         $$.basicType = EbtSampler;
2650         $$.sampler.set(EbtFloat16, EsdCube, true, true);
2651     }
2652     | ISAMPLER1D {
2653         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2654         $$.basicType = EbtSampler;
2655         $$.sampler.set(EbtInt, Esd1D);
2656     }
2657 GLSLANG_WEB_EXCLUDE_OFF
2658     | ISAMPLER2D {
2659         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2660         $$.basicType = EbtSampler;
2661         $$.sampler.set(EbtInt, Esd2D);
2662     }
2663     | ISAMPLER3D {
2664         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2665         $$.basicType = EbtSampler;
2666         $$.sampler.set(EbtInt, Esd3D);
2667     }
2668     | ISAMPLERCUBE {
2669         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2670         $$.basicType = EbtSampler;
2671         $$.sampler.set(EbtInt, EsdCube);
2672     }
2673     | ISAMPLER2DARRAY {
2674         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2675         $$.basicType = EbtSampler;
2676         $$.sampler.set(EbtInt, Esd2D, true);
2677     }
2678     | USAMPLER2D {
2679         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2680         $$.basicType = EbtSampler;
2681         $$.sampler.set(EbtUint, Esd2D);
2682     }
2683     | USAMPLER3D {
2684         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2685         $$.basicType = EbtSampler;
2686         $$.sampler.set(EbtUint, Esd3D);
2687     }
2688     | USAMPLERCUBE {
2689         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2690         $$.basicType = EbtSampler;
2691         $$.sampler.set(EbtUint, EsdCube);
2692     }
2693 GLSLANG_WEB_EXCLUDE_ON
2694     | ISAMPLER1DARRAY {
2695         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2696         $$.basicType = EbtSampler;
2697         $$.sampler.set(EbtInt, Esd1D, true);
2698     }
2699     | ISAMPLERCUBEARRAY {
2700         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2701         $$.basicType = EbtSampler;
2702         $$.sampler.set(EbtInt, EsdCube, true);
2703     }
2704     | USAMPLER1D {
2705         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2706         $$.basicType = EbtSampler;
2707         $$.sampler.set(EbtUint, Esd1D);
2708     }
2709     | USAMPLER1DARRAY {
2710         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2711         $$.basicType = EbtSampler;
2712         $$.sampler.set(EbtUint, Esd1D, true);
2713     }
2714     | USAMPLERCUBEARRAY {
2715         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2716         $$.basicType = EbtSampler;
2717         $$.sampler.set(EbtUint, EsdCube, true);
2718     }
2719     | TEXTURECUBEARRAY {
2720         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2721         $$.basicType = EbtSampler;
2722         $$.sampler.setTexture(EbtFloat, EsdCube, true);
2723     }
2724     | ITEXTURECUBEARRAY {
2725         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2726         $$.basicType = EbtSampler;
2727         $$.sampler.setTexture(EbtInt, EsdCube, true);
2728     }
2729     | UTEXTURECUBEARRAY {
2730         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2731         $$.basicType = EbtSampler;
2732         $$.sampler.setTexture(EbtUint, EsdCube, true);
2733     }
2734 GLSLANG_WEB_EXCLUDE_OFF
2735     | USAMPLER2DARRAY {
2736         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2737         $$.basicType = EbtSampler;
2738         $$.sampler.set(EbtUint, Esd2D, true);
2739     }
2740     | TEXTURE2D {
2741         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2742         $$.basicType = EbtSampler;
2743         $$.sampler.setTexture(EbtFloat, Esd2D);
2744     }
2745     | TEXTURE3D {
2746         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2747         $$.basicType = EbtSampler;
2748         $$.sampler.setTexture(EbtFloat, Esd3D);
2749     }
2750     | TEXTURE2DARRAY {
2751         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2752         $$.basicType = EbtSampler;
2753         $$.sampler.setTexture(EbtFloat, Esd2D, true);
2754     }
2755     | TEXTURECUBE {
2756         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2757         $$.basicType = EbtSampler;
2758         $$.sampler.setTexture(EbtFloat, EsdCube);
2759     }
2760     | ITEXTURE2D {
2761         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2762         $$.basicType = EbtSampler;
2763         $$.sampler.setTexture(EbtInt, Esd2D);
2764     }
2765     | ITEXTURE3D {
2766         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2767         $$.basicType = EbtSampler;
2768         $$.sampler.setTexture(EbtInt, Esd3D);
2769     }
2770     | ITEXTURECUBE {
2771         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2772         $$.basicType = EbtSampler;
2773         $$.sampler.setTexture(EbtInt, EsdCube);
2774     }
2775     | ITEXTURE2DARRAY {
2776         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2777         $$.basicType = EbtSampler;
2778         $$.sampler.setTexture(EbtInt, Esd2D, true);
2779     }
2780     | UTEXTURE2D {
2781         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2782         $$.basicType = EbtSampler;
2783         $$.sampler.setTexture(EbtUint, Esd2D);
2784     }
2785     | UTEXTURE3D {
2786         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2787         $$.basicType = EbtSampler;
2788         $$.sampler.setTexture(EbtUint, Esd3D);
2789     }
2790     | UTEXTURECUBE {
2791         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2792         $$.basicType = EbtSampler;
2793         $$.sampler.setTexture(EbtUint, EsdCube);
2794     }
2795     | UTEXTURE2DARRAY {
2796         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2797         $$.basicType = EbtSampler;
2798         $$.sampler.setTexture(EbtUint, Esd2D, true);
2799     }
2800     | SAMPLER {
2801         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2802         $$.basicType = EbtSampler;
2803         $$.sampler.setPureSampler(false);
2804     }
2805     | SAMPLERSHADOW {
2806         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2807         $$.basicType = EbtSampler;
2808         $$.sampler.setPureSampler(true);
2809     }
2810 GLSLANG_WEB_EXCLUDE_ON
2811     | SAMPLER2DRECT {
2812         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2813         $$.basicType = EbtSampler;
2814         $$.sampler.set(EbtFloat, EsdRect);
2815     }
2816     | SAMPLER2DRECTSHADOW {
2817         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2818         $$.basicType = EbtSampler;
2819         $$.sampler.set(EbtFloat, EsdRect, false, true);
2820     }
2821     | F16SAMPLER2DRECT {
2822         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2823         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2824         $$.basicType = EbtSampler;
2825         $$.sampler.set(EbtFloat16, EsdRect);
2826     }
2827     | F16SAMPLER2DRECTSHADOW {
2828         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2829         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2830         $$.basicType = EbtSampler;
2831         $$.sampler.set(EbtFloat16, EsdRect, false, true);
2832     }
2833     | ISAMPLER2DRECT {
2834         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2835         $$.basicType = EbtSampler;
2836         $$.sampler.set(EbtInt, EsdRect);
2837     }
2838     | USAMPLER2DRECT {
2839         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2840         $$.basicType = EbtSampler;
2841         $$.sampler.set(EbtUint, EsdRect);
2842     }
2843     | SAMPLERBUFFER {
2844         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2845         $$.basicType = EbtSampler;
2846         $$.sampler.set(EbtFloat, EsdBuffer);
2847     }
2848     | F16SAMPLERBUFFER {
2849         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2850         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2851         $$.basicType = EbtSampler;
2852         $$.sampler.set(EbtFloat16, EsdBuffer);
2853     }
2854     | ISAMPLERBUFFER {
2855         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2856         $$.basicType = EbtSampler;
2857         $$.sampler.set(EbtInt, EsdBuffer);
2858     }
2859     | USAMPLERBUFFER {
2860         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2861         $$.basicType = EbtSampler;
2862         $$.sampler.set(EbtUint, EsdBuffer);
2863     }
2864     | SAMPLER2DMS {
2865         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2866         $$.basicType = EbtSampler;
2867         $$.sampler.set(EbtFloat, Esd2D, false, false, true);
2868     }
2869     | F16SAMPLER2DMS {
2870         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2871         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2872         $$.basicType = EbtSampler;
2873         $$.sampler.set(EbtFloat16, Esd2D, false, false, true);
2874     }
2875     | ISAMPLER2DMS {
2876         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2877         $$.basicType = EbtSampler;
2878         $$.sampler.set(EbtInt, Esd2D, false, false, true);
2879     }
2880     | USAMPLER2DMS {
2881         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2882         $$.basicType = EbtSampler;
2883         $$.sampler.set(EbtUint, Esd2D, false, false, true);
2884     }
2885     | SAMPLER2DMSARRAY {
2886         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2887         $$.basicType = EbtSampler;
2888         $$.sampler.set(EbtFloat, Esd2D, true, false, true);
2889     }
2890     | F16SAMPLER2DMSARRAY {
2891         parseContext.float16OpaqueCheck($1.loc, "half float sampler", parseContext.symbolTable.atBuiltInLevel());
2892         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2893         $$.basicType = EbtSampler;
2894         $$.sampler.set(EbtFloat16, Esd2D, true, false, true);
2895     }
2896     | ISAMPLER2DMSARRAY {
2897         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2898         $$.basicType = EbtSampler;
2899         $$.sampler.set(EbtInt, Esd2D, true, false, true);
2900     }
2901     | USAMPLER2DMSARRAY {
2902         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2903         $$.basicType = EbtSampler;
2904         $$.sampler.set(EbtUint, Esd2D, true, false, true);
2905     }
2906     | TEXTURE1D {
2907         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2908         $$.basicType = EbtSampler;
2909         $$.sampler.setTexture(EbtFloat, Esd1D);
2910     }
2911     | F16TEXTURE1D {
2912         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2913         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2914         $$.basicType = EbtSampler;
2915         $$.sampler.setTexture(EbtFloat16, Esd1D);
2916     }
2917     | F16TEXTURE2D {
2918         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2919         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2920         $$.basicType = EbtSampler;
2921         $$.sampler.setTexture(EbtFloat16, Esd2D);
2922     }
2923     | F16TEXTURE3D {
2924         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2925         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2926         $$.basicType = EbtSampler;
2927         $$.sampler.setTexture(EbtFloat16, Esd3D);
2928     }
2929     | F16TEXTURECUBE {
2930         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2931         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2932         $$.basicType = EbtSampler;
2933         $$.sampler.setTexture(EbtFloat16, EsdCube);
2934     }
2935     | TEXTURE1DARRAY {
2936         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2937         $$.basicType = EbtSampler;
2938         $$.sampler.setTexture(EbtFloat, Esd1D, true);
2939     }
2940     | F16TEXTURE1DARRAY {
2941         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2942         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2943         $$.basicType = EbtSampler;
2944         $$.sampler.setTexture(EbtFloat16, Esd1D, true);
2945     }
2946     | F16TEXTURE2DARRAY {
2947         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2948         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2949         $$.basicType = EbtSampler;
2950         $$.sampler.setTexture(EbtFloat16, Esd2D, true);
2951     }
2952     | F16TEXTURECUBEARRAY {
2953         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2954         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2955         $$.basicType = EbtSampler;
2956         $$.sampler.setTexture(EbtFloat16, EsdCube, true);
2957     }
2958     | ITEXTURE1D {
2959         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2960         $$.basicType = EbtSampler;
2961         $$.sampler.setTexture(EbtInt, Esd1D);
2962     }
2963     | ITEXTURE1DARRAY {
2964         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2965         $$.basicType = EbtSampler;
2966         $$.sampler.setTexture(EbtInt, Esd1D, true);
2967     }
2968     | UTEXTURE1D {
2969         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2970         $$.basicType = EbtSampler;
2971         $$.sampler.setTexture(EbtUint, Esd1D);
2972     }
2973     | UTEXTURE1DARRAY {
2974         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2975         $$.basicType = EbtSampler;
2976         $$.sampler.setTexture(EbtUint, Esd1D, true);
2977     }
2978     | TEXTURE2DRECT {
2979         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2980         $$.basicType = EbtSampler;
2981         $$.sampler.setTexture(EbtFloat, EsdRect);
2982     }
2983     | F16TEXTURE2DRECT {
2984         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
2985         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2986         $$.basicType = EbtSampler;
2987         $$.sampler.setTexture(EbtFloat16, EsdRect);
2988     }
2989     | ITEXTURE2DRECT {
2990         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2991         $$.basicType = EbtSampler;
2992         $$.sampler.setTexture(EbtInt, EsdRect);
2993     }
2994     | UTEXTURE2DRECT {
2995         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
2996         $$.basicType = EbtSampler;
2997         $$.sampler.setTexture(EbtUint, EsdRect);
2998     }
2999     | TEXTUREBUFFER {
3000         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3001         $$.basicType = EbtSampler;
3002         $$.sampler.setTexture(EbtFloat, EsdBuffer);
3003     }
3004     | F16TEXTUREBUFFER {
3005         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
3006         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3007         $$.basicType = EbtSampler;
3008         $$.sampler.setTexture(EbtFloat16, EsdBuffer);
3009     }
3010     | ITEXTUREBUFFER {
3011         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3012         $$.basicType = EbtSampler;
3013         $$.sampler.setTexture(EbtInt, EsdBuffer);
3014     }
3015     | UTEXTUREBUFFER {
3016         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3017         $$.basicType = EbtSampler;
3018         $$.sampler.setTexture(EbtUint, EsdBuffer);
3019     }
3020     | TEXTURE2DMS {
3021         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3022         $$.basicType = EbtSampler;
3023         $$.sampler.setTexture(EbtFloat, Esd2D, false, false, true);
3024     }
3025     | F16TEXTURE2DMS {
3026         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
3027         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3028         $$.basicType = EbtSampler;
3029         $$.sampler.setTexture(EbtFloat16, Esd2D, false, false, true);
3030     }
3031     | ITEXTURE2DMS {
3032         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3033         $$.basicType = EbtSampler;
3034         $$.sampler.setTexture(EbtInt, Esd2D, false, false, true);
3035     }
3036     | UTEXTURE2DMS {
3037         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3038         $$.basicType = EbtSampler;
3039         $$.sampler.setTexture(EbtUint, Esd2D, false, false, true);
3040     }
3041     | TEXTURE2DMSARRAY {
3042         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3043         $$.basicType = EbtSampler;
3044         $$.sampler.setTexture(EbtFloat, Esd2D, true, false, true);
3045     }
3046     | F16TEXTURE2DMSARRAY {
3047         parseContext.float16OpaqueCheck($1.loc, "half float texture", parseContext.symbolTable.atBuiltInLevel());
3048         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3049         $$.basicType = EbtSampler;
3050         $$.sampler.setTexture(EbtFloat16, Esd2D, true, false, true);
3051     }
3052     | ITEXTURE2DMSARRAY {
3053         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3054         $$.basicType = EbtSampler;
3055         $$.sampler.setTexture(EbtInt, Esd2D, true, false, true);
3056     }
3057     | UTEXTURE2DMSARRAY {
3058         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3059         $$.basicType = EbtSampler;
3060         $$.sampler.setTexture(EbtUint, Esd2D, true, false, true);
3061     }
3062     | IMAGE1D {
3063         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3064         $$.basicType = EbtSampler;
3065         $$.sampler.setImage(EbtFloat, Esd1D);
3066     }
3067     | F16IMAGE1D {
3068         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3069         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3070         $$.basicType = EbtSampler;
3071         $$.sampler.setImage(EbtFloat16, Esd1D);
3072     }
3073     | IIMAGE1D {
3074         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3075         $$.basicType = EbtSampler;
3076         $$.sampler.setImage(EbtInt, Esd1D);
3077     }
3078     | UIMAGE1D {
3079         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3080         $$.basicType = EbtSampler;
3081         $$.sampler.setImage(EbtUint, Esd1D);
3082     }
3083     | IMAGE2D {
3084         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3085         $$.basicType = EbtSampler;
3086         $$.sampler.setImage(EbtFloat, Esd2D);
3087     }
3088     | F16IMAGE2D {
3089         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3090         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3091         $$.basicType = EbtSampler;
3092         $$.sampler.setImage(EbtFloat16, Esd2D);
3093     }
3094     | IIMAGE2D {
3095         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3096         $$.basicType = EbtSampler;
3097         $$.sampler.setImage(EbtInt, Esd2D);
3098     }
3099     | UIMAGE2D {
3100         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3101         $$.basicType = EbtSampler;
3102         $$.sampler.setImage(EbtUint, Esd2D);
3103     }
3104     | IMAGE3D {
3105         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3106         $$.basicType = EbtSampler;
3107         $$.sampler.setImage(EbtFloat, Esd3D);
3108     }
3109     | F16IMAGE3D {
3110         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3111         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3112         $$.basicType = EbtSampler;
3113         $$.sampler.setImage(EbtFloat16, Esd3D);
3114     }
3115     | IIMAGE3D {
3116         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3117         $$.basicType = EbtSampler;
3118         $$.sampler.setImage(EbtInt, Esd3D);
3119     }
3120     | UIMAGE3D {
3121         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3122         $$.basicType = EbtSampler;
3123         $$.sampler.setImage(EbtUint, Esd3D);
3124     }
3125     | IMAGE2DRECT {
3126         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3127         $$.basicType = EbtSampler;
3128         $$.sampler.setImage(EbtFloat, EsdRect);
3129     }
3130     | F16IMAGE2DRECT {
3131         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3132         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3133         $$.basicType = EbtSampler;
3134         $$.sampler.setImage(EbtFloat16, EsdRect);
3135     }
3136     | IIMAGE2DRECT {
3137         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3138         $$.basicType = EbtSampler;
3139         $$.sampler.setImage(EbtInt, EsdRect);
3140     }
3141     | UIMAGE2DRECT {
3142         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3143         $$.basicType = EbtSampler;
3144         $$.sampler.setImage(EbtUint, EsdRect);
3145     }
3146     | IMAGECUBE {
3147         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3148         $$.basicType = EbtSampler;
3149         $$.sampler.setImage(EbtFloat, EsdCube);
3150     }
3151     | F16IMAGECUBE {
3152         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3153         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3154         $$.basicType = EbtSampler;
3155         $$.sampler.setImage(EbtFloat16, EsdCube);
3156     }
3157     | IIMAGECUBE {
3158         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3159         $$.basicType = EbtSampler;
3160         $$.sampler.setImage(EbtInt, EsdCube);
3161     }
3162     | UIMAGECUBE {
3163         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3164         $$.basicType = EbtSampler;
3165         $$.sampler.setImage(EbtUint, EsdCube);
3166     }
3167     | IMAGEBUFFER {
3168         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3169         $$.basicType = EbtSampler;
3170         $$.sampler.setImage(EbtFloat, EsdBuffer);
3171     }
3172     | F16IMAGEBUFFER {
3173         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3174         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3175         $$.basicType = EbtSampler;
3176         $$.sampler.setImage(EbtFloat16, EsdBuffer);
3177     }
3178     | IIMAGEBUFFER {
3179         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3180         $$.basicType = EbtSampler;
3181         $$.sampler.setImage(EbtInt, EsdBuffer);
3182     }
3183     | UIMAGEBUFFER {
3184         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3185         $$.basicType = EbtSampler;
3186         $$.sampler.setImage(EbtUint, EsdBuffer);
3187     }
3188     | IMAGE1DARRAY {
3189         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3190         $$.basicType = EbtSampler;
3191         $$.sampler.setImage(EbtFloat, Esd1D, true);
3192     }
3193     | F16IMAGE1DARRAY {
3194         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3195         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3196         $$.basicType = EbtSampler;
3197         $$.sampler.setImage(EbtFloat16, Esd1D, true);
3198     }
3199     | IIMAGE1DARRAY {
3200         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3201         $$.basicType = EbtSampler;
3202         $$.sampler.setImage(EbtInt, Esd1D, true);
3203     }
3204     | UIMAGE1DARRAY {
3205         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3206         $$.basicType = EbtSampler;
3207         $$.sampler.setImage(EbtUint, Esd1D, true);
3208     }
3209     | IMAGE2DARRAY {
3210         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3211         $$.basicType = EbtSampler;
3212         $$.sampler.setImage(EbtFloat, Esd2D, true);
3213     }
3214     | F16IMAGE2DARRAY {
3215         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3216         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3217         $$.basicType = EbtSampler;
3218         $$.sampler.setImage(EbtFloat16, Esd2D, true);
3219     }
3220     | IIMAGE2DARRAY {
3221         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3222         $$.basicType = EbtSampler;
3223         $$.sampler.setImage(EbtInt, Esd2D, true);
3224     }
3225     | UIMAGE2DARRAY {
3226         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3227         $$.basicType = EbtSampler;
3228         $$.sampler.setImage(EbtUint, Esd2D, true);
3229     }
3230     | IMAGECUBEARRAY {
3231         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3232         $$.basicType = EbtSampler;
3233         $$.sampler.setImage(EbtFloat, EsdCube, true);
3234     }
3235     | F16IMAGECUBEARRAY {
3236         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3237         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3238         $$.basicType = EbtSampler;
3239         $$.sampler.setImage(EbtFloat16, EsdCube, true);
3240     }
3241     | IIMAGECUBEARRAY {
3242         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3243         $$.basicType = EbtSampler;
3244         $$.sampler.setImage(EbtInt, EsdCube, true);
3245     }
3246     | UIMAGECUBEARRAY {
3247         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3248         $$.basicType = EbtSampler;
3249         $$.sampler.setImage(EbtUint, EsdCube, true);
3250     }
3251     | IMAGE2DMS {
3252         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3253         $$.basicType = EbtSampler;
3254         $$.sampler.setImage(EbtFloat, Esd2D, false, false, true);
3255     }
3256     | F16IMAGE2DMS {
3257         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3258         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3259         $$.basicType = EbtSampler;
3260         $$.sampler.setImage(EbtFloat16, Esd2D, false, false, true);
3261     }
3262     | IIMAGE2DMS {
3263         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3264         $$.basicType = EbtSampler;
3265         $$.sampler.setImage(EbtInt, Esd2D, false, false, true);
3266     }
3267     | UIMAGE2DMS {
3268         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3269         $$.basicType = EbtSampler;
3270         $$.sampler.setImage(EbtUint, Esd2D, false, false, true);
3271     }
3272     | IMAGE2DMSARRAY {
3273         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3274         $$.basicType = EbtSampler;
3275         $$.sampler.setImage(EbtFloat, Esd2D, true, false, true);
3276     }
3277     | F16IMAGE2DMSARRAY {
3278         parseContext.float16OpaqueCheck($1.loc, "half float image", parseContext.symbolTable.atBuiltInLevel());
3279         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3280         $$.basicType = EbtSampler;
3281         $$.sampler.setImage(EbtFloat16, Esd2D, true, false, true);
3282     }
3283     | IIMAGE2DMSARRAY {
3284         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3285         $$.basicType = EbtSampler;
3286         $$.sampler.setImage(EbtInt, Esd2D, true, false, true);
3287     }
3288     | UIMAGE2DMSARRAY {
3289         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3290         $$.basicType = EbtSampler;
3291         $$.sampler.setImage(EbtUint, Esd2D, true, false, true);
3292     }
3293     | I64IMAGE1D {
3294         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3295         $$.basicType = EbtSampler;
3296         $$.sampler.setImage(EbtInt64, Esd1D);
3297     }
3298     | U64IMAGE1D {
3299         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3300         $$.basicType = EbtSampler;
3301         $$.sampler.setImage(EbtUint64, Esd1D);
3302     }
3303     | I64IMAGE2D {
3304         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3305         $$.basicType = EbtSampler;
3306         $$.sampler.setImage(EbtInt64, Esd2D);
3307     }
3308     | U64IMAGE2D {
3309         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3310         $$.basicType = EbtSampler;
3311         $$.sampler.setImage(EbtUint64, Esd2D);
3312     }
3313     | I64IMAGE3D {
3314         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3315         $$.basicType = EbtSampler;
3316         $$.sampler.setImage(EbtInt64, Esd3D);
3317     }
3318     | U64IMAGE3D {
3319         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3320         $$.basicType = EbtSampler;
3321         $$.sampler.setImage(EbtUint64, Esd3D);
3322     }
3323     | I64IMAGE2DRECT {
3324         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3325         $$.basicType = EbtSampler;
3326         $$.sampler.setImage(EbtInt64, EsdRect);
3327     }
3328     | U64IMAGE2DRECT {
3329         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3330         $$.basicType = EbtSampler;
3331         $$.sampler.setImage(EbtUint64, EsdRect);
3332     }
3333     | I64IMAGECUBE {
3334         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3335         $$.basicType = EbtSampler;
3336         $$.sampler.setImage(EbtInt64, EsdCube);
3337     }
3338     | U64IMAGECUBE {
3339         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3340         $$.basicType = EbtSampler;
3341         $$.sampler.setImage(EbtUint64, EsdCube);
3342     }
3343     | I64IMAGEBUFFER {
3344         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3345         $$.basicType = EbtSampler;
3346         $$.sampler.setImage(EbtInt64, EsdBuffer);
3347     }
3348     | U64IMAGEBUFFER {
3349         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3350         $$.basicType = EbtSampler;
3351         $$.sampler.setImage(EbtUint64, EsdBuffer);
3352     }
3353     | I64IMAGE1DARRAY {
3354         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3355         $$.basicType = EbtSampler;
3356         $$.sampler.setImage(EbtInt64, Esd1D, true);
3357     }
3358     | U64IMAGE1DARRAY {
3359         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3360         $$.basicType = EbtSampler;
3361         $$.sampler.setImage(EbtUint64, Esd1D, true);
3362     }
3363     | I64IMAGE2DARRAY {
3364         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3365         $$.basicType = EbtSampler;
3366         $$.sampler.setImage(EbtInt64, Esd2D, true);
3367     }
3368     | U64IMAGE2DARRAY {
3369         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3370         $$.basicType = EbtSampler;
3371         $$.sampler.setImage(EbtUint64, Esd2D, true);
3372     }
3373     | I64IMAGECUBEARRAY {
3374         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3375         $$.basicType = EbtSampler;
3376         $$.sampler.setImage(EbtInt64, EsdCube, true);
3377     }
3378     | U64IMAGECUBEARRAY {
3379         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3380         $$.basicType = EbtSampler;
3381         $$.sampler.setImage(EbtUint64, EsdCube, true);
3382     }
3383     | I64IMAGE2DMS {
3384         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3385         $$.basicType = EbtSampler;
3386         $$.sampler.setImage(EbtInt64, Esd2D, false, false, true);
3387     }
3388     | U64IMAGE2DMS {
3389         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3390         $$.basicType = EbtSampler;
3391         $$.sampler.setImage(EbtUint64, Esd2D, false, false, true);
3392     }
3393     | I64IMAGE2DMSARRAY {
3394         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3395         $$.basicType = EbtSampler;
3396         $$.sampler.setImage(EbtInt64, Esd2D, true, false, true);
3397     }
3398     | U64IMAGE2DMSARRAY {
3399         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3400         $$.basicType = EbtSampler;
3401         $$.sampler.setImage(EbtUint64, Esd2D, true, false, true);
3402     }
3403     | SAMPLEREXTERNALOES {  // GL_OES_EGL_image_external
3404         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3405         $$.basicType = EbtSampler;
3406         $$.sampler.set(EbtFloat, Esd2D);
3407         $$.sampler.external = true;
3408     }
3409     | SAMPLEREXTERNAL2DY2YEXT { // GL_EXT_YUV_target
3410         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3411         $$.basicType = EbtSampler;
3412         $$.sampler.set(EbtFloat, Esd2D);
3413         $$.sampler.yuv = true;
3414     }
3415     | SUBPASSINPUT {
3416         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3417         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3418         $$.basicType = EbtSampler;
3419         $$.sampler.setSubpass(EbtFloat);
3420     }
3421     | SUBPASSINPUTMS {
3422         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3423         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3424         $$.basicType = EbtSampler;
3425         $$.sampler.setSubpass(EbtFloat, true);
3426     }
3427     | F16SUBPASSINPUT {
3428         parseContext.float16OpaqueCheck($1.loc, "half float subpass input", parseContext.symbolTable.atBuiltInLevel());
3429         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3430         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3431         $$.basicType = EbtSampler;
3432         $$.sampler.setSubpass(EbtFloat16);
3433     }
3434     | F16SUBPASSINPUTMS {
3435         parseContext.float16OpaqueCheck($1.loc, "half float subpass input", parseContext.symbolTable.atBuiltInLevel());
3436         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3437         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3438         $$.basicType = EbtSampler;
3439         $$.sampler.setSubpass(EbtFloat16, true);
3440     }
3441     | ISUBPASSINPUT {
3442         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3443         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3444         $$.basicType = EbtSampler;
3445         $$.sampler.setSubpass(EbtInt);
3446     }
3447     | ISUBPASSINPUTMS {
3448         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3449         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3450         $$.basicType = EbtSampler;
3451         $$.sampler.setSubpass(EbtInt, true);
3452     }
3453     | USUBPASSINPUT {
3454         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3455         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3456         $$.basicType = EbtSampler;
3457         $$.sampler.setSubpass(EbtUint);
3458     }
3459     | USUBPASSINPUTMS {
3460         parseContext.requireStage($1.loc, EShLangFragment, "subpass input");
3461         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3462         $$.basicType = EbtSampler;
3463         $$.sampler.setSubpass(EbtUint, true);
3464     }
3465     | FCOOPMATNV {
3466         parseContext.fcoopmatCheck($1.loc, "fcoopmatNV", parseContext.symbolTable.atBuiltInLevel());
3467         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3468         $$.basicType = EbtFloat;
3469         $$.coopmat = true;
3470     }
3471     | ICOOPMATNV {
3472         parseContext.intcoopmatCheck($1.loc, "icoopmatNV", parseContext.symbolTable.atBuiltInLevel());
3473         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3474         $$.basicType = EbtInt;
3475         $$.coopmat = true;
3476     }
3477     | UCOOPMATNV {
3478         parseContext.intcoopmatCheck($1.loc, "ucoopmatNV", parseContext.symbolTable.atBuiltInLevel());
3479         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3480         $$.basicType = EbtUint;
3481         $$.coopmat = true;
3482     }
3483     | spirv_type_specifier {
3484         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_spirv_intrinsics, "SPIR-V type specifier");
3485         $$ = $1;
3486     }
3487 GLSLANG_WEB_EXCLUDE_OFF
3488     | struct_specifier {
3489         $$ = $1;
3490         $$.qualifier.storage = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
3491         parseContext.structTypeCheck($$.loc, $$);
3492     }
3493     | TYPE_NAME {
3494         //
3495         // This is for user defined type names.  The lexical phase looked up the
3496         // type.
3497         //
3498         if (const TVariable* variable = ($1.symbol)->getAsVariable()) {
3499             const TType& structure = variable->getType();
3500             $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3501             $$.basicType = EbtStruct;
3502             $$.userDef = &structure;
3503         } else
3504             parseContext.error($1.loc, "expected type name", $1.string->c_str(), "");
3505     }
3506     ;
3507
3508 precision_qualifier
3509     : HIGH_PRECISION {
3510         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "highp precision qualifier");
3511         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3512         parseContext.handlePrecisionQualifier($1.loc, $$.qualifier, EpqHigh);
3513     }
3514     | MEDIUM_PRECISION {
3515         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "mediump precision qualifier");
3516         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3517         parseContext.handlePrecisionQualifier($1.loc, $$.qualifier, EpqMedium);
3518     }
3519     | LOW_PRECISION {
3520         parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "lowp precision qualifier");
3521         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
3522         parseContext.handlePrecisionQualifier($1.loc, $$.qualifier, EpqLow);
3523     }
3524     ;
3525
3526 struct_specifier
3527     : STRUCT IDENTIFIER LEFT_BRACE { parseContext.nestedStructCheck($1.loc); } struct_declaration_list RIGHT_BRACE {
3528         TType* structure = new TType($5, *$2.string);
3529         parseContext.structArrayCheck($2.loc, *structure);
3530         TVariable* userTypeDef = new TVariable($2.string, *structure, true);
3531         if (! parseContext.symbolTable.insert(*userTypeDef))
3532             parseContext.error($2.loc, "redefinition", $2.string->c_str(), "struct");
3533         $$.init($1.loc);
3534         $$.basicType = EbtStruct;
3535         $$.userDef = structure;
3536         --parseContext.structNestingLevel;
3537     }
3538     | STRUCT LEFT_BRACE { parseContext.nestedStructCheck($1.loc); } struct_declaration_list RIGHT_BRACE {
3539         TType* structure = new TType($4, TString(""));
3540         $$.init($1.loc);
3541         $$.basicType = EbtStruct;
3542         $$.userDef = structure;
3543         --parseContext.structNestingLevel;
3544     }
3545     ;
3546
3547 struct_declaration_list
3548     : struct_declaration {
3549         $$ = $1;
3550     }
3551     | struct_declaration_list struct_declaration {
3552         $$ = $1;
3553         for (unsigned int i = 0; i < $2->size(); ++i) {
3554             for (unsigned int j = 0; j < $$->size(); ++j) {
3555                 if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName())
3556                     parseContext.error((*$2)[i].loc, "duplicate member name:", "", (*$2)[i].type->getFieldName().c_str());
3557             }
3558             $$->push_back((*$2)[i]);
3559         }
3560     }
3561     ;
3562
3563 struct_declaration
3564     : type_specifier struct_declarator_list SEMICOLON {
3565         if ($1.arraySizes) {
3566             parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
3567             parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
3568             if (parseContext.isEsProfile())
3569                 parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
3570         }
3571
3572         $$ = $2;
3573
3574         parseContext.voidErrorCheck($1.loc, (*$2)[0].type->getFieldName(), $1.basicType);
3575         parseContext.precisionQualifierCheck($1.loc, $1.basicType, $1.qualifier);
3576
3577         for (unsigned int i = 0; i < $$->size(); ++i) {
3578             TType type($1);
3579             type.setFieldName((*$$)[i].type->getFieldName());
3580             type.transferArraySizes((*$$)[i].type->getArraySizes());
3581             type.copyArrayInnerSizes($1.arraySizes);
3582             parseContext.arrayOfArrayVersionCheck((*$$)[i].loc, type.getArraySizes());
3583             (*$$)[i].type->shallowCopy(type);
3584         }
3585     }
3586     | type_qualifier type_specifier struct_declarator_list SEMICOLON {
3587         if ($2.arraySizes) {
3588             parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
3589             parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
3590             if (parseContext.isEsProfile())
3591                 parseContext.arraySizeRequiredCheck($2.loc, *$2.arraySizes);
3592         }
3593
3594         $$ = $3;
3595
3596         parseContext.memberQualifierCheck($1);
3597         parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType);
3598         parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true);
3599         parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
3600
3601         for (unsigned int i = 0; i < $$->size(); ++i) {
3602             TType type($2);
3603             type.setFieldName((*$$)[i].type->getFieldName());
3604             type.transferArraySizes((*$$)[i].type->getArraySizes());
3605             type.copyArrayInnerSizes($2.arraySizes);
3606             parseContext.arrayOfArrayVersionCheck((*$$)[i].loc, type.getArraySizes());
3607             (*$$)[i].type->shallowCopy(type);
3608         }
3609     }
3610     ;
3611
3612 struct_declarator_list
3613     : struct_declarator {
3614         $$ = new TTypeList;
3615         $$->push_back($1);
3616     }
3617     | struct_declarator_list COMMA struct_declarator {
3618         $$->push_back($3);
3619     }
3620     ;
3621
3622 struct_declarator
3623     : IDENTIFIER {
3624         $$.type = new TType(EbtVoid);
3625         $$.loc = $1.loc;
3626         $$.type->setFieldName(*$1.string);
3627     }
3628     | IDENTIFIER array_specifier {
3629         parseContext.arrayOfArrayVersionCheck($1.loc, $2.arraySizes);
3630
3631         $$.type = new TType(EbtVoid);
3632         $$.loc = $1.loc;
3633         $$.type->setFieldName(*$1.string);
3634         $$.type->transferArraySizes($2.arraySizes);
3635     }
3636     ;
3637
3638 initializer
3639     : assignment_expression {
3640         $$ = $1;
3641     }
3642 GLSLANG_WEB_EXCLUDE_ON
3643     | LEFT_BRACE initializer_list RIGHT_BRACE {
3644         const char* initFeature = "{ } style initializers";
3645         parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
3646         parseContext.profileRequires($1.loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, initFeature);
3647         $$ = $2;
3648     }
3649     | LEFT_BRACE initializer_list COMMA RIGHT_BRACE {
3650         const char* initFeature = "{ } style initializers";
3651         parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
3652         parseContext.profileRequires($1.loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, initFeature);
3653         $$ = $2;
3654     }
3655     | LEFT_BRACE RIGHT_BRACE {
3656         const char* initFeature = "empty { } initializer";
3657         parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_EXT_null_initializer, initFeature);
3658         parseContext.profileRequires($1.loc, ~EEsProfile, 0, E_GL_EXT_null_initializer, initFeature);
3659         $$ = parseContext.intermediate.makeAggregate($1.loc);
3660     }
3661 GLSLANG_WEB_EXCLUDE_OFF
3662     ;
3663
3664 GLSLANG_WEB_EXCLUDE_ON
3665 initializer_list
3666     : initializer {
3667         $$ = parseContext.intermediate.growAggregate(0, $1, $1->getLoc());
3668     }
3669     | initializer_list COMMA initializer {
3670         $$ = parseContext.intermediate.growAggregate($1, $3);
3671     }
3672     ;
3673 GLSLANG_WEB_EXCLUDE_OFF
3674
3675 declaration_statement
3676     : declaration { $$ = $1; }
3677     ;
3678
3679 statement
3680     : compound_statement  { $$ = $1; }
3681     | simple_statement    { $$ = $1; }
3682     ;
3683
3684 // Grammar Note:  labeled statements for switch statements only; 'goto' is not supported.
3685
3686 simple_statement
3687     : declaration_statement { $$ = $1; }
3688     | expression_statement  { $$ = $1; }
3689     | selection_statement   { $$ = $1; }
3690     | switch_statement      { $$ = $1; }
3691     | case_label            { $$ = $1; }
3692     | iteration_statement   { $$ = $1; }
3693     | jump_statement        { $$ = $1; }
3694 GLSLANG_WEB_EXCLUDE_ON
3695     | demote_statement      { $$ = $1; }
3696 GLSLANG_WEB_EXCLUDE_OFF
3697     ;
3698
3699 GLSLANG_WEB_EXCLUDE_ON
3700 demote_statement
3701     : DEMOTE SEMICOLON {
3702         parseContext.requireStage($1.loc, EShLangFragment, "demote");
3703         parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_demote_to_helper_invocation, "demote");
3704         $$ = parseContext.intermediate.addBranch(EOpDemote, $1.loc);
3705     }
3706     ;
3707 GLSLANG_WEB_EXCLUDE_OFF
3708
3709 compound_statement
3710     : LEFT_BRACE RIGHT_BRACE { $$ = 0; }
3711     | LEFT_BRACE {
3712         parseContext.symbolTable.push();
3713         ++parseContext.statementNestingLevel;
3714     }
3715       statement_list {
3716         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3717         --parseContext.statementNestingLevel;
3718     }
3719       RIGHT_BRACE {
3720         if ($3 && $3->getAsAggregate())
3721             $3->getAsAggregate()->setOperator(EOpSequence);
3722         $$ = $3;
3723     }
3724     ;
3725
3726 statement_no_new_scope
3727     : compound_statement_no_new_scope { $$ = $1; }
3728     | simple_statement                { $$ = $1; }
3729     ;
3730
3731 statement_scoped
3732     : {
3733         ++parseContext.controlFlowNestingLevel;
3734     }
3735       compound_statement  {
3736         --parseContext.controlFlowNestingLevel;
3737         $$ = $2;
3738     }
3739     | {
3740         parseContext.symbolTable.push();
3741         ++parseContext.statementNestingLevel;
3742         ++parseContext.controlFlowNestingLevel;
3743     }
3744       simple_statement {
3745         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3746         --parseContext.statementNestingLevel;
3747         --parseContext.controlFlowNestingLevel;
3748         $$ = $2;
3749     }
3750
3751 compound_statement_no_new_scope
3752     // Statement that doesn't create a new scope, for selection_statement, iteration_statement
3753     : LEFT_BRACE RIGHT_BRACE {
3754         $$ = 0;
3755     }
3756     | LEFT_BRACE statement_list RIGHT_BRACE {
3757         if ($2 && $2->getAsAggregate())
3758             $2->getAsAggregate()->setOperator(EOpSequence);
3759         $$ = $2;
3760     }
3761     ;
3762
3763 statement_list
3764     : statement {
3765         $$ = parseContext.intermediate.makeAggregate($1);
3766         if ($1 && $1->getAsBranchNode() && ($1->getAsBranchNode()->getFlowOp() == EOpCase ||
3767                                             $1->getAsBranchNode()->getFlowOp() == EOpDefault)) {
3768             parseContext.wrapupSwitchSubsequence(0, $1);
3769             $$ = 0;  // start a fresh subsequence for what's after this case
3770         }
3771     }
3772     | statement_list statement {
3773         if ($2 && $2->getAsBranchNode() && ($2->getAsBranchNode()->getFlowOp() == EOpCase ||
3774                                             $2->getAsBranchNode()->getFlowOp() == EOpDefault)) {
3775             parseContext.wrapupSwitchSubsequence($1 ? $1->getAsAggregate() : 0, $2);
3776             $$ = 0;  // start a fresh subsequence for what's after this case
3777         } else
3778             $$ = parseContext.intermediate.growAggregate($1, $2);
3779     }
3780     ;
3781
3782 expression_statement
3783     : SEMICOLON  { $$ = 0; }
3784     | expression SEMICOLON  { $$ = static_cast<TIntermNode*>($1); }
3785     ;
3786
3787 selection_statement
3788     : selection_statement_nonattributed {
3789         $$ = $1;
3790     }
3791 GLSLANG_WEB_EXCLUDE_ON
3792     | attribute selection_statement_nonattributed {
3793         parseContext.requireExtensions($2->getLoc(), 1, &E_GL_EXT_control_flow_attributes, "attribute");
3794         parseContext.handleSelectionAttributes(*$1, $2);
3795         $$ = $2;
3796     }
3797 GLSLANG_WEB_EXCLUDE_OFF
3798
3799 selection_statement_nonattributed
3800     : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement {
3801         parseContext.boolCheck($1.loc, $3);
3802         $$ = parseContext.intermediate.addSelection($3, $5, $1.loc);
3803     }
3804     ;
3805
3806 selection_rest_statement
3807     : statement_scoped ELSE statement_scoped {
3808         $$.node1 = $1;
3809         $$.node2 = $3;
3810     }
3811     | statement_scoped {
3812         $$.node1 = $1;
3813         $$.node2 = 0;
3814     }
3815     ;
3816
3817 condition
3818     // In 1996 c++ draft, conditions can include single declarations
3819     : expression {
3820         $$ = $1;
3821         parseContext.boolCheck($1->getLoc(), $1);
3822     }
3823     | fully_specified_type IDENTIFIER EQUAL initializer {
3824         parseContext.boolCheck($2.loc, $1);
3825
3826         TType type($1);
3827         TIntermNode* initNode = parseContext.declareVariable($2.loc, *$2.string, $1, 0, $4);
3828         if (initNode)
3829             $$ = initNode->getAsTyped();
3830         else
3831             $$ = 0;
3832     }
3833     ;
3834
3835 switch_statement
3836     : switch_statement_nonattributed {
3837         $$ = $1;
3838     }
3839 GLSLANG_WEB_EXCLUDE_ON
3840     | attribute switch_statement_nonattributed {
3841         parseContext.requireExtensions($2->getLoc(), 1, &E_GL_EXT_control_flow_attributes, "attribute");
3842         parseContext.handleSwitchAttributes(*$1, $2);
3843         $$ = $2;
3844     }
3845 GLSLANG_WEB_EXCLUDE_OFF
3846
3847 switch_statement_nonattributed
3848     : SWITCH LEFT_PAREN expression RIGHT_PAREN {
3849         // start new switch sequence on the switch stack
3850         ++parseContext.controlFlowNestingLevel;
3851         ++parseContext.statementNestingLevel;
3852         parseContext.switchSequenceStack.push_back(new TIntermSequence);
3853         parseContext.switchLevel.push_back(parseContext.statementNestingLevel);
3854         parseContext.symbolTable.push();
3855     }
3856     LEFT_BRACE switch_statement_list RIGHT_BRACE {
3857         $$ = parseContext.addSwitch($1.loc, $3, $7 ? $7->getAsAggregate() : 0);
3858         delete parseContext.switchSequenceStack.back();
3859         parseContext.switchSequenceStack.pop_back();
3860         parseContext.switchLevel.pop_back();
3861         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3862         --parseContext.statementNestingLevel;
3863         --parseContext.controlFlowNestingLevel;
3864     }
3865     ;
3866
3867 switch_statement_list
3868     : /* nothing */ {
3869         $$ = 0;
3870     }
3871     | statement_list {
3872         $$ = $1;
3873     }
3874     ;
3875
3876 case_label
3877     : CASE expression COLON {
3878         $$ = 0;
3879         if (parseContext.switchLevel.size() == 0)
3880             parseContext.error($1.loc, "cannot appear outside switch statement", "case", "");
3881         else if (parseContext.switchLevel.back() != parseContext.statementNestingLevel)
3882             parseContext.error($1.loc, "cannot be nested inside control flow", "case", "");
3883         else {
3884             parseContext.constantValueCheck($2, "case");
3885             parseContext.integerCheck($2, "case");
3886             $$ = parseContext.intermediate.addBranch(EOpCase, $2, $1.loc);
3887         }
3888     }
3889     | DEFAULT COLON {
3890         $$ = 0;
3891         if (parseContext.switchLevel.size() == 0)
3892             parseContext.error($1.loc, "cannot appear outside switch statement", "default", "");
3893         else if (parseContext.switchLevel.back() != parseContext.statementNestingLevel)
3894             parseContext.error($1.loc, "cannot be nested inside control flow", "default", "");
3895         else
3896             $$ = parseContext.intermediate.addBranch(EOpDefault, $1.loc);
3897     }
3898     ;
3899
3900 iteration_statement
3901     : iteration_statement_nonattributed {
3902         $$ = $1;
3903     }
3904 GLSLANG_WEB_EXCLUDE_ON
3905     | attribute iteration_statement_nonattributed {
3906         parseContext.requireExtensions($2->getLoc(), 1, &E_GL_EXT_control_flow_attributes, "attribute");
3907         parseContext.handleLoopAttributes(*$1, $2);
3908         $$ = $2;
3909     }
3910 GLSLANG_WEB_EXCLUDE_OFF
3911
3912 iteration_statement_nonattributed
3913     : WHILE LEFT_PAREN {
3914         if (! parseContext.limits.whileLoops)
3915             parseContext.error($1.loc, "while loops not available", "limitation", "");
3916         parseContext.symbolTable.push();
3917         ++parseContext.loopNestingLevel;
3918         ++parseContext.statementNestingLevel;
3919         ++parseContext.controlFlowNestingLevel;
3920     }
3921       condition RIGHT_PAREN statement_no_new_scope {
3922         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3923         $$ = parseContext.intermediate.addLoop($6, $4, 0, true, $1.loc);
3924         --parseContext.loopNestingLevel;
3925         --parseContext.statementNestingLevel;
3926         --parseContext.controlFlowNestingLevel;
3927     }
3928     | DO {
3929         parseContext.symbolTable.push();
3930         ++parseContext.loopNestingLevel;
3931         ++parseContext.statementNestingLevel;
3932         ++parseContext.controlFlowNestingLevel;
3933     }
3934       statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
3935         if (! parseContext.limits.whileLoops)
3936             parseContext.error($1.loc, "do-while loops not available", "limitation", "");
3937
3938         parseContext.boolCheck($8.loc, $6);
3939
3940         $$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.loc);
3941         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3942         --parseContext.loopNestingLevel;
3943         --parseContext.statementNestingLevel;
3944         --parseContext.controlFlowNestingLevel;
3945     }
3946     | FOR LEFT_PAREN {
3947         parseContext.symbolTable.push();
3948         ++parseContext.loopNestingLevel;
3949         ++parseContext.statementNestingLevel;
3950         ++parseContext.controlFlowNestingLevel;
3951     }
3952       for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
3953         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
3954         $$ = parseContext.intermediate.makeAggregate($4, $2.loc);
3955         TIntermLoop* forLoop = parseContext.intermediate.addLoop($7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.loc);
3956         if (! parseContext.limits.nonInductiveForLoops)
3957             parseContext.inductiveLoopCheck($1.loc, $4, forLoop);
3958         $$ = parseContext.intermediate.growAggregate($$, forLoop, $1.loc);
3959         $$->getAsAggregate()->setOperator(EOpSequence);
3960         --parseContext.loopNestingLevel;
3961         --parseContext.statementNestingLevel;
3962         --parseContext.controlFlowNestingLevel;
3963     }
3964     ;
3965
3966 for_init_statement
3967     : expression_statement {
3968         $$ = $1;
3969     }
3970     | declaration_statement {
3971         $$ = $1;
3972     }
3973     ;
3974
3975 conditionopt
3976     : condition {
3977         $$ = $1;
3978     }
3979     | /* May be null */ {
3980         $$ = 0;
3981     }
3982     ;
3983
3984 for_rest_statement
3985     : conditionopt SEMICOLON {
3986         $$.node1 = $1;
3987         $$.node2 = 0;
3988     }
3989     | conditionopt SEMICOLON expression  {
3990         $$.node1 = $1;
3991         $$.node2 = $3;
3992     }
3993     ;
3994
3995 jump_statement
3996     : CONTINUE SEMICOLON {
3997         if (parseContext.loopNestingLevel <= 0)
3998             parseContext.error($1.loc, "continue statement only allowed in loops", "", "");
3999         $$ = parseContext.intermediate.addBranch(EOpContinue, $1.loc);
4000     }
4001     | BREAK SEMICOLON {
4002         if (parseContext.loopNestingLevel + parseContext.switchSequenceStack.size() <= 0)
4003             parseContext.error($1.loc, "break statement only allowed in switch and loops", "", "");
4004         $$ = parseContext.intermediate.addBranch(EOpBreak, $1.loc);
4005     }
4006     | RETURN SEMICOLON {
4007         $$ = parseContext.intermediate.addBranch(EOpReturn, $1.loc);
4008         if (parseContext.currentFunctionType->getBasicType() != EbtVoid)
4009             parseContext.error($1.loc, "non-void function must return a value", "return", "");
4010         if (parseContext.inMain)
4011             parseContext.postEntryPointReturn = true;
4012     }
4013     | RETURN expression SEMICOLON {
4014         $$ = parseContext.handleReturnValue($1.loc, $2);
4015     }
4016     | DISCARD SEMICOLON {
4017         parseContext.requireStage($1.loc, EShLangFragment, "discard");
4018         $$ = parseContext.intermediate.addBranch(EOpKill, $1.loc);
4019     }
4020     | TERMINATE_INVOCATION SEMICOLON {
4021         parseContext.requireStage($1.loc, EShLangFragment, "terminateInvocation");
4022         $$ = parseContext.intermediate.addBranch(EOpTerminateInvocation, $1.loc);
4023     }
4024 GLSLANG_WEB_EXCLUDE_ON
4025     | TERMINATE_RAY SEMICOLON {
4026         parseContext.requireStage($1.loc, EShLangAnyHit, "terminateRayEXT");
4027         $$ = parseContext.intermediate.addBranch(EOpTerminateRayKHR, $1.loc);
4028     }
4029     | IGNORE_INTERSECTION SEMICOLON {
4030         parseContext.requireStage($1.loc, EShLangAnyHit, "ignoreIntersectionEXT");
4031         $$ = parseContext.intermediate.addBranch(EOpIgnoreIntersectionKHR, $1.loc);
4032     }
4033 GLSLANG_WEB_EXCLUDE_OFF
4034     ;
4035
4036 // Grammar Note:  No 'goto'.  Gotos are not supported.
4037
4038 translation_unit
4039     : external_declaration {
4040         $$ = $1;
4041         parseContext.intermediate.setTreeRoot($$);
4042     }
4043     | translation_unit external_declaration {
4044         if ($2 != nullptr) {
4045             $$ = parseContext.intermediate.growAggregate($1, $2);
4046             parseContext.intermediate.setTreeRoot($$);
4047         }
4048     }
4049     ;
4050
4051 external_declaration
4052     : function_definition {
4053         $$ = $1;
4054     }
4055     | declaration {
4056         $$ = $1;
4057     }
4058 GLSLANG_WEB_EXCLUDE_ON
4059     | SEMICOLON {
4060         parseContext.requireProfile($1.loc, ~EEsProfile, "extraneous semicolon");
4061         parseContext.profileRequires($1.loc, ~EEsProfile, 460, nullptr, "extraneous semicolon");
4062         $$ = nullptr;
4063     }
4064 GLSLANG_WEB_EXCLUDE_OFF
4065     ;
4066
4067 function_definition
4068     : function_prototype {
4069         $1.function = parseContext.handleFunctionDeclarator($1.loc, *$1.function, false /* not prototype */);
4070         $1.intermNode = parseContext.handleFunctionDefinition($1.loc, *$1.function);
4071
4072         // For ES 100 only, according to ES shading language 100 spec: A function
4073         // body has a scope nested inside the function's definition.
4074         if (parseContext.profile == EEsProfile && parseContext.version == 100)
4075         {
4076             parseContext.symbolTable.push();
4077             ++parseContext.statementNestingLevel;
4078         }
4079     }
4080     compound_statement_no_new_scope {
4081         //   May be best done as post process phase on intermediate code
4082         if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue)
4083             parseContext.error($1.loc, "function does not return a value:", "", $1.function->getName().c_str());
4084         parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
4085         $$ = parseContext.intermediate.growAggregate($1.intermNode, $3);
4086         parseContext.intermediate.setAggregateOperator($$, EOpFunction, $1.function->getType(), $1.loc);
4087         $$->getAsAggregate()->setName($1.function->getMangledName().c_str());
4088
4089         // store the pragma information for debug and optimize and other vendor specific
4090         // information. This information can be queried from the parse tree
4091         $$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
4092         $$->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
4093         $$->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable);
4094
4095         // Set currentFunctionType to empty pointer when goes outside of the function
4096         parseContext.currentFunctionType = nullptr;
4097
4098         // For ES 100 only, according to ES shading language 100 spec: A function
4099         // body has a scope nested inside the function's definition.
4100         if (parseContext.profile == EEsProfile && parseContext.version == 100)
4101         {
4102             parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
4103             --parseContext.statementNestingLevel;
4104         }
4105     }
4106     ;
4107
4108 GLSLANG_WEB_EXCLUDE_ON
4109 attribute
4110     : LEFT_BRACKET LEFT_BRACKET attribute_list RIGHT_BRACKET RIGHT_BRACKET {
4111         $$ = $3;
4112     }
4113
4114 attribute_list
4115     : single_attribute {
4116         $$ = $1;
4117     }
4118     | attribute_list COMMA single_attribute {
4119         $$ = parseContext.mergeAttributes($1, $3);
4120     }
4121
4122 single_attribute
4123     : IDENTIFIER {
4124         $$ = parseContext.makeAttributes(*$1.string);
4125     }
4126     | IDENTIFIER LEFT_PAREN constant_expression RIGHT_PAREN {
4127         $$ = parseContext.makeAttributes(*$1.string, $3);
4128     }
4129 GLSLANG_WEB_EXCLUDE_OFF
4130
4131 GLSLANG_WEB_EXCLUDE_ON
4132 spirv_requirements_list
4133     : spirv_requirements_parameter {
4134         $$ = $1;
4135     }
4136     | spirv_requirements_list COMMA spirv_requirements_parameter {
4137         $$ = parseContext.mergeSpirvRequirements($2.loc, $1, $3);
4138     }
4139
4140 spirv_requirements_parameter
4141     : IDENTIFIER EQUAL LEFT_BRACKET spirv_extension_list RIGHT_BRACKET {
4142         $$ = parseContext.makeSpirvRequirement($2.loc, *$1.string, $4->getAsAggregate(), nullptr);
4143     }
4144     | IDENTIFIER EQUAL LEFT_BRACKET spirv_capability_list RIGHT_BRACKET {
4145         $$ = parseContext.makeSpirvRequirement($2.loc, *$1.string, nullptr, $4->getAsAggregate());
4146     }
4147
4148 spirv_extension_list
4149     : STRING_LITERAL {
4150         $$ = parseContext.intermediate.makeAggregate(parseContext.intermediate.addConstantUnion($1.string, $1.loc, true));
4151     }
4152     | spirv_extension_list COMMA STRING_LITERAL {
4153         $$ = parseContext.intermediate.growAggregate($1, parseContext.intermediate.addConstantUnion($3.string, $3.loc, true));
4154     }
4155
4156 spirv_capability_list
4157     : INTCONSTANT {
4158         $$ = parseContext.intermediate.makeAggregate(parseContext.intermediate.addConstantUnion($1.i, $1.loc, true));
4159     }
4160     | spirv_capability_list COMMA INTCONSTANT {
4161         $$ = parseContext.intermediate.growAggregate($1, parseContext.intermediate.addConstantUnion($3.i, $3.loc, true));
4162     }
4163
4164 spirv_execution_mode_qualifier
4165     : SPIRV_EXECUTION_MODE LEFT_PAREN INTCONSTANT RIGHT_PAREN {
4166         parseContext.intermediate.insertSpirvExecutionMode($3.i);
4167         $$ = 0;
4168     }
4169     | SPIRV_EXECUTION_MODE LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT RIGHT_PAREN {
4170         parseContext.intermediate.insertSpirvRequirement($3);
4171         parseContext.intermediate.insertSpirvExecutionMode($5.i);
4172         $$ = 0;
4173     }
4174     | SPIRV_EXECUTION_MODE LEFT_PAREN INTCONSTANT COMMA spirv_execution_mode_parameter_list RIGHT_PAREN {
4175         parseContext.intermediate.insertSpirvExecutionMode($3.i, $5->getAsAggregate());
4176         $$ = 0;
4177     }
4178     | SPIRV_EXECUTION_MODE LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT COMMA spirv_execution_mode_parameter_list RIGHT_PAREN {
4179         parseContext.intermediate.insertSpirvRequirement($3);
4180         parseContext.intermediate.insertSpirvExecutionMode($5.i, $7->getAsAggregate());
4181         $$ = 0;
4182     }
4183     | SPIRV_EXECUTION_MODE_ID LEFT_PAREN INTCONSTANT COMMA spirv_execution_mode_id_parameter_list RIGHT_PAREN {
4184         parseContext.intermediate.insertSpirvExecutionModeId($3.i, $5->getAsAggregate());
4185         $$ = 0;
4186     }
4187     | SPIRV_EXECUTION_MODE_ID LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT COMMA spirv_execution_mode_id_parameter_list RIGHT_PAREN {
4188         parseContext.intermediate.insertSpirvRequirement($3);
4189         parseContext.intermediate.insertSpirvExecutionModeId($5.i, $7->getAsAggregate());
4190         $$ = 0;
4191     }
4192
4193 spirv_execution_mode_parameter_list
4194     : spirv_execution_mode_parameter {
4195         $$ = parseContext.intermediate.makeAggregate($1);
4196     }
4197     | spirv_execution_mode_parameter_list COMMA spirv_execution_mode_parameter {
4198         $$ = parseContext.intermediate.growAggregate($1, $3);
4199     }
4200
4201 spirv_execution_mode_parameter
4202     : FLOATCONSTANT {
4203         $$ = parseContext.intermediate.addConstantUnion($1.d, EbtFloat, $1.loc, true);
4204     }
4205     | INTCONSTANT {
4206         $$ = parseContext.intermediate.addConstantUnion($1.i, $1.loc, true);
4207     }
4208     | UINTCONSTANT {
4209         $$ = parseContext.intermediate.addConstantUnion($1.u, $1.loc, true);
4210     }
4211     | BOOLCONSTANT {
4212         $$ = parseContext.intermediate.addConstantUnion($1.b, $1.loc, true);
4213     }
4214     | STRING_LITERAL {
4215         $$ = parseContext.intermediate.addConstantUnion($1.string, $1.loc, true);
4216     }
4217
4218 spirv_execution_mode_id_parameter_list
4219     : constant_expression {
4220         if ($1->getBasicType() != EbtFloat &&
4221             $1->getBasicType() != EbtInt &&
4222             $1->getBasicType() != EbtUint &&
4223             $1->getBasicType() != EbtBool &&
4224             $1->getBasicType() != EbtString)
4225             parseContext.error($1->getLoc(), "this type not allowed", $1->getType().getBasicString(), "");
4226         $$ = parseContext.intermediate.makeAggregate($1);
4227     }
4228     | spirv_execution_mode_id_parameter_list COMMA constant_expression {
4229         if ($3->getBasicType() != EbtFloat &&
4230             $3->getBasicType() != EbtInt &&
4231             $3->getBasicType() != EbtUint &&
4232             $3->getBasicType() != EbtBool &&
4233             $3->getBasicType() != EbtString)
4234             parseContext.error($3->getLoc(), "this type not allowed", $3->getType().getBasicString(), "");
4235         $$ = parseContext.intermediate.growAggregate($1, $3);
4236     }
4237
4238 spirv_storage_class_qualifier
4239     : SPIRV_STORAGE_CLASS LEFT_PAREN INTCONSTANT RIGHT_PAREN {
4240         $$.init($1.loc);
4241         $$.qualifier.storage = EvqSpirvStorageClass;
4242         $$.qualifier.spirvStorageClass = $3.i;
4243     }
4244     | SPIRV_STORAGE_CLASS LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT RIGHT_PAREN {
4245         $$.init($1.loc);
4246         parseContext.intermediate.insertSpirvRequirement($3);
4247         $$.qualifier.storage = EvqSpirvStorageClass;
4248         $$.qualifier.spirvStorageClass = $5.i;
4249     }
4250
4251 spirv_decorate_qualifier
4252     : SPIRV_DECORATE LEFT_PAREN INTCONSTANT RIGHT_PAREN{
4253         $$.init($1.loc);
4254         $$.qualifier.setSpirvDecorate($3.i);
4255     }
4256     | SPIRV_DECORATE LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT RIGHT_PAREN{
4257         $$.init($1.loc);
4258         parseContext.intermediate.insertSpirvRequirement($3);
4259         $$.qualifier.setSpirvDecorate($5.i);
4260     }
4261     | SPIRV_DECORATE LEFT_PAREN INTCONSTANT COMMA spirv_decorate_parameter_list RIGHT_PAREN {
4262         $$.init($1.loc);
4263         $$.qualifier.setSpirvDecorate($3.i, $5->getAsAggregate());
4264     }
4265     | SPIRV_DECORATE LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT COMMA spirv_decorate_parameter_list RIGHT_PAREN {
4266         $$.init($1.loc);
4267         parseContext.intermediate.insertSpirvRequirement($3);
4268         $$.qualifier.setSpirvDecorate($5.i, $7->getAsAggregate());
4269     }
4270     | SPIRV_DECORATE_ID LEFT_PAREN INTCONSTANT COMMA spirv_decorate_id_parameter_list RIGHT_PAREN {
4271         $$.init($1.loc);
4272         $$.qualifier.setSpirvDecorateId($3.i, $5->getAsAggregate());
4273     }
4274     | SPIRV_DECORATE_ID LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT COMMA spirv_decorate_id_parameter_list RIGHT_PAREN {
4275         $$.init($1.loc);
4276         parseContext.intermediate.insertSpirvRequirement($3);
4277         $$.qualifier.setSpirvDecorateId($5.i, $7->getAsAggregate());
4278     }
4279     | SPIRV_DECORATE_STRING LEFT_PAREN INTCONSTANT COMMA spirv_decorate_string_parameter_list RIGHT_PAREN {
4280         $$.init($1.loc);
4281         $$.qualifier.setSpirvDecorateString($3.i, $5->getAsAggregate());
4282     }
4283     | SPIRV_DECORATE_STRING LEFT_PAREN spirv_requirements_list COMMA INTCONSTANT COMMA spirv_decorate_string_parameter_list RIGHT_PAREN {
4284         $$.init($1.loc);
4285         parseContext.intermediate.insertSpirvRequirement($3);
4286         $$.qualifier.setSpirvDecorateString($5.i, $7->getAsAggregate());
4287     }
4288
4289 spirv_decorate_parameter_list
4290     : spirv_decorate_parameter {
4291         $$ = parseContext.intermediate.makeAggregate($1);
4292     }
4293     | spirv_decorate_parameter_list COMMA spirv_decorate_parameter {
4294         $$ = parseContext.intermediate.growAggregate($1, $3);
4295     }
4296
4297 spirv_decorate_parameter
4298     : FLOATCONSTANT {
4299         $$ = parseContext.intermediate.addConstantUnion($1.d, EbtFloat, $1.loc, true);
4300     }
4301     | INTCONSTANT {
4302         $$ = parseContext.intermediate.addConstantUnion($1.i, $1.loc, true);
4303     }
4304     | UINTCONSTANT {
4305         $$ = parseContext.intermediate.addConstantUnion($1.u, $1.loc, true);
4306     }
4307     | BOOLCONSTANT {
4308         $$ = parseContext.intermediate.addConstantUnion($1.b, $1.loc, true);
4309     }
4310
4311 spirv_decorate_id_parameter_list
4312     : constant_expression {
4313         if ($1->getBasicType() != EbtFloat &&
4314             $1->getBasicType() != EbtInt &&
4315             $1->getBasicType() != EbtUint &&
4316             $1->getBasicType() != EbtBool)
4317             parseContext.error($1->getLoc(), "this type not allowed", $1->getType().getBasicString(), "");
4318         $$ = parseContext.intermediate.makeAggregate($1);
4319     }
4320     | spirv_decorate_id_parameter_list COMMA constant_expression {
4321         if ($3->getBasicType() != EbtFloat &&
4322             $3->getBasicType() != EbtInt &&
4323             $3->getBasicType() != EbtUint &&
4324             $3->getBasicType() != EbtBool)
4325             parseContext.error($3->getLoc(), "this type not allowed", $3->getType().getBasicString(), "");
4326         $$ = parseContext.intermediate.growAggregate($1, $3);
4327     }
4328
4329 spirv_decorate_string_parameter_list
4330     : STRING_LITERAL {
4331         $$ = parseContext.intermediate.makeAggregate(
4332             parseContext.intermediate.addConstantUnion($1.string, $1.loc, true));
4333     }
4334     | spirv_decorate_string_parameter_list COMMA STRING_LITERAL {
4335         $$ = parseContext.intermediate.growAggregate($1, parseContext.intermediate.addConstantUnion($3.string, $3.loc, true));
4336     }
4337
4338 spirv_type_specifier
4339     : SPIRV_TYPE LEFT_PAREN spirv_instruction_qualifier_list COMMA spirv_type_parameter_list RIGHT_PAREN {
4340         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
4341         $$.setSpirvType(*$3, $5);
4342     }
4343     | SPIRV_TYPE LEFT_PAREN spirv_requirements_list COMMA spirv_instruction_qualifier_list COMMA spirv_type_parameter_list RIGHT_PAREN {
4344         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
4345         parseContext.intermediate.insertSpirvRequirement($3);
4346         $$.setSpirvType(*$5, $7);
4347     }
4348     | SPIRV_TYPE LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {
4349         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
4350         $$.setSpirvType(*$3);
4351     }
4352     | SPIRV_TYPE LEFT_PAREN spirv_requirements_list COMMA spirv_instruction_qualifier_list RIGHT_PAREN {
4353         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
4354         parseContext.intermediate.insertSpirvRequirement($3);
4355         $$.setSpirvType(*$5);
4356     }
4357
4358 spirv_type_parameter_list
4359     : spirv_type_parameter {
4360         $$ = $1;
4361     }
4362     | spirv_type_parameter_list COMMA spirv_type_parameter {
4363         $$ = parseContext.mergeSpirvTypeParameters($1, $3);
4364     }
4365
4366 spirv_type_parameter
4367     : constant_expression {
4368         $$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion());
4369     }
4370     | type_specifier {
4371         $$ = parseContext.makeSpirvTypeParameters($1);
4372     }
4373
4374 spirv_instruction_qualifier
4375     : SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {
4376         $$ = $3;
4377     }
4378     | SPIRV_INSTRUCTION LEFT_PAREN spirv_requirements_list COMMA spirv_instruction_qualifier_list RIGHT_PAREN {
4379         parseContext.intermediate.insertSpirvRequirement($3);
4380         $$ = $5;
4381     }
4382
4383 spirv_instruction_qualifier_list
4384     : spirv_instruction_qualifier_id {
4385         $$ = $1;
4386     }
4387     | spirv_instruction_qualifier_list COMMA spirv_instruction_qualifier_id {
4388         $$ = parseContext.mergeSpirvInstruction($2.loc, $1, $3);
4389     }
4390
4391 spirv_instruction_qualifier_id
4392     : IDENTIFIER EQUAL STRING_LITERAL {
4393         $$ = parseContext.makeSpirvInstruction($2.loc, *$1.string, *$3.string);
4394     }
4395     | IDENTIFIER EQUAL INTCONSTANT {
4396         $$ = parseContext.makeSpirvInstruction($2.loc, *$1.string, $3.i);
4397     }
4398 GLSLANG_WEB_EXCLUDE_OFF
4399
4400 %%