14 : _engine(
engine), _tos(-1), _index(0), yyloc(-1), yytoken(-1), yyrecovering(0), _recovered(
false)
16 _tokens.reserve(1024);
18 _stateStack.resize(128);
19 _locationStack.resize(128);
20 _symStack.resize(128);
22 _tokens.push_back(
Token());
24 std::stack<int> parenStack;
25 std::stack<int> bracketStack;
26 std::stack<int> braceStack;
36 parenStack.push(
static_cast<int>(_tokens.size()));
39 bracketStack.push(
static_cast<int>(_tokens.size()));
42 braceStack.push(
static_cast<int>(_tokens.size()));
46 if (! parenStack.empty()) {
47 _tokens[parenStack.top()].matchingBrace =
static_cast<int>(_tokens.size());
52 if (! bracketStack.empty()) {
53 _tokens[bracketStack.top()].matchingBrace =
static_cast<int>(_tokens.size());
58 if (! braceStack.empty()) {
59 _tokens[braceStack.top()].matchingBrace =
static_cast<int>(_tokens.size());
67 _tokens.push_back(tk);
82 void *yyval =
nullptr;
86 _startToken.
kind = startToken;
87 int recoveryAttempts = 0;
94 if (
unsigned(++_tos) == _stateStack.size()) {
95 _stateStack.resize(_tos * 2);
96 _locationStack.resize(_tos * 2);
97 _symStack.resize(_tos * 2);
100 _stateStack[_tos] = action;
103 yyloc = consumeToken();
104 yytoken = tokenKind(yyloc);
108 const Token &la = tokenAt(_index);
117 yyval = _tokens.at(yyloc).ptr;
124 return _symStack[0].translation_unit;
126 _symStack[_tos].ptr = yyval;
127 _locationStack[_tos] = yyloc;
129 }
else if (action < 0) {
130 const int ruleno = -action - 1;
131 const int N =
rhs[ruleno];
135 }
else if (action == 0) {
137 if (recoveryAttempts > 10)
139 const int line = _tokens[yyloc].line + 1;
148 for (; _tos; --_tos) {
149 const int state = _stateStack[_tos];
151 static int tks1[] = {
159 static int tks2[] = {
165 if (recoveryAttempts < 2)
170 for (
int *tptr = tks; *tptr; ++tptr) {
173 if (! yyrecovering && ! _recovered) {
186 _symStack[_tos].ptr = yyval;
187 _locationStack[_tos] = yyloc;
191 goto againAfterRecovery;
209void Parser::reduce(
int ruleno)
216 ast(1) = makeAstNode<IdentifierExpressionAST>(
string(1));
222 ast(1) = makeAstNode<LiteralExpressionAST>(
string(1));
228 ast(1) = makeAstNode<LiteralExpressionAST>(_engine->
identifier(
"true", 4));
234 ast(1) = makeAstNode<LiteralExpressionAST>(_engine->
identifier(
"false", 5));
270 ast(1) = makeAstNode<MemberAccessExpressionAST>(expression(1),
string(3));
300 ast(1) = makeAstNode<FunctionCallExpressionAST>
301 (sym(1).function.id, sym(1).function.arguments);
307 ast(1) = makeAstNode<FunctionCallExpressionAST>
308 (expression(1), sym(3).function.id, sym(3).function.arguments);
342 makeAstNode< List<ExpressionAST *> >(expression(2));
349 makeAstNode< List<ExpressionAST *> >
362 ast(1) = makeAstNode<FunctionIdentifierAST>(
type(1));
368 ast(1) = makeAstNode<FunctionIdentifierAST>(
string(1));
392 ast(1) = makeAstNode<UnaryExpressionAST>(sym(1).kind, expression(2));
428 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_Multiply, expression(1), expression(3));
434 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_Divide, expression(1), expression(3));
440 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_Modulus, expression(1), expression(3));
452 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_Plus, expression(1), expression(3));
458 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_Minus, expression(1), expression(3));
470 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_ShiftLeft, expression(1), expression(3));
488 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_LessThan, expression(1), expression(3));
500 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_LessEqual, expression(1), expression(3));
518 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_Equal, expression(1), expression(3));
524 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_NotEqual, expression(1), expression(3));
560 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_BitwiseOr, expression(1), expression(3));
596 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_LogicalOr, expression(1), expression(3));
608 ast(1) = makeAstNode<TernaryExpressionAST>(
AST::Kind_Conditional, expression(1), expression(3), expression(5));
620 ast(1) = makeAstNode<AssignmentExpressionAST>(sym(2).kind, expression(1), expression(3));
698 ast(1) = makeAstNode<BinaryExpressionAST>(
AST::Kind_Comma, expression(1), expression(3));
716 ast(1) = makeAstNode<InitDeclarationAST>(sym(1).declaration_list);
722 ast(1) = makeAstNode<PrecisionDeclarationAST>(sym(2).
precision,
type(3));
731 TypeAST *
type = makeAstNode<StructTypeAST>(
string(2), sym(4).field_list);
732 ast(1) = makeAstNode<TypeDeclarationAST>(
type);
741 TypeAST *
type = makeAstNode<StructTypeAST>(
string(2), sym(4).field_list);
744 qualtype = makeAstNode<QualifiedTypeAST>
748 ast(1) = makeAstNode<TypeAndVariableDeclarationAST>
749 (makeAstNode<TypeDeclarationAST>(
type),
750 makeAstNode<VariableDeclarationAST>(qualtype,
string(6)));
759 TypeAST *
type = makeAstNode<StructTypeAST>(
string(2), sym(4).field_list);
762 qualtype = makeAstNode<QualifiedTypeAST>
766 ast(1) = makeAstNode<TypeAndVariableDeclarationAST>
767 (makeAstNode<TypeDeclarationAST>(
type),
768 makeAstNode<VariableDeclarationAST>
769 (makeAstNode<ArrayTypeAST>(qualtype),
string(6)));
778 TypeAST *
type = makeAstNode<StructTypeAST>(
string(2), sym(4).field_list);
781 qualtype = makeAstNode<QualifiedTypeAST>
785 ast(1) = makeAstNode<TypeAndVariableDeclarationAST>
786 (makeAstNode<TypeDeclarationAST>(
type),
787 makeAstNode<VariableDeclarationAST>
788 (makeAstNode<ArrayTypeAST>(qualtype, expression(8)),
string(6)));
797 ast(1) = makeAstNode<TypeDeclarationAST>(
type);
821 function(1)->
params = makeAstNode< List<ParameterDeclarationAST *> >
828 function(1)->
params = makeAstNode< List<ParameterDeclarationAST *> >
835 function(1) = makeAstNode<FunctionDeclarationAST>(
type(1),
string(2));
855 ast(1) = makeAstNode<ParameterDeclarationAST>
856 (makeAstNode<QualifiedTypeAST>
857 (sym(1).qualifier, sym(3).param_declarator.
type,
860 sym(3).param_declarator.
name);
866 ast(1) = makeAstNode<ParameterDeclarationAST>
867 (sym(2).param_declarator.
type,
869 sym(2).param_declarator.
name);
875 ast(1) = makeAstNode<ParameterDeclarationAST>
876 (makeAstNode<QualifiedTypeAST>
885 ast(1) = makeAstNode<ParameterDeclarationAST>
940 type = makeAstNode<ArrayTypeAST>(
type);
950 type = makeAstNode<ArrayTypeAST>(
type, expression(5));
960 type = makeAstNode<ArrayTypeAST>(
type);
962 (
type,
string(3), expression(7));
971 type = makeAstNode<ArrayTypeAST>(
type, expression(5));
973 (
type,
string(3), expression(8));
983 (
type,
string(3), expression(5));
991 ast(1) = makeAstNode<TypeDeclarationAST>(
type(1));
997 ast(1) = makeAstNode<VariableDeclarationAST>(
type(1),
string(2));
1000#line 1568 "./glsl.g"
1003 ast(1) = makeAstNode<VariableDeclarationAST>
1004 (makeAstNode<ArrayTypeAST>(
type(1)),
string(2));
1007#line 1576 "./glsl.g"
1010 ast(1) = makeAstNode<VariableDeclarationAST>
1011 (makeAstNode<ArrayTypeAST>(
type(1), expression(4)),
string(2));
1014#line 1584 "./glsl.g"
1017 ast(1) = makeAstNode<VariableDeclarationAST>
1018 (makeAstNode<ArrayTypeAST>(
type(1)),
string(2), expression(6));
1021#line 1592 "./glsl.g"
1024 ast(1) = makeAstNode<VariableDeclarationAST>
1025 (makeAstNode<ArrayTypeAST>(
type(1), expression(4)),
1026 string(2), expression(7));
1029#line 1601 "./glsl.g"
1032 ast(1) = makeAstNode<VariableDeclarationAST>
1033 (
type(1),
string(2), expression(4));
1036#line 1609 "./glsl.g"
1039 ast(1) = makeAstNode<InvariantDeclarationAST>(
string(2));
1042#line 1616 "./glsl.g"
1048#line 1623 "./glsl.g"
1051 ast(1) = makeAstNode<QualifiedTypeAST>
1056#line 1632 "./glsl.g"
1062#line 1639 "./glsl.g"
1068#line 1646 "./glsl.g"
1074#line 1653 "./glsl.g"
1080#line 1660 "./glsl.g"
1086#line 1667 "./glsl.g"
1092#line 1674 "./glsl.g"
1098#line 1681 "./glsl.g"
1101 sym(1).
layout = makeAstNode<LayoutQualifierAST>(
string(1), (
const QString *)
nullptr);
1104#line 1688 "./glsl.g"
1107 sym(1).
layout = makeAstNode<LayoutQualifierAST>(
string(1),
string(3));
1110#line 1695 "./glsl.g"
1116#line 1702 "./glsl.g"
1123#line 1710 "./glsl.g"
1130#line 1718 "./glsl.g"
1137#line 1726 "./glsl.g"
1144#line 1734 "./glsl.g"
1151#line 1742 "./glsl.g"
1158#line 1750 "./glsl.g"
1165#line 1758 "./glsl.g"
1172#line 1766 "./glsl.g"
1178#line 1773 "./glsl.g"
1184#line 1780 "./glsl.g"
1190#line 1787 "./glsl.g"
1196#line 1794 "./glsl.g"
1202#line 1801 "./glsl.g"
1208#line 1808 "./glsl.g"
1214#line 1815 "./glsl.g"
1220#line 1822 "./glsl.g"
1226#line 1829 "./glsl.g"
1232#line 1836 "./glsl.g"
1238#line 1843 "./glsl.g"
1244#line 1850 "./glsl.g"
1250#line 1857 "./glsl.g"
1256#line 1864 "./glsl.g"
1265#line 1874 "./glsl.g"
1271#line 1881 "./glsl.g"
1274 ast(1) = makeAstNode<ArrayTypeAST>(
type(1));
1277#line 1888 "./glsl.g"
1280 ast(1) = makeAstNode<ArrayTypeAST>(
type(1), expression(3));
1283#line 1895 "./glsl.g"
1286 ast(1) = makeBasicType(
T_VOID);
1289#line 1902 "./glsl.g"
1292 ast(1) = makeBasicType(
T_FLOAT);
1295#line 1909 "./glsl.g"
1301#line 1916 "./glsl.g"
1304 ast(1) = makeBasicType(
T_INT);
1307#line 1923 "./glsl.g"
1310 ast(1) = makeBasicType(
T_UINT);
1313#line 1930 "./glsl.g"
1316 ast(1) = makeBasicType(
T_BOOL);
1319#line 1937 "./glsl.g"
1322 ast(1) = makeBasicType(
T_VEC2);
1325#line 1944 "./glsl.g"
1328 ast(1) = makeBasicType(
T_VEC3);
1331#line 1951 "./glsl.g"
1334 ast(1) = makeBasicType(
T_VEC4);
1337#line 1958 "./glsl.g"
1340 ast(1) = makeBasicType(
T_DVEC2);
1343#line 1965 "./glsl.g"
1346 ast(1) = makeBasicType(
T_DVEC3);
1349#line 1972 "./glsl.g"
1352 ast(1) = makeBasicType(
T_DVEC4);
1355#line 1979 "./glsl.g"
1358 ast(1) = makeBasicType(
T_BVEC2);
1361#line 1986 "./glsl.g"
1364 ast(1) = makeBasicType(
T_BVEC3);
1367#line 1993 "./glsl.g"
1370 ast(1) = makeBasicType(
T_BVEC4);
1373#line 2000 "./glsl.g"
1376 ast(1) = makeBasicType(
T_IVEC2);
1379#line 2007 "./glsl.g"
1382 ast(1) = makeBasicType(
T_IVEC3);
1385#line 2014 "./glsl.g"
1388 ast(1) = makeBasicType(
T_IVEC4);
1391#line 2021 "./glsl.g"
1394 ast(1) = makeBasicType(
T_UVEC2);
1397#line 2028 "./glsl.g"
1400 ast(1) = makeBasicType(
T_UVEC3);
1403#line 2035 "./glsl.g"
1406 ast(1) = makeBasicType(
T_UVEC4);
1409#line 2042 "./glsl.g"
1412 ast(1) = makeBasicType(
T_MAT2);
1415#line 2049 "./glsl.g"
1418 ast(1) = makeBasicType(
T_MAT3);
1421#line 2056 "./glsl.g"
1424 ast(1) = makeBasicType(
T_MAT4);
1427#line 2063 "./glsl.g"
1430 ast(1) = makeBasicType(
T_MAT2);
1433#line 2070 "./glsl.g"
1439#line 2077 "./glsl.g"
1445#line 2084 "./glsl.g"
1451#line 2091 "./glsl.g"
1454 ast(1) = makeBasicType(
T_MAT3);
1457#line 2098 "./glsl.g"
1463#line 2105 "./glsl.g"
1469#line 2112 "./glsl.g"
1475#line 2119 "./glsl.g"
1478 ast(1) = makeBasicType(
T_MAT4);
1481#line 2126 "./glsl.g"
1484 ast(1) = makeBasicType(
T_DMAT2);
1487#line 2133 "./glsl.g"
1490 ast(1) = makeBasicType(
T_DMAT3);
1493#line 2140 "./glsl.g"
1496 ast(1) = makeBasicType(
T_DMAT4);
1499#line 2147 "./glsl.g"
1502 ast(1) = makeBasicType(
T_DMAT2);
1505#line 2154 "./glsl.g"
1511#line 2161 "./glsl.g"
1517#line 2168 "./glsl.g"
1523#line 2175 "./glsl.g"
1526 ast(1) = makeBasicType(
T_DMAT3);
1529#line 2182 "./glsl.g"
1535#line 2189 "./glsl.g"
1541#line 2196 "./glsl.g"
1547#line 2203 "./glsl.g"
1550 ast(1) = makeBasicType(
T_DMAT4);
1553#line 2210 "./glsl.g"
1559#line 2217 "./glsl.g"
1565#line 2224 "./glsl.g"
1571#line 2231 "./glsl.g"
1577#line 2238 "./glsl.g"
1583#line 2245 "./glsl.g"
1589#line 2252 "./glsl.g"
1595#line 2259 "./glsl.g"
1601#line 2266 "./glsl.g"
1607#line 2273 "./glsl.g"
1613#line 2280 "./glsl.g"
1619#line 2287 "./glsl.g"
1625#line 2294 "./glsl.g"
1631#line 2301 "./glsl.g"
1637#line 2308 "./glsl.g"
1643#line 2315 "./glsl.g"
1649#line 2322 "./glsl.g"
1655#line 2329 "./glsl.g"
1661#line 2336 "./glsl.g"
1667#line 2343 "./glsl.g"
1673#line 2350 "./glsl.g"
1679#line 2357 "./glsl.g"
1685#line 2364 "./glsl.g"
1691#line 2371 "./glsl.g"
1697#line 2378 "./glsl.g"
1703#line 2385 "./glsl.g"
1709#line 2392 "./glsl.g"
1715#line 2399 "./glsl.g"
1721#line 2406 "./glsl.g"
1727#line 2413 "./glsl.g"
1733#line 2420 "./glsl.g"
1739#line 2427 "./glsl.g"
1745#line 2434 "./glsl.g"
1751#line 2441 "./glsl.g"
1757#line 2448 "./glsl.g"
1763#line 2455 "./glsl.g"
1769#line 2462 "./glsl.g"
1775#line 2469 "./glsl.g"
1781#line 2476 "./glsl.g"
1787#line 2483 "./glsl.g"
1793#line 2490 "./glsl.g"
1799#line 2497 "./glsl.g"
1802 ast(1) = makeAstNode<NamedTypeAST>(
string(1));
1805#line 2504 "./glsl.g"
1811#line 2511 "./glsl.g"
1817#line 2518 "./glsl.g"
1823#line 2525 "./glsl.g"
1826 ast(1) = makeAstNode<StructTypeAST>(
string(2), sym(4).field_list);
1829#line 2532 "./glsl.g"
1832 ast(1) = makeAstNode<StructTypeAST>(sym(3).field_list);
1835#line 2539 "./glsl.g"
1841#line 2546 "./glsl.g"
1847#line 2553 "./glsl.g"
1853#line 2560 "./glsl.g"
1857 (makeAstNode<QualifiedTypeAST>
1859 sym(1).type_qualifier.
layout_list), sym(3).field_list);
1862#line 2570 "./glsl.g"
1866 sym(1).
field_list = makeAstNode< List<StructTypeAST::Field *> >(sym(1).
field);
1869#line 2578 "./glsl.g"
1875#line 2585 "./glsl.g"
1878 sym(1).
field = makeAstNode<StructTypeAST::Field>(
string(1));
1881#line 2592 "./glsl.g"
1884 sym(1).
field = makeAstNode<StructTypeAST::Field>
1885 (
string(1), makeAstNode<ArrayTypeAST>((
TypeAST *)
nullptr));
1888#line 2600 "./glsl.g"
1891 sym(1).
field = makeAstNode<StructTypeAST::Field>
1892 (
string(1), makeAstNode<ArrayTypeAST>((
TypeAST *)
nullptr, expression(3)));
1895#line 2608 "./glsl.g"
1901#line 2615 "./glsl.g"
1904 ast(1) = makeAstNode<DeclarationStatementAST>(sym(1).declaration);
1907#line 2622 "./glsl.g"
1913#line 2629 "./glsl.g"
1919#line 2636 "./glsl.g"
1925#line 2643 "./glsl.g"
1931#line 2650 "./glsl.g"
1937#line 2657 "./glsl.g"
1943#line 2664 "./glsl.g"
1949#line 2671 "./glsl.g"
1955#line 2678 "./glsl.g"
1961#line 2685 "./glsl.g"
1970#line 2695 "./glsl.g"
1979#line 2705 "./glsl.g"
1985#line 2712 "./glsl.g"
1991#line 2719 "./glsl.g"
2000#line 2729 "./glsl.g"
2009#line 2739 "./glsl.g"
2015#line 2746 "./glsl.g"
2021#line 2753 "./glsl.g"
2024 ast(1) = makeAstNode<CompoundStatementAST>();
2027#line 2760 "./glsl.g"
2030 ast(1) = makeAstNode<ExpressionStatementAST>(expression(1));
2033#line 2767 "./glsl.g"
2036 ast(1) = makeAstNode<IfStatementAST>(expression(3), sym(5).ifstmt.
thenClause, sym(5).ifstmt.
elseClause);
2039#line 2774 "./glsl.g"
2046#line 2782 "./glsl.g"
2053#line 2790 "./glsl.g"
2059#line 2797 "./glsl.g"
2062 ast(1) = makeAstNode<DeclarationExpressionAST>
2063 (
type(1),
string(2), expression(4));
2066#line 2805 "./glsl.g"
2069 ast(1) = makeAstNode<SwitchStatementAST>(expression(3), statement(6));
2072#line 2812 "./glsl.g"
2075 ast(1) = makeAstNode<CompoundStatementAST>();
2078#line 2819 "./glsl.g"
2081 ast(1) = makeAstNode<CompoundStatementAST>(sym(1).statement_list);
2084#line 2826 "./glsl.g"
2087 ast(1) = makeAstNode<CaseLabelStatementAST>(expression(2));
2090#line 2833 "./glsl.g"
2093 ast(1) = makeAstNode<CaseLabelStatementAST>();
2096#line 2840 "./glsl.g"
2099 ast(1) = makeAstNode<WhileStatementAST>(expression(3), statement(5));
2102#line 2847 "./glsl.g"
2105 ast(1) = makeAstNode<DoStatementAST>(statement(2), expression(5));
2108#line 2854 "./glsl.g"
2111 ast(1) = makeAstNode<ForStatementAST>(statement(3), sym(4).forstmt.
condition, sym(4).forstmt.
increment, statement(6));
2114#line 2861 "./glsl.g"
2120#line 2868 "./glsl.g"
2126#line 2875 "./glsl.g"
2132#line 2882 "./glsl.g"
2138#line 2889 "./glsl.g"
2145#line 2897 "./glsl.g"
2152#line 2905 "./glsl.g"
2158#line 2912 "./glsl.g"
2164#line 2919 "./glsl.g"
2167 ast(1) = makeAstNode<ReturnStatementAST>();
2170#line 2926 "./glsl.g"
2173 ast(1) = makeAstNode<ReturnStatementAST>(expression(2));
2176#line 2933 "./glsl.g"
2182#line 2940 "./glsl.g"
2185 ast(1) = makeAstNode<TranslationUnitAST>(sym(1).declaration_list);
2188#line 2947 "./glsl.g"
2191 if (sym(1).declaration) {
2199#line 2959 "./glsl.g"
2202 if (sym(1).declaration_list && sym(2).declaration) {
2215#line 2976 "./glsl.g"
2221#line 2983 "./glsl.g"
2227#line 2990 "./glsl.g"
2233#line 2997 "./glsl.g"
2236 function(1)->
body = statement(2);
2239#line 3004 "./glsl.g"
2245#line 3012 "./glsl.g"
2251#line 3019 "./glsl.g"
2257#line 3025 "./glsl.g"
static const short action_index[]
static int t_action(int state, int token)
static int nt_action(int state, int nt)
@ T_SAMPLERCUBEARRAYSHADOW
static const char *const spell[]
const QString * identifier(const QString &s)
List< ParameterDeclarationAST * > * params
void setVariant(int flags)
TranslationUnitAST * parse()
static List< Field * > * fixInnerTypes(TypeAST *innerType, List< Field * > *fields)
static TypeAST * declarationType(List< DeclarationAST * > *decls)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
List< T > * appendLists(List< T > *first, List< T > *second)
DBusConnection const char DBusError * error
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLsizei const GLchar * message
GLsizei GLsizei GLchar * source
GLenum GLint GLint * precision
GLsizei const GLchar *const * string
[0]
QLatin1StringView QLatin1String
List< ExpressionAST * > * arguments
struct GLSL::Parser::Value::@737 ifstmt
struct GLSL::Parser::Value::@741 param_declarator
FunctionIdentifierAST * function_identifier
StatementAST * thenClause
List< DeclarationAST * > * declaration_list
FunctionIdentifierAST * id
StatementAST * elseClause
ParameterDeclarationAST * param_declaration
ExpressionAST * increment
List< StructTypeAST::Field * > * field_list
struct GLSL::Parser::Value::@739 function
struct GLSL::Parser::Value::@738 forstmt
List< StatementAST * > * statement_list
struct GLSL::Parser::Value::@740 type_qualifier
ExpressionAST * condition
List< LayoutQualifierAST * > * layout_list
DeclarationAST * declaration
LayoutQualifierAST * layout
TypeAST::Precision precision
StructTypeAST::Field * field