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