1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/* 2d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 4d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Licensed under the Apache License, Version 2.0 (the "License"); 5d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// you may not use this file except in compliance with the License. 6d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// You may obtain a copy of the License at 7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 8d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// http://www.apache.org/licenses/LICENSE-2.0 9d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// 10d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Unless required by applicable law or agreed to in writing, software 11d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// distributed under the License is distributed on an "AS IS" BASIS, 12d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// See the License for the specific language governing permissions and 14d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// limitations under the License. 15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanThis file contains the Yacc grammar for GLSL ES. 17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanBased on ANSI C Yacc grammar: 18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanhttp://www.lysator.liu.se/c/ANSI-C-grammar-y.html 19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanIF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, 21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanWHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). 22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman*/ 23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%{ 25d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 26d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// 27d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Licensed under the Apache License, Version 2.0 (the "License"); 28d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// you may not use this file except in compliance with the License. 29d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// You may obtain a copy of the License at 30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 31d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// http://www.apache.org/licenses/LICENSE-2.0 32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 33d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Unless required by applicable law or agreed to in writing, software 34d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// distributed under the License is distributed on an "AS IS" BASIS, 35d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// See the License for the specific language governing permissions and 37d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// limitations under the License. 38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// This file is auto-generated by generate_parser.sh. DO NOT EDIT! 4066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// Ignore errors in auto-generated code. 4266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#if defined(__GNUC__) 4366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#pragma GCC diagnostic ignored "-Wunused-function" 4466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#pragma GCC diagnostic ignored "-Wunused-variable" 4566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#pragma GCC diagnostic ignored "-Wswitch-enum" 4666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#elif defined(_MSC_VER) 4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#pragma warning(disable: 4065) 4866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#pragma warning(disable: 4189) 4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#pragma warning(disable: 4505) 5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#pragma warning(disable: 4701) 5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#endif 52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 53cc863da574ed5079b055574127fe5788a9a0fc33Nicolas Capens#include "SymbolTable.h" 54cc863da574ed5079b055574127fe5788a9a0fc33Nicolas Capens#include "ParseHelper.h" 55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 56d4ae863d01d5f448dbbba6be4ecc161971a2324fJohn Bauman#define YYENABLE_NLS 0 57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%} 58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%expect 1 /* One shift reduce conflict because of if | else */ 60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%pure-parser 61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%parse-param {TParseContext* context} 62eced26a12537825c00dcdd8e74e110b3e838a08fVeranika Liaukevich%param {void* yyscanner} 63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu%code requires { 6515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu#define YYLTYPE TSourceLoc 6615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu#define YYLTYPE_IS_DECLARED 1 6715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu} 6815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu 69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%union { 70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman struct { 71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman union { 72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TString *string; 73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman float f; 74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int i; 752c1239f554f88546f0f8abf30dc829bb621dd94bNicolas Capens unsigned int u; 76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool b; 77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TSymbol* symbol; 79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } lex; 80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman struct { 81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TOperator op; 82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman union { 83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TIntermNode* intermNode; 84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TIntermNodePair nodePair; 85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TIntermTyped* intermTypedNode; 86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TIntermAggregate* intermAggregate; 8776a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu TIntermSwitch* intermSwitch; 8876a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu TIntermCase* intermCase; 89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman union { 91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TPublicType type; 92894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TPrecision precision; 937d626796531874d308706c46a32942d71c85a7f8Nicolas Capens TLayoutQualifier layoutQualifier; 94894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qualifier; 95894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TFunction* function; 96894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TParameter param; 97a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu TField* field; 98a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu TFieldList* fieldList; 99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } interm; 101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%{ 10415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetuextern int yylex(YYSTYPE* yylval, YYLTYPE* yylloc, void* yyscanner); 105eced26a12537825c00dcdd8e74e110b3e838a08fVeranika Liaukevichextern void yyerror(YYLTYPE* lloc, TParseContext* context, void* scanner, const char* reason); 10615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu 107242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu#define YYLLOC_DEFAULT(Current, Rhs, N) \ 108242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu do { \ 109242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu if (N) { \ 110242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).first_file = YYRHSLOC(Rhs, 1).first_file; \ 111242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ 112242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).last_file = YYRHSLOC(Rhs, N).last_file; \ 113242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ 114242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu } \ 115242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu else { \ 116242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).first_file = YYRHSLOC(Rhs, 0).last_file; \ 117242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).first_line = YYRHSLOC(Rhs, 0).last_line; \ 118242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).last_file = YYRHSLOC(Rhs, 0).last_file; \ 119242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \ 120242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu } \ 121242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu } while (0) 122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define FRAG_VERT_ONLY(S, L) { \ 1240a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderType() != GL_FRAGMENT_SHADER && \ 1250a65584a1529450c476c026f3254d78efc200645Alexis Hetu context->getShaderType() != GL_VERTEX_SHADER) { \ 12666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman context->error(L, " supported in vertex/fragment shaders only ", S); \ 127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); \ 128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } \ 129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define VERTEX_ONLY(S, L) { \ 1320a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderType() != GL_VERTEX_SHADER) { \ 13366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman context->error(L, " supported in vertex shaders only ", S); \ 134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); \ 135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } \ 136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define FRAG_ONLY(S, L) { \ 1390a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderType() != GL_FRAGMENT_SHADER) { \ 14066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman context->error(L, " supported in fragment shaders only ", S); \ 141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); \ 142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } \ 143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 144c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens 145c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens#define ES2_ONLY(S, L) { \ 1460a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderVersion() != 100) { \ 147c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens context->error(L, " supported in GLSL ES 1.00 only ", S); \ 148c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens context->recover(); \ 149c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens } \ 150c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens} 151c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens 1523e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu#define ES3_ONLY(TOKEN, LINE, REASON) { \ 1530a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderVersion() != 300) { \ 1543e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu context->error(LINE, REASON " supported in GLSL ES 3.00 only ", TOKEN); \ 155c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens context->recover(); \ 156c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens } \ 157c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens} 158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%} 159894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION 1613c20f806dd9b3492c7ab102858f84f7cfd73133eNicolas Capens%token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE UINT_TYPE 162c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens%token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT 163e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4 UVEC2 UVEC3 UVEC4 164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING 165b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu%token <lex> MATRIX2x3 MATRIX3x2 MATRIX2x4 MATRIX4x2 MATRIX3x4 MATRIX4x3 166c6841851785cab1f3fd19b8aae8e8a8fe7dd7b99Nicolas Capens%token <lex> CENTROID FLAT SMOOTH 167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> STRUCT VOID_TYPE WHILE 168b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu%token <lex> SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES SAMPLER2DRECT SAMPLER2DARRAY 169b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu%token <lex> ISAMPLER2D ISAMPLER3D ISAMPLERCUBE ISAMPLER2DARRAY 170b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu%token <lex> USAMPLER2D USAMPLER3D USAMPLERCUBE USAMPLER2DARRAY 171b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu%token <lex> SAMPLER3D SAMPLER3DRECT SAMPLER2DSHADOW SAMPLERCUBESHADOW SAMPLER2DARRAYSHADOW 1727d626796531874d308706c46a32942d71c85a7f8Nicolas Capens%token <lex> LAYOUT 173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1742c1239f554f88546f0f8abf30dc829bb621dd94bNicolas Capens%token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT UINTCONSTANT BOOLCONSTANT 175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> FIELD_SELECTION 176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> LEFT_OP RIGHT_OP 177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP 178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN 179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN 180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> SUB_ASSIGN 181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> LEFT_PAREN RIGHT_PAREN LEFT_BRACKET RIGHT_BRACKET LEFT_BRACE RIGHT_BRACE DOT 183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> COMMA COLON EQUAL SEMICOLON BANG DASH TILDE PLUS STAR SLASH PERCENT 184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%token <lex> LEFT_ANGLE RIGHT_ANGLE VERTICAL_BAR CARET AMPERSAND QUESTION 185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm> assignment_operator unary_operator 187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> variable_identifier primary_expression postfix_expression 188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> expression integer_expression assignment_expression 189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> unary_expression multiplicative_expression additive_expression 190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> relational_expression equality_expression 191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> conditional_expression constant_expression 192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> logical_or_expression logical_xor_expression logical_and_expression 193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> shift_expression and_expression exclusive_or_expression inclusive_or_expression 194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermTypedNode> function_call initializer condition conditionopt 195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermNode> translation_unit function_definition 197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermNode> statement simple_statement 198242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu%type <interm.intermAggregate> statement_list compound_statement compound_statement_no_new_scope 199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermNode> declaration_statement selection_statement expression_statement 200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.intermNode> declaration external_declaration 201242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu%type <interm.intermNode> for_init_statement 202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.nodePair> selection_rest_statement for_rest_statement 20376a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu%type <interm.intermSwitch> switch_statement 20476a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu%type <interm.intermCase> case_label 20519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman%type <interm.intermNode> iteration_statement jump_statement statement_no_new_scope statement_with_scope 206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm> single_declaration init_declarator_list 207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm> parameter_declaration parameter_declarator parameter_type_specifier 209a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens%type <interm.qualifier> parameter_qualifier parameter_type_qualifier 2107d626796531874d308706c46a32942d71c85a7f8Nicolas Capens%type <interm.layoutQualifier> layout_qualifier layout_qualifier_id_list layout_qualifier_id 211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.precision> precision_qualifier 21355a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu%type <interm.type> type_qualifier fully_specified_type type_specifier storage_qualifier interpolation_qualifier 214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.type> type_specifier_no_prec type_specifier_nonarray 215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.type> struct_specifier 216a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu%type <interm.field> struct_declarator 217a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu%type <interm.fieldList> struct_declarator_list struct_declaration struct_declaration_list 218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.function> function_header function_declarator function_identifier 219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm.function> function_header_with_parameters function_call_header 220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm> function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype 221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%type <interm> function_call_or_method 222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 223a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu%type <lex> enter_struct 224a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu 225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%start translation_unit 226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%% 227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanvariable_identifier 229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : IDENTIFIER { 230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // The symbol table search was done in the lexical phase 231242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu const TVariable *variable = context->getNamedVariable(@1, $1.string, $1.symbol); 232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // don't delete $1.string, it's used by error recovery, and the pool 234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // pop will reclaim the memory 235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2362cb7452bae261744d6410a01a54fd398f7f0c2acNicolas Capens ConstantUnion *constArray = variable->getConstPointer(); 2372cb7452bae261744d6410a01a54fd398f7f0c2acNicolas Capens if (constArray) { 238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TType t(variable->getType()); 23915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addConstantUnion(constArray, t, @1); 240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else 241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = context->intermediate.addSymbol(variable->getUniqueId(), 242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman variable->getName(), 24315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu variable->getType(), @1); 244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanprimary_expression 248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : variable_identifier { 249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | INTCONSTANT { 252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstantUnion *unionArray = new ConstantUnion[1]; 253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unionArray->setIConst($1.i); 25415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr), @1); 255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 2562c1239f554f88546f0f8abf30dc829bb621dd94bNicolas Capens | UINTCONSTANT { 2572c1239f554f88546f0f8abf30dc829bb621dd94bNicolas Capens ConstantUnion *unionArray = new ConstantUnion[1]; 2582c1239f554f88546f0f8abf30dc829bb621dd94bNicolas Capens unionArray->setUConst($1.u); 25915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConstExpr), @1); 2602c1239f554f88546f0f8abf30dc829bb621dd94bNicolas Capens } 261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | FLOATCONSTANT { 262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstantUnion *unionArray = new ConstantUnion[1]; 263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unionArray->setFConst($1.f); 26415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConstExpr), @1); 265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | BOOLCONSTANT { 267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstantUnion *unionArray = new ConstantUnion[1]; 268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unionArray->setBConst($1.b); 26915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConstExpr), @1); 270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | LEFT_PAREN expression RIGHT_PAREN { 272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $2; 273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 276894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanpostfix_expression 277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : primary_expression { 278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET { 28115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addIndexExpression($1, @2, $3); 282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | function_call { 284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | postfix_expression DOT FIELD_SELECTION { 28715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addFieldSelectionExpression($1, @2, *$3.string, @3); 288894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | postfix_expression INC_OP { 29015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addUnaryMathLValue(EOpPostIncrement, $1, @2); 291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | postfix_expression DEC_OP { 29315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addUnaryMathLValue(EOpPostDecrement, $1, @2); 294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 295894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumaninteger_expression 298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : expression { 299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (context->integerErrorCheck($1, "[]")) 300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_call 306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_call_or_method { 307eee212e77d07ef0ad4dd9396c62dc318435ae3d3Alexis Hetu bool fatalError = false; 308950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu $$ = context->addFunctionCallOrMethod($1.function, $1.nodePair.node1, $1.nodePair.node2, @1, &fatalError); 309eee212e77d07ef0ad4dd9396c62dc318435ae3d3Alexis Hetu if (fatalError) 310894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 311eee212e77d07ef0ad4dd9396c62dc318435ae3d3Alexis Hetu YYERROR; 312894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 316894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_call_or_method 317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_call_generic { 318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 319950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu $$.nodePair.node2 = nullptr; 320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | postfix_expression DOT function_call_generic { 322950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu ES3_ONLY("", @3, "methods"); 323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $3; 324950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu $$.nodePair.node2 = $1; 325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_call_generic 329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_call_header_with_parameters RIGHT_PAREN { 330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 331894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | function_call_header_no_parameters RIGHT_PAREN { 333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_call_header_no_parameters 338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_call_header VOID_TYPE { 339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.function = $1; 340950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu $$.nodePair.node1 = nullptr; 341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | function_call_header { 343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.function = $1; 344950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu $$.nodePair.node1 = nullptr; 345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_call_header_with_parameters 349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_call_header assignment_expression { 350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TParameter param = { 0, new TType($2->getType()) }; 351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $1->addParameter(param); 352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.function = $1; 353950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu $$.nodePair.node1 = $2; 354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | function_call_header_with_parameters COMMA assignment_expression { 356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TParameter param = { 0, new TType($3->getType()) }; 357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $1.function->addParameter(param); 358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.function = $1.function; 359950cb449744bc5d4e3d8ad8432e4549f5e29863cAlexis Hetu $$.nodePair.node1 = context->intermediate.growAggregate($1.intermNode, $3, @2); 360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_call_header 364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_identifier LEFT_PAREN { 365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// Grammar Note: Constructors look like functions, but are recognized as types. 370894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_identifier 372e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu : type_specifier_no_prec { 373e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu if ($1.array) { 3743e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("[]", @1, "array constructor"); 375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 376e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addConstructorFunc($1); 377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | IDENTIFIER { 37915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->reservedErrorCheck(@1, *$1.string)) 380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TType type(EbtVoid, EbpUndefined); 382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TFunction *function = new TFunction($1.string, type); 383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = function; 384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | FIELD_SELECTION { 38615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->reservedErrorCheck(@1, *$1.string)) 387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TType type(EbtVoid, EbpUndefined); 389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TFunction *function = new TFunction($1.string, type); 390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = function; 391894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 393894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanunary_expression 395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : postfix_expression { 396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | INC_OP unary_expression { 399242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->addUnaryMathLValue(EOpPreIncrement, $2, @1); 400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | DEC_OP unary_expression { 402242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->addUnaryMathLValue(EOpPreDecrement, $2, @1); 403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | unary_operator unary_expression { 405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($1.op != EOpNull) { 406242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->addUnaryMath($1.op, $2, @1); 407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else 408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $2; 409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 411894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// Grammar Note: No traditional style type casts. 412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanunary_operator 414242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu : PLUS { $$.op = EOpNull; } 415242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | DASH { $$.op = EOpNegative; } 416242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | BANG { $$.op = EOpLogicalNot; } 4171780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu | TILDE { 4183e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("~", @1, "bit-wise operator"); 419242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$.op = EOpBitwiseNot; 4201780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu } 421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// Grammar Note: No '*' or '&' unary ops. Pointers are not supported. 423894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanmultiplicative_expression 425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : unary_expression { $$ = $1; } 426894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | multiplicative_expression STAR unary_expression { 42715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("*", @2); 428b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpMul, $1, $3, @2); 429894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | multiplicative_expression SLASH unary_expression { 43115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("/", @2); 432b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpDiv, $1, $3, @2); 433894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4341780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu | multiplicative_expression PERCENT unary_expression { 43515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("%", @2); 4363e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("%", @2, "integer modulus operator"); 437b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpIMod, $1, $3, @2); 4381780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu } 439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 441894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanadditive_expression 442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : multiplicative_expression { $$ = $1; } 443894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | additive_expression PLUS multiplicative_expression { 444b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpAdd, $1, $3, @2); 445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 446894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | additive_expression DASH multiplicative_expression { 447b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpSub, $1, $3, @2); 448894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 449894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 451894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanshift_expression 452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : additive_expression { $$ = $1; } 4531780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu | shift_expression LEFT_OP additive_expression { 4543e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("<<", @2, "bit-wise operator"); 455b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpBitShiftLeft, $1, $3, @2); 4561780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu } 4571780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu | shift_expression RIGHT_OP additive_expression { 4583e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY(">>", @2, "bit-wise operator"); 459b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpBitShiftRight, $1, $3, @2); 4601780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu } 461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 463894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanrelational_expression 464894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : shift_expression { $$ = $1; } 465894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | relational_expression LEFT_ANGLE shift_expression { 466b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpLessThan, $1, $3, @2); 467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 468894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | relational_expression RIGHT_ANGLE shift_expression { 469b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpGreaterThan, $1, $3, @2); 470894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | relational_expression LE_OP shift_expression { 472b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpLessThanEqual, $1, $3, @2); 473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 474894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | relational_expression GE_OP shift_expression { 475b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpGreaterThanEqual, $1, $3, @2); 476894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 478894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanequality_expression 480894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : relational_expression { $$ = $1; } 481894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | equality_expression EQ_OP relational_expression { 482b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpEqual, $1, $3, @2); 483894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 484894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | equality_expression NE_OP relational_expression { 485b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpNotEqual, $1, $3, @2); 486894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 487894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 488894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 489894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanand_expression 490894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : equality_expression { $$ = $1; } 4911780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu | and_expression AMPERSAND equality_expression { 4923e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("&", @2, "bit-wise operator"); 493b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpBitwiseAnd, $1, $3, @2); 4941780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu } 495894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 496894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanexclusive_or_expression 498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : and_expression { $$ = $1; } 4991780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu | exclusive_or_expression CARET and_expression { 5003e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("^", @2, "bit-wise operator"); 501b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpBitwiseXor, $1, $3, @2); 5021780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu } 503894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 504894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 505894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumaninclusive_or_expression 506894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : exclusive_or_expression { $$ = $1; } 5071780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu | inclusive_or_expression VERTICAL_BAR exclusive_or_expression { 5083e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("|", @2, "bit-wise operator"); 509b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMath(EOpBitwiseOr, $1, $3, @2); 5101780905ed341f3b5df8fd87774ed53d3aaaa280fAlexis Hetu } 511894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanlogical_and_expression 514894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : inclusive_or_expression { $$ = $1; } 515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | logical_and_expression AND_OP inclusive_or_expression { 516b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpLogicalAnd, $1, $3, @2); 517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 518894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 519894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 520894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanlogical_xor_expression 521894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : logical_and_expression { $$ = $1; } 522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | logical_xor_expression XOR_OP logical_and_expression { 523b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpLogicalXor, $1, $3, @2); 524894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 525894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 526894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 527894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanlogical_or_expression 528894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : logical_xor_expression { $$ = $1; } 529894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | logical_or_expression OR_OP logical_xor_expression { 530b4769581b65063fe83d673677dfd2109619ed8b5Alexis Hetu $$ = context->addBinaryMathBooleanResult(EOpLogicalOr, $1, $3, @2); 531894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 532894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 533894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 534894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanconditional_expression 535894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : logical_or_expression { $$ = $1; } 536894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | logical_or_expression QUESTION expression COLON assignment_expression { 537eee212e77d07ef0ad4dd9396c62dc318435ae3d3Alexis Hetu $$ = context->addTernarySelection($1, $3, $5, @2); 538894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 539894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 540894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 541894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanassignment_expression 542894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : conditional_expression { $$ = $1; } 543894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | unary_expression assignment_operator assignment_expression { 54415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->lValueErrorCheck(@2, "assign", $1)) 545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 546e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addAssign($2.op, $1, $3, @2); 547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 548894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 549894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanassignment_operator 551242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu : EQUAL { $$.op = EOpAssign; } 552242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | MUL_ASSIGN { FRAG_VERT_ONLY("*=", @1); $$.op = EOpMulAssign; } 553242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | DIV_ASSIGN { FRAG_VERT_ONLY("/=", @1); $$.op = EOpDivAssign; } 5543e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu | MOD_ASSIGN { ES3_ONLY("%=", @1, "integer modulus operator"); 555242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu FRAG_VERT_ONLY("%=", @1); $$.op = EOpIModAssign; } 556242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | ADD_ASSIGN { $$.op = EOpAddAssign; } 557242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | SUB_ASSIGN { $$.op = EOpSubAssign; } 5583e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu | LEFT_ASSIGN { ES3_ONLY("<<=", @1, "bit-wise operator"); 559242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu FRAG_VERT_ONLY("<<=", @1); 560242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$.op = EOpBitShiftLeftAssign; } 5613e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu | RIGHT_ASSIGN { ES3_ONLY(">>=", @1, "bit-wise operator"); 562242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu FRAG_VERT_ONLY(">>=", @1); 563242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$.op = EOpBitShiftRightAssign; } 5643e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu | AND_ASSIGN { ES3_ONLY("&=", @1, "bit-wise operator"); 565242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu FRAG_VERT_ONLY("&=", @1); 566242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$.op = EOpBitwiseAndAssign; } 5673e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu | XOR_ASSIGN { ES3_ONLY("^=", @1, "bit-wise operator"); 568242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu FRAG_VERT_ONLY("^=", @1); 569242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$.op = EOpBitwiseXorAssign; } 5703e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu | OR_ASSIGN { ES3_ONLY("|=", @1, "bit-wise operator"); 571242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu FRAG_VERT_ONLY("|=", @1); 572242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$.op = EOpBitwiseOrAssign; } 573894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 574894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 575894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanexpression 576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : assignment_expression { 577894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 578894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 579894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | expression COMMA assignment_expression { 58015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addComma($1, $3, @2); 581894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($$ == 0) { 58215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->binaryOpError(@2, ",", $1->getCompleteString(), $3->getCompleteString()); 583894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 584894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $3; 585894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 586894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 587894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 588894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 589894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanconstant_expression 590894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : conditional_expression { 591894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (context->constErrorCheck($1)) 592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 593894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 594894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 595894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 596894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 597a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetuenter_struct 598a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu : IDENTIFIER LEFT_BRACE { 599e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu if (context->enterStructDeclaration(@1, *$1.string)) 600a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu context->recover(); 601a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu $$ = $1; 602a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu } 603a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu ; 604a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu 605894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumandeclaration 606242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu : function_prototype SEMICOLON { 607242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->addFunctionPrototypeDeclaration(*($1.function), @1); 608894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 609894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | init_declarator_list SEMICOLON { 610dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu TIntermAggregate *aggNode = $1.intermAggregate; 611dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu if (aggNode && aggNode->getOp() == EOpNull) 612dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu aggNode->setOp(EOpDeclaration); 613dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu $$ = aggNode; 614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 615894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | PRECISION precision_qualifier type_specifier_no_prec SEMICOLON { 616d4ae863d01d5f448dbbba6be4ecc161971a2324fJohn Bauman if (!context->symbolTable.setDefaultPrecision( $3, $2 )) { 61715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@1, "illegal type argument for default precision qualifier", getBasicString($3.type)); 618d4ae863d01d5f448dbbba6be4ecc161971a2324fJohn Bauman context->recover(); 619d4ae863d01d5f448dbbba6be4ecc161971a2324fJohn Bauman } 620894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = 0; 621894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 622a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE SEMICOLON { 6233e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY(getQualifierString($1.qualifier), @1, "interface blocks"); 624e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addInterfaceBlock($1, @2, *$2.string, $3, NULL, @1, NULL, @1); 625a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu } 626a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER SEMICOLON { 6273e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY(getQualifierString($1.qualifier), @1, "interface blocks"); 628e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addInterfaceBlock($1, @2, *$2.string, $3, $5.string, @5, NULL, @1); 629a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu } 630a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET SEMICOLON { 6313e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY(getQualifierString($1.qualifier), @1, "interface blocks"); 632e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addInterfaceBlock($1, @2, *$2.string, $3, $5.string, @5, $7, @6); 633a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu } 634a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu | type_qualifier SEMICOLON { 635a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu context->parseGlobalLayoutQualifier($1); 636a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu $$ = 0; 637a35d8232a5276bef4eae7230d0ed71ce89aa23e8Alexis Hetu } 638894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 640894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_prototype 641894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_declarator RIGHT_PAREN { 642242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$.function = context->parseFunctionDeclarator(@2, $1); 643894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 644894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 645894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 646894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_declarator 647894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_header { 648894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 649894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 650894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | function_header_with_parameters { 651894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 653894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 654894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 655894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 656894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_header_with_parameters 657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_header parameter_declaration { 658894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Add the parameter 659894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 660894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($2.param.type->getBasicType() != EbtVoid) 661894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $1->addParameter($2.param); 662894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman delete $2.param.type; 664894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 665894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | function_header_with_parameters COMMA parameter_declaration { 666894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Only first parameter of one-parameter functions can be void 668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // The check for named parameters not being void is done in parameter_declarator 669894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 670894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($3.param.type->getBasicType() == EbtVoid) { 671894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 672894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // This parameter > first is void 673894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 67415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@2, "cannot be an argument type except for '(void)'", "void"); 675894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 676894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman delete $3.param.type; 677894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else { 678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Add the parameter 679894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $1->addParameter($3.param); 681894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 682894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 684894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_header 686894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : fully_specified_type IDENTIFIER LEFT_PAREN { 687894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) { 68815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@2, "no qualifiers allowed for function return", getQualifierString($1.qualifier)); 689894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 691242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu if (!$1.layoutQualifier.isEmpty()) 692242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu { 693242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu context->error(@2, "no qualifiers allowed for function return", "layout"); 694242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu context->recover(); 695242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu } 696894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // make sure a sampler is not involved as well... 697242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu if (context->samplerErrorCheck(@2, $1, "samplers can't be function return values")) 698894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 699894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 700894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Add the function as a prototype after parsing it (we do not support recursion) 701894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TFunction *function; 702894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TType type($1); 703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman function = new TFunction($2.string, type); 704894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = function; 7052cb7452bae261744d6410a01a54fd398f7f0c2acNicolas Capens 70666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman context->symbolTable.push(); 707894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 708894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 709894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 710894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanparameter_declarator 711894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Type + name 712894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : type_specifier IDENTIFIER { 713894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($1.type == EbtVoid) { 71415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@2, "illegal use of type 'void'", $2.string->c_str()); 715894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 716894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 71715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->reservedErrorCheck(@2, *$2.string)) 718894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 719894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TParameter param = {$2.string, new TType($1)}; 720894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.param = param; 721894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 722894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { 723894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Check that we can make an array out of this type 72415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->arrayTypeErrorCheck(@3, $1)) 725894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 726894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 72715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->reservedErrorCheck(@2, *$2.string)) 728894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 729894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 730894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int size; 73115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->arraySizeErrorCheck(@3, $4, size)) 732894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 733894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $1.setArray(true, size); 734894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 735894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TType* type = new TType($1); 736894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TParameter param = { $2.string, type }; 737894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.param = param; 738894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 739894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 740894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 741894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanparameter_declaration 742894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 743894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // The only parameter qualifier a parameter can have are 744894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // IN_QUAL, OUT_QUAL, INOUT_QUAL, or CONST. 745894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 746894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 747894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 748894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Type + name 749894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 750a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens : parameter_type_qualifier parameter_qualifier parameter_declarator { 751894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $3; 75215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->paramErrorCheck(@3, $1, $2, $$.param.type)) 753894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 754894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 755894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | parameter_qualifier parameter_declarator { 756894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $2; 75715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->parameterSamplerErrorCheck(@2, $1, *$2.param.type)) 758894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 75915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->paramErrorCheck(@2, EvqTemporary, $1, $$.param.type)) 760894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 761894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 762894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 763894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Only type 764894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 765a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens | parameter_type_qualifier parameter_qualifier parameter_type_specifier { 766894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $3; 76715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->paramErrorCheck(@3, $1, $2, $$.param.type)) 768894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 769894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 770894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | parameter_qualifier parameter_type_specifier { 771894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $2; 77215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->parameterSamplerErrorCheck(@2, $1, *$2.param.type)) 773894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 77415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->paramErrorCheck(@2, EvqTemporary, $1, $$.param.type)) 775894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 776894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 777894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 778894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 779894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanparameter_qualifier 780894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : /* empty */ { 781894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = EvqIn; 782894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 783894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | IN_QUAL { 784894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = EvqIn; 785894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 786894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | OUT_QUAL { 787894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = EvqOut; 788894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 789894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | INOUT_QUAL { 790894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = EvqInOut; 791894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 792894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 793894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 794894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanparameter_type_specifier 795894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : type_specifier { 796894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TParameter param = { 0, new TType($1) }; 797894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.param = param; 798894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 799894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 800894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 801894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumaninit_declarator_list 802894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : single_declaration { 803894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 804894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 805894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | init_declarator_list COMMA IDENTIFIER { 806894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 80715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseDeclarator($$.type, $1.intermAggregate, @3, *$3.string); 808894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 809894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { 810894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 81115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseArrayDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, $5); 812dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu } 813dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer { 8143e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("[]", @3, "implicitly sized array"); 815dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu $$ = $1; 81615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseArrayInitDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, nullptr, @6, $7); 817dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu } 818dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer { 8193e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("=", @7, "first-class arrays (array initializer)"); 820dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu $$ = $1; 82115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseArrayInitDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, $5, @7, $8); 822894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 823894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | init_declarator_list COMMA IDENTIFIER EQUAL initializer { 824894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 82515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseInitDeclarator($$.type, $1.intermAggregate, @3, *$3.string, @4, $5); 826894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 827894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 828894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 829894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumansingle_declaration 830894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : fully_specified_type { 831894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.type = $1; 83215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseSingleDeclaration($$.type, @1, ""); 833894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 834894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | fully_specified_type IDENTIFIER { 835894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.type = $1; 83615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseSingleDeclaration($$.type, @2, *$2.string); 837894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 838894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { 839894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.type = $1; 84015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseSingleArrayDeclaration($$.type, @2, *$2.string, @3, $4); 841dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu } 842dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu | fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer { 8433e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("[]", @3, "implicitly sized array"); 844dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu $$.type = $1; 84515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseSingleArrayInitDeclaration($$.type, @2, *$2.string, @3, nullptr, @5, $6); 846dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu } 847dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer { 8483e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("=", @6, "first-class arrays (array initializer)"); 849dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu $$.type = $1; 85015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseSingleArrayInitDeclaration($$.type, @2, *$2.string, @3, $4, @6, $7); 851894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 852894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | fully_specified_type IDENTIFIER EQUAL initializer { 853894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.type = $1; 85415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseSingleInitDeclaration($$.type, @2, *$2.string, @3, $4); 855894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 856894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | INVARIANT IDENTIFIER { 857dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu // $$.type is not used in invariant declarations. 85815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.intermAggregate = context->parseInvariantDeclaration(@1, @2, $2.string, $2.symbol); 859894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 860dd7ff7a5695e28d5e1fe156349786639ee0783d7Alexis Hetu ; 861894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 862894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfully_specified_type 863894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : type_specifier { 864894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 865894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 866894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($1.array) { 8673e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("[]", @1, "first-class-array"); 86842ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu if (context->getShaderVersion() != 300) { 86942ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu $1.clearArrayness(); 87042ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu } 871894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 872894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 873894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | type_qualifier type_specifier { 87442ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu $$ = context->addFullySpecifiedType($1.qualifier, $1.invariant, $1.layoutQualifier, $2); 875894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 876894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 877894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 87855a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetuinterpolation_qualifier 87955a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu : SMOOTH { 88055a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu $$.qualifier = EvqSmooth; 88155a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu } 88255a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu | FLAT { 88355a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu $$.qualifier = EvqFlat; 88455a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu } 88555a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu ; 88655a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu 887a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capensparameter_type_qualifier 888894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : CONST_QUAL { 889b1e911adcb5cafce13997878b9c0cf7921d694c5Nicolas Capens $$ = EvqConstReadOnly; 890894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 891a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens ; 892a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens 893a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capenstype_qualifier 894a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens : ATTRIBUTE { 89515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu VERTEX_ONLY("attribute", @1); 89615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu ES2_ONLY("attribute", @1); 89715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "attribute")) 898894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 89915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, EvqAttribute, @1); 900894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 901894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | VARYING { 90215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu ES2_ONLY("varying", @1); 90315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "varying")) 904894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 9050a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderType() == GL_VERTEX_SHADER) 90615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, EvqVaryingOut, @1); 907894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 90815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, EvqVaryingIn, @1); 909894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 910894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | INVARIANT VARYING { 91115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu ES2_ONLY("varying", @1); 91215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "invariant varying")) 913894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 9140a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderType() == GL_VERTEX_SHADER) 91515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, EvqInvariantVaryingOut, @1); 916894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 91715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, EvqInvariantVaryingIn, @1); 918894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 919242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | storage_qualifier { 920242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu if ($1.qualifier != EvqConstExpr && !context->symbolTable.atGlobalLevel()) 921242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu { 922242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu context->error(@1, "Local variables can only use the const storage qualifier.", getQualifierString($1.qualifier)); 923242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu context->recover(); 924242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu } 92515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, $1.qualifier, @1); 926a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens } 92755a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu | interpolation_qualifier storage_qualifier { 92815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->joinInterpolationQualifiers(@1, $1.qualifier, @2, $2.qualifier); 92955a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu } 93055a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu | interpolation_qualifier { 93115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@1, "interpolation qualifier requires a fragment 'in' or vertex 'out' storage qualifier", getQualifierString($1.qualifier)); 93255a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu context->recover(); 9332cb7452bae261744d6410a01a54fd398f7f0c2acNicolas Capens 93455a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 93515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, qual, @1); 93655a2cbc6454aaccaaec43a842602e23c917d8307Alexis Hetu } 9377d626796531874d308706c46a32942d71c85a7f8Nicolas Capens | layout_qualifier { 9387d626796531874d308706c46a32942d71c85a7f8Nicolas Capens $$.qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 9397d626796531874d308706c46a32942d71c85a7f8Nicolas Capens $$.layoutQualifier = $1; 9407d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 9417d626796531874d308706c46a32942d71c85a7f8Nicolas Capens | layout_qualifier storage_qualifier { 94215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, $2.qualifier, @2); 9437d626796531874d308706c46a32942d71c85a7f8Nicolas Capens $$.layoutQualifier = $1; 9447d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 945ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu | INVARIANT storage_qualifier { 946ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu context->es3InvariantErrorCheck($2.qualifier, @1); 947ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu $$.setBasic(EbtVoid, $2.qualifier, @2); 948ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu $$.invariant = true; 949ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu } 950ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu | INVARIANT interpolation_qualifier storage_qualifier { 951ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu context->es3InvariantErrorCheck($3.qualifier, @1); 952ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu $$ = context->joinInterpolationQualifiers(@2, $2.qualifier, @3, $3.qualifier); 953ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu $$.invariant = true; 954ad52775476d367199a4cd3b3b47ff8959e63bd59Alexis Hetu } 955a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens ; 956a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens 957a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capensstorage_qualifier 958a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens : CONST_QUAL { 95931ad2aa7f12e804d6628fb70d6e945c419cb2c7dNicolas Capens $$.qualifier = EvqConstExpr; 960a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens } 961a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens | IN_QUAL { 9623e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("in", @1, "storage qualifier"); 9630a65584a1529450c476c026f3254d78efc200645Alexis Hetu $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn; 964a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens } 965a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens | OUT_QUAL { 9663e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("out", @1, "storage qualifier"); 9670a65584a1529450c476c026f3254d78efc200645Alexis Hetu $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut; 968a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens } 969a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens | CENTROID IN_QUAL { 9703e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("centroid in", @1, "storage qualifier"); 9710a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderType() == GL_VERTEX_SHADER) 97242ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu { 97315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@1, "invalid storage qualifier", "it is an error to use 'centroid in' in the vertex shader"); 97442ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu context->recover(); 97542ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu } 9760a65584a1529450c476c026f3254d78efc200645Alexis Hetu $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn; 977a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens } 9783e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu | CENTROID OUT_QUAL { 9793e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("centroid out", @1, "storage qualifier"); 9800a65584a1529450c476c026f3254d78efc200645Alexis Hetu if (context->getShaderType() == GL_FRAGMENT_SHADER) 98142ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu { 98215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@1, "invalid storage qualifier", "it is an error to use 'centroid out' in the fragment shader"); 98342ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu context->recover(); 98442ff6b15714827bb44869e5f1c41918b461bf4c8Alexis Hetu } 9850a65584a1529450c476c026f3254d78efc200645Alexis Hetu $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut; 986a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens } 987242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu | UNIFORM { 98815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "uniform")) 989894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 990a6a79ab0490903fa4dd0d77bc3cf041e48936ecaNicolas Capens $$.qualifier = EvqUniform; 991894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 992894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 993894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 994894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantype_specifier 995894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : type_specifier_no_prec { 996894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 99766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 99866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman if ($$.precision == EbpUndefined) { 99966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman $$.precision = context->symbolTable.getDefaultPrecision($1.type); 100015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->precisionErrorCheck(@1, $$.precision, $1.type)) { 100166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman context->recover(); 100266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 100366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman } 1004894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1005894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | precision_qualifier type_specifier_no_prec { 1006894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $2; 1007894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.precision = $1; 1008242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu 1009242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu if (!SupportsPrecision($2.type)) { 1010242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu context->error(@1, "illegal type for precision qualifier", getBasicString($2.type)); 1011242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu context->recover(); 1012242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu } 1013894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1014894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1015894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1016894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanprecision_qualifier 1017894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : HIGH_PRECISION { 1018894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = EbpHigh; 1019894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1020894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | MEDIUM_PRECISION { 1021894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = EbpMedium; 1022894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1023894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | LOW_PRECISION { 1024894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = EbpLow; 1025894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1026894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1027894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 10287d626796531874d308706c46a32942d71c85a7f8Nicolas Capenslayout_qualifier 10297d626796531874d308706c46a32942d71c85a7f8Nicolas Capens : LAYOUT LEFT_PAREN layout_qualifier_id_list RIGHT_PAREN { 10303e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("layout", @1, "qualifier"); 10317d626796531874d308706c46a32942d71c85a7f8Nicolas Capens $$ = $3; 10327d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 10337d626796531874d308706c46a32942d71c85a7f8Nicolas Capens ; 10347d626796531874d308706c46a32942d71c85a7f8Nicolas Capens 10357d626796531874d308706c46a32942d71c85a7f8Nicolas Capenslayout_qualifier_id_list 10367d626796531874d308706c46a32942d71c85a7f8Nicolas Capens : layout_qualifier_id { 10377d626796531874d308706c46a32942d71c85a7f8Nicolas Capens $$ = $1; 10387d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 10397d626796531874d308706c46a32942d71c85a7f8Nicolas Capens | layout_qualifier_id_list COMMA layout_qualifier_id { 10407d626796531874d308706c46a32942d71c85a7f8Nicolas Capens $$ = context->joinLayoutQualifiers($1, $3); 10417d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 10427d626796531874d308706c46a32942d71c85a7f8Nicolas Capens ; 10437d626796531874d308706c46a32942d71c85a7f8Nicolas Capens 10447d626796531874d308706c46a32942d71c85a7f8Nicolas Capenslayout_qualifier_id 10457d626796531874d308706c46a32942d71c85a7f8Nicolas Capens : IDENTIFIER { 104615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->parseLayoutQualifier(*$1.string, @1); 10477d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 10487d626796531874d308706c46a32942d71c85a7f8Nicolas Capens | IDENTIFIER EQUAL INTCONSTANT { 104915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3); 10507d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 10517d626796531874d308706c46a32942d71c85a7f8Nicolas Capens | IDENTIFIER EQUAL UINTCONSTANT { 105215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3); 10537d626796531874d308706c46a32942d71c85a7f8Nicolas Capens } 10547d626796531874d308706c46a32942d71c85a7f8Nicolas Capens ; 10557d626796531874d308706c46a32942d71c85a7f8Nicolas Capens 1056894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantype_specifier_no_prec 1057894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : type_specifier_nonarray { 1058894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1059894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1060e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu | type_specifier_nonarray LEFT_BRACKET RIGHT_BRACKET { 10613e9e208b8f2cedb9e45a369d3e8c97456336f70cAlexis Hetu ES3_ONLY("[]", @2, "implicitly sized array"); 1062e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = $1; 1063e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$.setArray(true, 0); 1064e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu } 1065894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET { 1066894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1067894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 106815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->arrayTypeErrorCheck(@2, $1)) 1069894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1070894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else { 1071894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int size; 107215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->arraySizeErrorCheck(@2, $3, size)) 1073894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1074894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setArray(true, size); 1075894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1076894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1077894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1078894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1079894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantype_specifier_nonarray 1080894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : VOID_TYPE { 1081894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 108215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtVoid, qual, @1); 1083894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1084894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | FLOAT_TYPE { 1085894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 108615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1087894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1088894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | INT_TYPE { 1089894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 109015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtInt, qual, @1); 1091894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 10923c20f806dd9b3492c7ab102858f84f7cfd73133eNicolas Capens | UINT_TYPE { 10933c20f806dd9b3492c7ab102858f84f7cfd73133eNicolas Capens TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 109415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUInt, qual, @1); 10953c20f806dd9b3492c7ab102858f84f7cfd73133eNicolas Capens } 1096894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | BOOL_TYPE { 1097894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 109815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtBool, qual, @1); 1099894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | VEC2 { 1101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 110215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(2); 1104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | VEC3 { 1106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 110715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(3); 1109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | VEC4 { 1111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 111215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(4); 1114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | BVEC2 { 1116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 111715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtBool, qual, @1); 1118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(2); 1119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | BVEC3 { 1121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 112215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtBool, qual, @1); 1123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(3); 1124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | BVEC4 { 1126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 112715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtBool, qual, @1); 1128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(4); 1129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | IVEC2 { 1131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 113215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtInt, qual, @1); 1133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(2); 1134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | IVEC3 { 1136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 113715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtInt, qual, @1); 1138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(3); 1139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | IVEC4 { 1141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 114215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtInt, qual, @1); 1143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.setAggregate(4); 1144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1145e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens | UVEC2 { 1146e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 114715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUInt, qual, @1); 1148e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens $$.setAggregate(2); 1149e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens } 1150e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens | UVEC3 { 1151e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 115215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUInt, qual, @1); 1153e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens $$.setAggregate(3); 1154e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens } 1155e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens | UVEC4 { 1156e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 115715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUInt, qual, @1); 1158e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens $$.setAggregate(4); 1159e4b1b1d8063673537b113beafff48b58ced93f6fNicolas Capens } 1160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | MATRIX2 { 116115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat2", @1); 1162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 116315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1164b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(2, 2); 1165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | MATRIX3 { 116715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat3", @1); 1168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 116915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1170b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(3, 3); 1171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | MATRIX4 { 117315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat4", @1); 1174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 117515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1176b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(4, 4); 1177b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1178b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | MATRIX2x3 { 117915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat2x3", @1); 1180b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 118115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1182b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(2, 3); 1183b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1184b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | MATRIX3x2 { 118515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat3x2", @1); 1186b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 118715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1188b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(3, 2); 1189b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1190b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | MATRIX2x4 { 119115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat2x4", @1); 1192b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 119315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1194b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(2, 4); 1195b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1196b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | MATRIX4x2 { 119715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat4x2", @1); 1198b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 119915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1200b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(4, 2); 1201b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1202b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | MATRIX3x4 { 120315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat3x4", @1); 1204b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 120515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1206b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(3, 4); 1207b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1208b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | MATRIX4x3 { 120915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("mat4x3", @1); 1210b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 121115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtFloat, qual, @1); 1212b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu $$.setMatrix(4, 3); 1213894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | SAMPLER2D { 121515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("sampler2D", @1); 1216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 121715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSampler2D, qual, @1); 1218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | SAMPLERCUBE { 122015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("samplerCube", @1); 1221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 122215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSamplerCube, qual, @1); 1223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1224e9c5e4f164bda3197b4c69bf6e433e87e9f46d19Nicolas Capens | SAMPLER_EXTERNAL_OES { 1225e9c5e4f164bda3197b4c69bf6e433e87e9f46d19Nicolas Capens if (!context->supportsExtension("GL_OES_EGL_image_external")) { 122615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu context->error(@1, "unsupported type", "samplerExternalOES", ""); 1227e9c5e4f164bda3197b4c69bf6e433e87e9f46d19Nicolas Capens context->recover(); 1228e9c5e4f164bda3197b4c69bf6e433e87e9f46d19Nicolas Capens } 122915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("samplerExternalOES", @1); 1230e9c5e4f164bda3197b4c69bf6e433e87e9f46d19Nicolas Capens TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 123115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSamplerExternalOES, qual, @1); 1232e9c5e4f164bda3197b4c69bf6e433e87e9f46d19Nicolas Capens } 1233b027aa91f4b20c5062fbc781d0ff693bf294cbccAlexis Hetu | SAMPLER3D { 123415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("sampler3D", @1); 1235b027aa91f4b20c5062fbc781d0ff693bf294cbccAlexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 123615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSampler3D, qual, @1); 1237b027aa91f4b20c5062fbc781d0ff693bf294cbccAlexis Hetu } 1238b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | SAMPLER2DARRAY { 123915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("sampler2DArray", @1); 1240b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 124115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSampler2DArray, qual, @1); 1242b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1243b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | ISAMPLER2D { 124415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("isampler2D", @1); 1245b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 124615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtISampler2D, qual, @1); 1247b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1248b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | ISAMPLER3D { 124915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("isampler3D", @1); 1250b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 125115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtISampler3D, qual, @1); 1252b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1253b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | ISAMPLERCUBE { 125415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("isamplerCube", @1); 1255b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 125615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtISamplerCube, qual, @1); 1257b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1258b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | ISAMPLER2DARRAY { 125915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("isampler2DArray", @1); 1260b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 126115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtISampler2DArray, qual, @1); 1262b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1263b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | USAMPLER2D { 126415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("usampler2D", @1); 1265b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 126615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUSampler2D, qual, @1); 1267b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1268b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | USAMPLER3D { 126915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("usampler3D", @1); 1270b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 127115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUSampler3D, qual, @1); 1272b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1273b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | USAMPLERCUBE { 127415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("usamplerCube", @1); 1275b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 127615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUSamplerCube, qual, @1); 1277b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1278b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | USAMPLER2DARRAY { 127915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("usampler2DArray", @1); 1280b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 128115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtUSampler2DArray, qual, @1); 1282b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1283b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | SAMPLER2DSHADOW { 128415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("sampler2DShadow", @1); 1285b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 128615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSampler2DShadow, qual, @1); 1287b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1288b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | SAMPLERCUBESHADOW { 128915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("samplerCubeShadow", @1); 1290b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 129115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSamplerCubeShadow, qual, @1); 1292b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1293b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu | SAMPLER2DARRAYSHADOW { 129415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("sampler2DArrayShadow", @1); 1295b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 129615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtSampler2DArrayShadow, qual, @1); 1297b14178b68ccb44a1fca9ba4e7db7770c6b6b6fa9Alexis Hetu } 1298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | struct_specifier { 129915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_VERT_ONLY("struct", @1); 1300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 1302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | TYPE_NAME { 1304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 1305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // This is for user defined type names. The lexical phase looked up the 1306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // type. 1307894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // 1308894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TType& structure = static_cast<TVariable*>($1.symbol)->getType(); 1309894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; 131015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$.setBasic(EbtStruct, qual, @1); 1311894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.userDef = &structure; 1312894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct_specifier 131615ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu : STRUCT IDENTIFIER LEFT_BRACE { if (context->enterStructDeclaration(@2, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE { 131715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addStructure(@1, @2, $2.string, $5); 1318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 131915ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu | STRUCT LEFT_BRACE { if (context->enterStructDeclaration(@2, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE { 132015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addStructure(@1, @1, NewPoolTString(""), $4); 1321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct_declaration_list 1325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : struct_declaration { 1326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | struct_declaration_list struct_declaration { 1329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for (unsigned int i = 0; i < $2->size(); ++i) { 1331a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu TField* field = (*$2)[i]; 1332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for (unsigned int j = 0; j < $$->size(); ++j) { 1333a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu if ((*$$)[j]->name() == field->name()) { 1334a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu context->error((*$2)[i]->line(), "duplicate field name in structure:", "struct", field->name().c_str()); 1335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$->push_back((*$2)[i]); 1339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct_declaration 1344894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : type_specifier struct_declarator_list SEMICOLON { 1345ad6b87569fb1d2e1705e6e4b090d209be3f68e68Alexis Hetu $$ = context->addStructDeclaratorList($1, $2); 1346ad6b87569fb1d2e1705e6e4b090d209be3f68e68Alexis Hetu } 1347ad6b87569fb1d2e1705e6e4b090d209be3f68e68Alexis Hetu | type_qualifier type_specifier struct_declarator_list SEMICOLON { 1348ad6b87569fb1d2e1705e6e4b090d209be3f68e68Alexis Hetu // ES3 Only, but errors should be handled elsewhere 1349ad6b87569fb1d2e1705e6e4b090d209be3f68e68Alexis Hetu $2.qualifier = $1.qualifier; 1350ad6b87569fb1d2e1705e6e4b090d209be3f68e68Alexis Hetu $2.layoutQualifier = $1.layoutQualifier; 1351ad6b87569fb1d2e1705e6e4b090d209be3f68e68Alexis Hetu $$ = context->addStructDeclaratorList($2, $3); 1352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct_declarator_list 1356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : struct_declarator { 1357a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu $$ = NewPoolTFieldList(); 1358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$->push_back($1); 1359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | struct_declarator_list COMMA struct_declarator { 1361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$->push_back($3); 1362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstruct_declarator 1366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : IDENTIFIER { 136715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->reservedErrorCheck(@1, *$1.string)) 1368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1370a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu TType* type = new TType(EbtVoid, EbpUndefined); 137115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = new TField(type, $1.string, @1); 1372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { 137415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->reservedErrorCheck(@1, *$1.string)) 1375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1377a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu TType* type = new TType(EbtVoid, EbpUndefined); 1378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int size; 1379a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu if (context->arraySizeErrorCheck($3->getLine(), $3, size)) 1380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1381a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu type->setArraySize(size); 1382a8b364b735624da31500d0fe93ae75f8b36a59d1Alexis Hetu 138315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = new TField(type, $1.string, @1); 1384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1386894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumaninitializer 1388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : assignment_expression { $$ = $1; } 1389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1391894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumandeclaration_statement 1392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : declaration { $$ = $1; } 1393894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstatement 1396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : compound_statement { $$ = $1; } 1397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | simple_statement { $$ = $1; } 1398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1400242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu// Grammar Note: Labeled statements for SWITCH only; 'goto' is not supported. 1401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumansimple_statement 1403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : declaration_statement { $$ = $1; } 1404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | expression_statement { $$ = $1; } 1405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | selection_statement { $$ = $1; } 140676a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu | switch_statement { $$ = $1; } 140776a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu | case_label { $$ = $1; } 1408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | iteration_statement { $$ = $1; } 1409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | jump_statement { $$ = $1; } 1410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1411894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumancompound_statement 1413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : LEFT_BRACE RIGHT_BRACE { $$ = 0; } 1414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | LEFT_BRACE { context->symbolTable.push(); } statement_list { context->symbolTable.pop(); } RIGHT_BRACE { 1415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($3 != 0) { 1416894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $3->setOp(EOpSequence); 141715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $3->setEndLine(@5); 1418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $3; 1420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1423894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstatement_no_new_scope 1424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : compound_statement_no_new_scope { $$ = $1; } 1425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | simple_statement { $$ = $1; } 1426894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 142819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanstatement_with_scope 142919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman : { context->symbolTable.push(); } compound_statement_no_new_scope { context->symbolTable.pop(); $$ = $2; } 143019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman | { context->symbolTable.push(); } simple_statement { context->symbolTable.pop(); $$ = $2; } 143119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman ; 143219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 1433894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumancompound_statement_no_new_scope 1434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Statement that doesn't create a new scope, for selection_statement, iteration_statement 1435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : LEFT_BRACE RIGHT_BRACE { 1436894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = 0; 1437894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1438894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | LEFT_BRACE statement_list RIGHT_BRACE { 1439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ($2) { 1440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $2->setOp(EOpSequence); 144115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $2->setEndLine(@3); 1442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1443894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $2; 1444894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1446894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanstatement_list 1448894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : statement { 1449242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->intermediate.makeAggregate($1, @$); 1450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1451894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | statement_list statement { 1452242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->intermediate.growAggregate($1, $2, @$); 1453894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1455894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1456894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanexpression_statement 1457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : SEMICOLON { $$ = 0; } 1458894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | expression SEMICOLON { $$ = static_cast<TIntermNode*>($1); } 1459894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1460894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanselection_statement 1462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement { 146315ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->boolErrorCheck(@1, $3)) 1464894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 146515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addSelection($3, $5, @1); 1466894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1468894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1469894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanselection_rest_statement 147019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman : statement_with_scope ELSE statement_with_scope { 1471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node1 = $1; 1472894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node2 = $3; 1473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 147419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman | statement_with_scope { 1475894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node1 = $1; 1476894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node2 = 0; 1477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1478894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 148076a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetuswitch_statement 148176a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu : SWITCH LEFT_PAREN expression RIGHT_PAREN { context->incrSwitchNestingLevel(); } compound_statement { 1482e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addSwitch($3, $6, @1); 148376a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu context->decrSwitchNestingLevel(); 148476a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu } 148576a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu ; 148676a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu 148776a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetucase_label 148876a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu : CASE constant_expression COLON { 1489e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addCase($2, @1); 149076a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu } 149176a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu | DEFAULT COLON { 1492e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu $$ = context->addDefault(@1); 149376a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu } 149476a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu ; 149576a343af4ea1f781a56fec006b5fe67a5615d5f8Alexis Hetu 1496894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumancondition 1497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // In 1996 c++ draft, conditions can include single declarations 1498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : expression { 1499894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1500894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (context->boolErrorCheck($1->getLine(), $1)) 1501894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1502894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1503894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | fully_specified_type IDENTIFIER EQUAL initializer { 1504242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu TIntermNode *intermNode; 150515ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->boolErrorCheck(@2, $1)) 1506894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1507894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1508e524669863d3a7ce8bf2e77fe05b24da555a6de9Alexis Hetu if (!context->executeInitializer(@2, *$2.string, $1, $4, &intermNode)) 1509894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $4; 1510894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else { 1511894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = 0; 1513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1514894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1516894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumaniteration_statement 15180a65584a1529450c476c026f3254d78efc200645Alexis Hetu : WHILE LEFT_PAREN { context->symbolTable.push(); context->incrLoopNestingLevel(); } condition RIGHT_PAREN statement_no_new_scope { 1519894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->symbolTable.pop(); 152015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addLoop(ELoopWhile, 0, $4, 0, $6, @1); 15210a65584a1529450c476c026f3254d78efc200645Alexis Hetu context->decrLoopNestingLevel(); 1522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 15230a65584a1529450c476c026f3254d78efc200645Alexis Hetu | DO { context->incrLoopNestingLevel(); } statement_with_scope WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON { 152415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu if (context->boolErrorCheck(@8, $6)) 1525894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->recover(); 1526894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 152715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addLoop(ELoopDoWhile, 0, $6, 0, $3, @4); 15280a65584a1529450c476c026f3254d78efc200645Alexis Hetu context->decrLoopNestingLevel(); 1529894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 15300a65584a1529450c476c026f3254d78efc200645Alexis Hetu | FOR LEFT_PAREN { context->symbolTable.push(); context->incrLoopNestingLevel(); } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope { 1531894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman context->symbolTable.pop(); 153215ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->intermediate.addLoop(ELoopFor, $4, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), $7, @1); 15330a65584a1529450c476c026f3254d78efc200645Alexis Hetu context->decrLoopNestingLevel(); 1534894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1535894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1536894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1537894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfor_init_statement 1538894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : expression_statement { 1539894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1540894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1541894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | declaration_statement { 1542894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1543894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1544894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1546894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanconditionopt 1547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : condition { 1548894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1549894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | /* May be null */ { 1551894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = 0; 1552894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1553894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1554894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1555894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfor_rest_statement 1556894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : conditionopt SEMICOLON { 1557894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node1 = $1; 1558894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node2 = 0; 1559894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1560894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | conditionopt SEMICOLON expression { 1561894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node1 = $1; 1562894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$.node2 = $3; 1563894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1564894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1565894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanjump_statement 1567894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : CONTINUE SEMICOLON { 156815ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addBranch(EOpContinue, @1); 1569894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1570894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | BREAK SEMICOLON { 157115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addBranch(EOpBreak, @1); 1572894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1573894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | RETURN SEMICOLON { 157415ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addBranch(EOpReturn, @1); 1575894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | RETURN expression SEMICOLON { 157715ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addBranch(EOpReturn, $2, @1); 1578894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1579894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | DISCARD SEMICOLON { 158015ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu FRAG_ONLY("discard", @1); 158115ae36c448eaebaec09c2e25ac6b5095c0d03606Alexis Hetu $$ = context->addBranch(EOpKill, @1); 1582894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1583894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1584894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1585894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// Grammar Note: No 'goto'. Gotos are not supported. 1586894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1587894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantranslation_unit 1588894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : external_declaration { 1589894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 15900a65584a1529450c476c026f3254d78efc200645Alexis Hetu context->setTreeRoot($$); 1591894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | translation_unit external_declaration { 1593242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->intermediate.growAggregate($1, $2, @$); 15940a65584a1529450c476c026f3254d78efc200645Alexis Hetu context->setTreeRoot($$); 1595894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1596894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1597894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1598894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanexternal_declaration 1599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_definition { 1600894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1601894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1602894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman | declaration { 1603894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman $$ = $1; 1604894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1605894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1606894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1607894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanfunction_definition 1608894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : function_prototype { 1609242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu context->parseFunctionPrototype(@1, $1.function, &$1.intermAggregate); 1610242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu } 1611242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu compound_statement_no_new_scope { 1612242eb5cf7aa683c909eb3add56839ac046312bceAlexis Hetu $$ = context->addFunctionDefinition(*($1.function), $1.intermAggregate, $3, @1); 1613894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 1614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ; 1615894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1616894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman%% 1617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1618894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanint glslang_parse(TParseContext* context) { 1619eced26a12537825c00dcdd8e74e110b3e838a08fVeranika Liaukevich return yyparse(context, context->getScanner()); 1620894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 1621