1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "glslparser_p.h" |
5 | #include "glslengine_p.h" |
6 | #include <iostream> |
7 | #include <cstdio> |
8 | #include <cassert> |
9 | #include <QDebug> |
10 | |
11 | using namespace GLSL; |
12 | |
13 | Parser::Parser(Engine *engine, const char *source, unsigned size, int variant) |
14 | : _engine(engine), _tos(-1), _index(0), yyloc(-1), yytoken(-1), yyrecovering(0), _recovered(false) |
15 | { |
16 | _tokens.reserve(n: 1024); |
17 | |
18 | _stateStack.resize(new_size: 128); |
19 | _locationStack.resize(new_size: 128); |
20 | _symStack.resize(new_size: 128); |
21 | |
22 | _tokens.push_back(x: Token()); // invalid token |
23 | |
24 | std::stack<int> parenStack; |
25 | std::stack<int> bracketStack; |
26 | std::stack<int> braceStack; |
27 | |
28 | Lexer lexer(engine, source, size); |
29 | lexer.setVariant(variant); |
30 | Token tk; |
31 | do { |
32 | lexer.yylex(tk: &tk); |
33 | |
34 | switch (tk.kind) { |
35 | case T_LEFT_PAREN: |
36 | parenStack.push(x: static_cast<int>(_tokens.size())); |
37 | break; |
38 | case T_LEFT_BRACKET: |
39 | bracketStack.push(x: static_cast<int>(_tokens.size())); |
40 | break; |
41 | case T_LEFT_BRACE: |
42 | braceStack.push(x: static_cast<int>(_tokens.size())); |
43 | break; |
44 | |
45 | case T_RIGHT_PAREN: |
46 | if (! parenStack.empty()) { |
47 | _tokens[parenStack.top()].matchingBrace = static_cast<int>(_tokens.size()); |
48 | parenStack.pop(); |
49 | } |
50 | break; |
51 | case T_RIGHT_BRACKET: |
52 | if (! bracketStack.empty()) { |
53 | _tokens[bracketStack.top()].matchingBrace = static_cast<int>(_tokens.size()); |
54 | bracketStack.pop(); |
55 | } |
56 | break; |
57 | case T_RIGHT_BRACE: |
58 | if (! braceStack.empty()) { |
59 | _tokens[braceStack.top()].matchingBrace = static_cast<int>(_tokens.size()); |
60 | braceStack.pop(); |
61 | } |
62 | break; |
63 | default: |
64 | break; |
65 | } |
66 | |
67 | _tokens.push_back(x: tk); |
68 | } while (tk.isNot(k: EOF_SYMBOL)); |
69 | |
70 | _index = 0; |
71 | } |
72 | |
73 | Parser::~Parser() |
74 | { |
75 | } |
76 | |
77 | AST *Parser::parse(int startToken) |
78 | { |
79 | int action = 0; |
80 | yytoken = -1; |
81 | yyloc = -1; |
82 | void *yyval = nullptr; // value of the current token. |
83 | |
84 | _recovered = false; |
85 | _tos = -1; |
86 | _startToken.kind = startToken; |
87 | int recoveryAttempts = 0; |
88 | |
89 | |
90 | do { |
91 | recoveryAttempts = 0; |
92 | |
93 | againAfterRecovery: |
94 | if (unsigned(++_tos) == _stateStack.size()) { |
95 | _stateStack.resize(new_size: _tos * 2); |
96 | _locationStack.resize(new_size: _tos * 2); |
97 | _symStack.resize(new_size: _tos * 2); |
98 | } |
99 | |
100 | _stateStack[_tos] = action; |
101 | |
102 | if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { |
103 | yyloc = consumeToken(); |
104 | yytoken = tokenKind(index: yyloc); |
105 | if (yyrecovering) |
106 | --yyrecovering; |
107 | if (yytoken == T_IDENTIFIER && t_action(state: action, token: T_TYPE_NAME) != 0) { |
108 | const Token &la = tokenAt(index: _index); |
109 | |
110 | if (la.is(k: T_IDENTIFIER)) { |
111 | yytoken = T_TYPE_NAME; |
112 | } else if (la.is(k: T_LEFT_BRACKET) && la.matchingBrace != 0 && |
113 | tokenAt(index: la.matchingBrace + 1).is(k: T_IDENTIFIER)) { |
114 | yytoken = T_TYPE_NAME; |
115 | } |
116 | } |
117 | yyval = _tokens.at(n: yyloc).ptr; |
118 | } |
119 | |
120 | action = t_action(state: action, token: yytoken); |
121 | if (action > 0) { |
122 | if (action == ACCEPT_STATE) { |
123 | --_tos; |
124 | return _symStack[0].translation_unit; |
125 | } |
126 | _symStack[_tos].ptr = yyval; |
127 | _locationStack[_tos] = yyloc; |
128 | yytoken = -1; |
129 | } else if (action < 0) { |
130 | const int ruleno = -action - 1; |
131 | const int N = rhs[ruleno]; |
132 | _tos -= N; |
133 | reduce(ruleno); |
134 | action = nt_action(state: _stateStack[_tos], nt: lhs[ruleno] - TERMINAL_COUNT); |
135 | } else if (action == 0) { |
136 | ++recoveryAttempts; |
137 | if (recoveryAttempts > 10) |
138 | break; |
139 | const int line = _tokens[yyloc].line + 1; |
140 | QString message = QLatin1String("Syntax error" ); |
141 | if (yytoken != -1) { |
142 | const QLatin1String s(spell[yytoken]); |
143 | message = QString::fromLatin1(ba: "Unexpected token `%1'" ).arg(a: s); |
144 | if (yytoken == 0) // do not freeze on unexpected end of file |
145 | return nullptr; |
146 | } |
147 | |
148 | for (; _tos; --_tos) { |
149 | const int state = _stateStack[_tos]; |
150 | |
151 | static int tks1[] = { |
152 | T_RIGHT_BRACE, T_RIGHT_PAREN, T_RIGHT_BRACKET, |
153 | T_SEMICOLON, T_COLON, T_COMMA, |
154 | T_NUMBER, T_TYPE_NAME, T_IDENTIFIER, |
155 | T_LEFT_BRACE, T_LEFT_PAREN, T_LEFT_BRACKET, |
156 | T_WHILE, |
157 | 0 |
158 | }; |
159 | static int tks2[] = { |
160 | T_RIGHT_BRACE, T_RIGHT_PAREN, T_RIGHT_BRACKET, |
161 | T_SEMICOLON, T_COLON, T_COMMA, |
162 | 0 |
163 | }; |
164 | int *tks; |
165 | if (recoveryAttempts < 2) |
166 | tks = tks1; |
167 | else |
168 | tks = tks2; // Avoid running into an endless loop for e.g.: for(int x=0; x y |
169 | |
170 | for (int *tptr = tks; *tptr; ++tptr) { |
171 | const int next = t_action(state, token: *tptr); |
172 | if (next > 0) { |
173 | if (! yyrecovering && ! _recovered) { |
174 | _recovered = true; |
175 | error(line, message: QString::fromLatin1(ba: "Expected `%1'" ).arg(a: QLatin1String(spell[*tptr]))); |
176 | } |
177 | |
178 | yyrecovering = 3; |
179 | if (*tptr == T_IDENTIFIER) |
180 | yyval = (void *) _engine->identifier(s: QLatin1String("$identifier" )); |
181 | else if (*tptr == T_NUMBER || *tptr == T_TYPE_NAME) |
182 | yyval = (void *) _engine->identifier(s: QLatin1String("$0" )); |
183 | else |
184 | yyval = nullptr; |
185 | |
186 | _symStack[_tos].ptr = yyval; |
187 | _locationStack[_tos] = yyloc; |
188 | yytoken = -1; |
189 | |
190 | action = next; |
191 | goto againAfterRecovery; |
192 | } |
193 | } |
194 | } |
195 | |
196 | if (! _recovered) { |
197 | _recovered = true; |
198 | error(line, message); |
199 | } |
200 | } |
201 | |
202 | } while (action); |
203 | |
204 | return nullptr; |
205 | } |
206 | |
207 | #line 657 "./glsl.g" |
208 | |
209 | void Parser::reduce(int ruleno) |
210 | { |
211 | switch(ruleno) { |
212 | |
213 | #line 666 "./glsl.g" |
214 | |
215 | case 0: { |
216 | ast(n: 1) = makeAstNode<IdentifierExpressionAST>(a1: string(n: 1)); |
217 | } break; |
218 | |
219 | #line 673 "./glsl.g" |
220 | |
221 | case 1: { |
222 | ast(n: 1) = makeAstNode<LiteralExpressionAST>(a1: string(n: 1)); |
223 | } break; |
224 | |
225 | #line 680 "./glsl.g" |
226 | |
227 | case 2: { |
228 | ast(n: 1) = makeAstNode<LiteralExpressionAST>(a1: _engine->identifier(s: "true" , n: 4)); |
229 | } break; |
230 | |
231 | #line 687 "./glsl.g" |
232 | |
233 | case 3: { |
234 | ast(n: 1) = makeAstNode<LiteralExpressionAST>(a1: _engine->identifier(s: "false" , n: 5)); |
235 | } break; |
236 | |
237 | #line 694 "./glsl.g" |
238 | |
239 | case 4: { |
240 | // nothing to do. |
241 | } break; |
242 | |
243 | #line 701 "./glsl.g" |
244 | |
245 | case 5: { |
246 | ast(n: 1) = ast(n: 2); |
247 | } break; |
248 | |
249 | #line 708 "./glsl.g" |
250 | |
251 | case 6: { |
252 | // nothing to do. |
253 | } break; |
254 | |
255 | #line 715 "./glsl.g" |
256 | |
257 | case 7: { |
258 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_ArrayAccess, a2: expression(n: 1), a3: expression(n: 3)); |
259 | } break; |
260 | |
261 | #line 722 "./glsl.g" |
262 | |
263 | case 8: { |
264 | // nothing to do. |
265 | } break; |
266 | |
267 | #line 729 "./glsl.g" |
268 | |
269 | case 9: { |
270 | ast(n: 1) = makeAstNode<MemberAccessExpressionAST>(a1: expression(n: 1), a2: string(n: 3)); |
271 | } break; |
272 | |
273 | #line 736 "./glsl.g" |
274 | |
275 | case 10: { |
276 | ast(n: 1) = makeAstNode<UnaryExpressionAST>(a1: AST::Kind_PostIncrement, a2: expression(n: 1)); |
277 | } break; |
278 | |
279 | #line 743 "./glsl.g" |
280 | |
281 | case 11: { |
282 | ast(n: 1) = makeAstNode<UnaryExpressionAST>(a1: AST::Kind_PostDecrement, a2: expression(n: 1)); |
283 | } break; |
284 | |
285 | #line 750 "./glsl.g" |
286 | |
287 | case 12: { |
288 | // nothing to do. |
289 | } break; |
290 | |
291 | #line 757 "./glsl.g" |
292 | |
293 | case 13: { |
294 | // nothing to do. |
295 | } break; |
296 | |
297 | #line 764 "./glsl.g" |
298 | |
299 | case 14: { |
300 | ast(n: 1) = makeAstNode<FunctionCallExpressionAST> |
301 | (a1: sym(n: 1).function.id, a2: sym(n: 1).function.arguments); |
302 | } break; |
303 | |
304 | #line 772 "./glsl.g" |
305 | |
306 | case 15: { |
307 | ast(n: 1) = makeAstNode<FunctionCallExpressionAST> |
308 | (a1: expression(n: 1), a2: sym(n: 3).function.id, a3: sym(n: 3).function.arguments); |
309 | } break; |
310 | |
311 | #line 780 "./glsl.g" |
312 | |
313 | case 16: { |
314 | // nothing to do. |
315 | } break; |
316 | |
317 | #line 787 "./glsl.g" |
318 | |
319 | case 17: { |
320 | // nothing to do. |
321 | } break; |
322 | |
323 | #line 794 "./glsl.g" |
324 | |
325 | case 18: { |
326 | sym(n: 1).function.id = sym(n: 1).function_identifier; |
327 | sym(n: 1).function.arguments = nullptr; |
328 | } break; |
329 | |
330 | #line 802 "./glsl.g" |
331 | |
332 | case 19: { |
333 | sym(n: 1).function.id = sym(n: 1).function_identifier; |
334 | sym(n: 1).function.arguments = nullptr; |
335 | } break; |
336 | |
337 | #line 810 "./glsl.g" |
338 | |
339 | case 20: { |
340 | sym(n: 1).function.id = sym(n: 1).function_identifier; |
341 | sym(n: 1).function.arguments = |
342 | makeAstNode< List<ExpressionAST *> >(a1: expression(n: 2)); |
343 | } break; |
344 | |
345 | #line 819 "./glsl.g" |
346 | |
347 | case 21: { |
348 | sym(n: 1).function.arguments = |
349 | makeAstNode< List<ExpressionAST *> > |
350 | (a1: sym(n: 1).function.arguments, a2: expression(n: 3)); |
351 | } break; |
352 | |
353 | #line 828 "./glsl.g" |
354 | |
355 | case 22: { |
356 | // nothing to do. |
357 | } break; |
358 | |
359 | #line 835 "./glsl.g" |
360 | |
361 | case 23: { |
362 | ast(n: 1) = makeAstNode<FunctionIdentifierAST>(a1: type(n: 1)); |
363 | } break; |
364 | |
365 | #line 842 "./glsl.g" |
366 | |
367 | case 24: { |
368 | ast(n: 1) = makeAstNode<FunctionIdentifierAST>(a1: string(n: 1)); |
369 | } break; |
370 | |
371 | #line 849 "./glsl.g" |
372 | |
373 | case 25: { |
374 | // nothing to do. |
375 | } break; |
376 | |
377 | #line 856 "./glsl.g" |
378 | |
379 | case 26: { |
380 | ast(n: 1) = makeAstNode<UnaryExpressionAST>(a1: AST::Kind_PreIncrement, a2: expression(n: 2)); |
381 | } break; |
382 | |
383 | #line 863 "./glsl.g" |
384 | |
385 | case 27: { |
386 | ast(n: 1) = makeAstNode<UnaryExpressionAST>(a1: AST::Kind_PreDecrement, a2: expression(n: 2)); |
387 | } break; |
388 | |
389 | #line 870 "./glsl.g" |
390 | |
391 | case 28: { |
392 | ast(n: 1) = makeAstNode<UnaryExpressionAST>(a1: sym(n: 1).kind, a2: expression(n: 2)); |
393 | } break; |
394 | |
395 | #line 877 "./glsl.g" |
396 | |
397 | case 29: { |
398 | sym(n: 1).kind = AST::Kind_UnaryPlus; |
399 | } break; |
400 | |
401 | #line 884 "./glsl.g" |
402 | |
403 | case 30: { |
404 | sym(n: 1).kind = AST::Kind_UnaryMinus; |
405 | } break; |
406 | |
407 | #line 891 "./glsl.g" |
408 | |
409 | case 31: { |
410 | sym(n: 1).kind = AST::Kind_LogicalNot; |
411 | } break; |
412 | |
413 | #line 898 "./glsl.g" |
414 | |
415 | case 32: { |
416 | sym(n: 1).kind = AST::Kind_BitwiseNot; |
417 | } break; |
418 | |
419 | #line 905 "./glsl.g" |
420 | |
421 | case 33: { |
422 | // nothing to do. |
423 | } break; |
424 | |
425 | #line 912 "./glsl.g" |
426 | |
427 | case 34: { |
428 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_Multiply, a2: expression(n: 1), a3: expression(n: 3)); |
429 | } break; |
430 | |
431 | #line 919 "./glsl.g" |
432 | |
433 | case 35: { |
434 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_Divide, a2: expression(n: 1), a3: expression(n: 3)); |
435 | } break; |
436 | |
437 | #line 926 "./glsl.g" |
438 | |
439 | case 36: { |
440 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_Modulus, a2: expression(n: 1), a3: expression(n: 3)); |
441 | } break; |
442 | |
443 | #line 933 "./glsl.g" |
444 | |
445 | case 37: { |
446 | // nothing to do. |
447 | } break; |
448 | |
449 | #line 940 "./glsl.g" |
450 | |
451 | case 38: { |
452 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_Plus, a2: expression(n: 1), a3: expression(n: 3)); |
453 | } break; |
454 | |
455 | #line 947 "./glsl.g" |
456 | |
457 | case 39: { |
458 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_Minus, a2: expression(n: 1), a3: expression(n: 3)); |
459 | } break; |
460 | |
461 | #line 954 "./glsl.g" |
462 | |
463 | case 40: { |
464 | // nothing to do. |
465 | } break; |
466 | |
467 | #line 961 "./glsl.g" |
468 | |
469 | case 41: { |
470 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_ShiftLeft, a2: expression(n: 1), a3: expression(n: 3)); |
471 | } break; |
472 | |
473 | #line 968 "./glsl.g" |
474 | |
475 | case 42: { |
476 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_ShiftRight, a2: expression(n: 1), a3: expression(n: 3)); |
477 | } break; |
478 | |
479 | #line 975 "./glsl.g" |
480 | |
481 | case 43: { |
482 | // nothing to do. |
483 | } break; |
484 | |
485 | #line 982 "./glsl.g" |
486 | |
487 | case 44: { |
488 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_LessThan, a2: expression(n: 1), a3: expression(n: 3)); |
489 | } break; |
490 | |
491 | #line 989 "./glsl.g" |
492 | |
493 | case 45: { |
494 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_GreaterThan, a2: expression(n: 1), a3: expression(n: 3)); |
495 | } break; |
496 | |
497 | #line 996 "./glsl.g" |
498 | |
499 | case 46: { |
500 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_LessEqual, a2: expression(n: 1), a3: expression(n: 3)); |
501 | } break; |
502 | |
503 | #line 1003 "./glsl.g" |
504 | |
505 | case 47: { |
506 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_GreaterEqual, a2: expression(n: 1), a3: expression(n: 3)); |
507 | } break; |
508 | |
509 | #line 1010 "./glsl.g" |
510 | |
511 | case 48: { |
512 | // nothing to do. |
513 | } break; |
514 | |
515 | #line 1017 "./glsl.g" |
516 | |
517 | case 49: { |
518 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_Equal, a2: expression(n: 1), a3: expression(n: 3)); |
519 | } break; |
520 | |
521 | #line 1024 "./glsl.g" |
522 | |
523 | case 50: { |
524 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_NotEqual, a2: expression(n: 1), a3: expression(n: 3)); |
525 | } break; |
526 | |
527 | #line 1031 "./glsl.g" |
528 | |
529 | case 51: { |
530 | // nothing to do. |
531 | } break; |
532 | |
533 | #line 1038 "./glsl.g" |
534 | |
535 | case 52: { |
536 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_BitwiseAnd, a2: expression(n: 1), a3: expression(n: 3)); |
537 | } break; |
538 | |
539 | #line 1045 "./glsl.g" |
540 | |
541 | case 53: { |
542 | // nothing to do. |
543 | } break; |
544 | |
545 | #line 1052 "./glsl.g" |
546 | |
547 | case 54: { |
548 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_BitwiseXor, a2: expression(n: 1), a3: expression(n: 3)); |
549 | } break; |
550 | |
551 | #line 1059 "./glsl.g" |
552 | |
553 | case 55: { |
554 | // nothing to do. |
555 | } break; |
556 | |
557 | #line 1066 "./glsl.g" |
558 | |
559 | case 56: { |
560 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_BitwiseOr, a2: expression(n: 1), a3: expression(n: 3)); |
561 | } break; |
562 | |
563 | #line 1073 "./glsl.g" |
564 | |
565 | case 57: { |
566 | // nothing to do. |
567 | } break; |
568 | |
569 | #line 1080 "./glsl.g" |
570 | |
571 | case 58: { |
572 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_LogicalAnd, a2: expression(n: 1), a3: expression(n: 3)); |
573 | } break; |
574 | |
575 | #line 1087 "./glsl.g" |
576 | |
577 | case 59: { |
578 | // nothing to do. |
579 | } break; |
580 | |
581 | #line 1094 "./glsl.g" |
582 | |
583 | case 60: { |
584 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_LogicalXor, a2: expression(n: 1), a3: expression(n: 3)); |
585 | } break; |
586 | |
587 | #line 1101 "./glsl.g" |
588 | |
589 | case 61: { |
590 | // nothing to do. |
591 | } break; |
592 | |
593 | #line 1108 "./glsl.g" |
594 | |
595 | case 62: { |
596 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_LogicalOr, a2: expression(n: 1), a3: expression(n: 3)); |
597 | } break; |
598 | |
599 | #line 1115 "./glsl.g" |
600 | |
601 | case 63: { |
602 | // nothing to do. |
603 | } break; |
604 | |
605 | #line 1122 "./glsl.g" |
606 | |
607 | case 64: { |
608 | ast(n: 1) = makeAstNode<TernaryExpressionAST>(a1: AST::Kind_Conditional, a2: expression(n: 1), a3: expression(n: 3), a4: expression(n: 5)); |
609 | } break; |
610 | |
611 | #line 1129 "./glsl.g" |
612 | |
613 | case 65: { |
614 | // nothing to do. |
615 | } break; |
616 | |
617 | #line 1136 "./glsl.g" |
618 | |
619 | case 66: { |
620 | ast(n: 1) = makeAstNode<AssignmentExpressionAST>(a1: sym(n: 2).kind, a2: expression(n: 1), a3: expression(n: 3)); |
621 | } break; |
622 | |
623 | #line 1143 "./glsl.g" |
624 | |
625 | case 67: { |
626 | sym(n: 1).kind = AST::Kind_Assign; |
627 | } break; |
628 | |
629 | #line 1150 "./glsl.g" |
630 | |
631 | case 68: { |
632 | sym(n: 1).kind = AST::Kind_AssignMultiply; |
633 | } break; |
634 | |
635 | #line 1157 "./glsl.g" |
636 | |
637 | case 69: { |
638 | sym(n: 1).kind = AST::Kind_AssignDivide; |
639 | } break; |
640 | |
641 | #line 1164 "./glsl.g" |
642 | |
643 | case 70: { |
644 | sym(n: 1).kind = AST::Kind_AssignModulus; |
645 | } break; |
646 | |
647 | #line 1171 "./glsl.g" |
648 | |
649 | case 71: { |
650 | sym(n: 1).kind = AST::Kind_AssignPlus; |
651 | } break; |
652 | |
653 | #line 1178 "./glsl.g" |
654 | |
655 | case 72: { |
656 | sym(n: 1).kind = AST::Kind_AssignMinus; |
657 | } break; |
658 | |
659 | #line 1185 "./glsl.g" |
660 | |
661 | case 73: { |
662 | sym(n: 1).kind = AST::Kind_AssignShiftLeft; |
663 | } break; |
664 | |
665 | #line 1192 "./glsl.g" |
666 | |
667 | case 74: { |
668 | sym(n: 1).kind = AST::Kind_AssignShiftRight; |
669 | } break; |
670 | |
671 | #line 1199 "./glsl.g" |
672 | |
673 | case 75: { |
674 | sym(n: 1).kind = AST::Kind_AssignAnd; |
675 | } break; |
676 | |
677 | #line 1206 "./glsl.g" |
678 | |
679 | case 76: { |
680 | sym(n: 1).kind = AST::Kind_AssignXor; |
681 | } break; |
682 | |
683 | #line 1213 "./glsl.g" |
684 | |
685 | case 77: { |
686 | sym(n: 1).kind = AST::Kind_AssignOr; |
687 | } break; |
688 | |
689 | #line 1220 "./glsl.g" |
690 | |
691 | case 78: { |
692 | // nothing to do. |
693 | } break; |
694 | |
695 | #line 1227 "./glsl.g" |
696 | |
697 | case 79: { |
698 | ast(n: 1) = makeAstNode<BinaryExpressionAST>(a1: AST::Kind_Comma, a2: expression(n: 1), a3: expression(n: 3)); |
699 | } break; |
700 | |
701 | #line 1234 "./glsl.g" |
702 | |
703 | case 80: { |
704 | // nothing to do. |
705 | } break; |
706 | |
707 | #line 1241 "./glsl.g" |
708 | |
709 | case 81: { |
710 | // nothing to do. |
711 | } break; |
712 | |
713 | #line 1248 "./glsl.g" |
714 | |
715 | case 82: { |
716 | ast(n: 1) = makeAstNode<InitDeclarationAST>(a1: sym(n: 1).declaration_list); |
717 | } break; |
718 | |
719 | #line 1255 "./glsl.g" |
720 | |
721 | case 83: { |
722 | ast(n: 1) = makeAstNode<PrecisionDeclarationAST>(a1: sym(n: 2).precision, a2: type(n: 3)); |
723 | } break; |
724 | |
725 | #line 1262 "./glsl.g" |
726 | |
727 | case 84: { |
728 | if (sym(n: 1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { |
729 | // TODO: issue an error if the qualifier is not "struct". |
730 | } |
731 | TypeAST *type = makeAstNode<StructTypeAST>(a1: string(n: 2), a2: sym(n: 4).field_list); |
732 | ast(n: 1) = makeAstNode<TypeDeclarationAST>(a1: type); |
733 | } break; |
734 | |
735 | #line 1273 "./glsl.g" |
736 | |
737 | case 85: { |
738 | if ((sym(n: 1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { |
739 | // TODO: issue an error if the qualifier does not contain "struct". |
740 | } |
741 | TypeAST *type = makeAstNode<StructTypeAST>(a1: string(n: 2), a2: sym(n: 4).field_list); |
742 | TypeAST *qualtype = type; |
743 | if (sym(n: 1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { |
744 | qualtype = makeAstNode<QualifiedTypeAST> |
745 | (a1: sym(n: 1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, a2: qualtype, |
746 | a3: sym(n: 1).type_qualifier.layout_list); |
747 | } |
748 | ast(n: 1) = makeAstNode<TypeAndVariableDeclarationAST> |
749 | (a1: makeAstNode<TypeDeclarationAST>(a1: type), |
750 | a2: makeAstNode<VariableDeclarationAST>(a1: qualtype, a2: string(n: 6))); |
751 | } break; |
752 | |
753 | #line 1292 "./glsl.g" |
754 | |
755 | case 86: { |
756 | if ((sym(n: 1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { |
757 | // TODO: issue an error if the qualifier does not contain "struct". |
758 | } |
759 | TypeAST *type = makeAstNode<StructTypeAST>(a1: string(n: 2), a2: sym(n: 4).field_list); |
760 | TypeAST *qualtype = type; |
761 | if (sym(n: 1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { |
762 | qualtype = makeAstNode<QualifiedTypeAST> |
763 | (a1: sym(n: 1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, a2: qualtype, |
764 | a3: sym(n: 1).type_qualifier.layout_list); |
765 | } |
766 | ast(n: 1) = makeAstNode<TypeAndVariableDeclarationAST> |
767 | (a1: makeAstNode<TypeDeclarationAST>(a1: type), |
768 | a2: makeAstNode<VariableDeclarationAST> |
769 | (a1: makeAstNode<ArrayTypeAST>(a1: qualtype), a2: string(n: 6))); |
770 | } break; |
771 | |
772 | #line 1312 "./glsl.g" |
773 | |
774 | case 87: { |
775 | if ((sym(n: 1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { |
776 | // TODO: issue an error if the qualifier does not contain "struct". |
777 | } |
778 | TypeAST *type = makeAstNode<StructTypeAST>(a1: string(n: 2), a2: sym(n: 4).field_list); |
779 | TypeAST *qualtype = type; |
780 | if (sym(n: 1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { |
781 | qualtype = makeAstNode<QualifiedTypeAST> |
782 | (a1: sym(n: 1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, a2: qualtype, |
783 | a3: sym(n: 1).type_qualifier.layout_list); |
784 | } |
785 | ast(n: 1) = makeAstNode<TypeAndVariableDeclarationAST> |
786 | (a1: makeAstNode<TypeDeclarationAST>(a1: type), |
787 | a2: makeAstNode<VariableDeclarationAST> |
788 | (a1: makeAstNode<ArrayTypeAST>(a1: qualtype, a2: expression(n: 8)), a2: string(n: 6))); |
789 | } break; |
790 | |
791 | #line 1332 "./glsl.g" |
792 | |
793 | case 88: { |
794 | TypeAST *type = makeAstNode<QualifiedTypeAST> |
795 | (a1: sym(n: 1).type_qualifier.qualifier, a2: (TypeAST *)nullptr, |
796 | a3: sym(n: 1).type_qualifier.layout_list); |
797 | ast(n: 1) = makeAstNode<TypeDeclarationAST>(a1: type); |
798 | } break; |
799 | |
800 | #line 1342 "./glsl.g" |
801 | |
802 | case 89: { |
803 | function(n: 1)->finishParams(); |
804 | } break; |
805 | |
806 | #line 1349 "./glsl.g" |
807 | |
808 | case 90: { |
809 | // nothing to do. |
810 | } break; |
811 | |
812 | #line 1356 "./glsl.g" |
813 | |
814 | case 91: { |
815 | // nothing to do. |
816 | } break; |
817 | |
818 | #line 1363 "./glsl.g" |
819 | |
820 | case 92: { |
821 | function(n: 1)->params = makeAstNode< List<ParameterDeclarationAST *> > |
822 | (a1: sym(n: 2).param_declaration); |
823 | } break; |
824 | |
825 | #line 1371 "./glsl.g" |
826 | |
827 | case 93: { |
828 | function(n: 1)->params = makeAstNode< List<ParameterDeclarationAST *> > |
829 | (a1: function(n: 1)->params, a2: sym(n: 3).param_declaration); |
830 | } break; |
831 | |
832 | #line 1379 "./glsl.g" |
833 | |
834 | case 94: { |
835 | function(n: 1) = makeAstNode<FunctionDeclarationAST>(a1: type(n: 1), a2: string(n: 2)); |
836 | } break; |
837 | |
838 | #line 1386 "./glsl.g" |
839 | |
840 | case 95: { |
841 | sym(n: 1).param_declarator.type = type(n: 1); |
842 | sym(n: 1).param_declarator.name = string(n: 2); |
843 | } break; |
844 | |
845 | #line 1394 "./glsl.g" |
846 | |
847 | case 96: { |
848 | sym(n: 1).param_declarator.type = makeAstNode<ArrayTypeAST>(a1: type(n: 1), a2: expression(n: 4)); |
849 | sym(n: 1).param_declarator.name = string(n: 2); |
850 | } break; |
851 | |
852 | #line 1402 "./glsl.g" |
853 | |
854 | case 97: { |
855 | ast(n: 1) = makeAstNode<ParameterDeclarationAST> |
856 | (a1: makeAstNode<QualifiedTypeAST> |
857 | (a1: sym(n: 1).qualifier, a2: sym(n: 3).param_declarator.type, |
858 | a3: (List<LayoutQualifierAST *> *)nullptr), |
859 | a2: ParameterDeclarationAST::Qualifier(sym(n: 2).qualifier), |
860 | a3: sym(n: 3).param_declarator.name); |
861 | } break; |
862 | |
863 | #line 1414 "./glsl.g" |
864 | |
865 | case 98: { |
866 | ast(n: 1) = makeAstNode<ParameterDeclarationAST> |
867 | (a1: sym(n: 2).param_declarator.type, |
868 | a2: ParameterDeclarationAST::Qualifier(sym(n: 1).qualifier), |
869 | a3: sym(n: 2).param_declarator.name); |
870 | } break; |
871 | |
872 | #line 1424 "./glsl.g" |
873 | |
874 | case 99: { |
875 | ast(n: 1) = makeAstNode<ParameterDeclarationAST> |
876 | (a1: makeAstNode<QualifiedTypeAST> |
877 | (a1: sym(n: 1).qualifier, a2: type(n: 3), a3: (List<LayoutQualifierAST *> *)nullptr), |
878 | a2: ParameterDeclarationAST::Qualifier(sym(n: 2).qualifier), |
879 | a3: (const QString *)nullptr); |
880 | } break; |
881 | |
882 | #line 1435 "./glsl.g" |
883 | |
884 | case 100: { |
885 | ast(n: 1) = makeAstNode<ParameterDeclarationAST> |
886 | (a1: type(n: 2), a2: ParameterDeclarationAST::Qualifier(sym(n: 1).qualifier), |
887 | a3: (const QString *)nullptr); |
888 | } break; |
889 | |
890 | #line 1444 "./glsl.g" |
891 | |
892 | case 101: { |
893 | sym(n: 1).qualifier = ParameterDeclarationAST::In; |
894 | } break; |
895 | |
896 | #line 1451 "./glsl.g" |
897 | |
898 | case 102: { |
899 | sym(n: 1).qualifier = ParameterDeclarationAST::In; |
900 | } break; |
901 | |
902 | #line 1458 "./glsl.g" |
903 | |
904 | case 103: { |
905 | sym(n: 1).qualifier = ParameterDeclarationAST::Out; |
906 | } break; |
907 | |
908 | #line 1465 "./glsl.g" |
909 | |
910 | case 104: { |
911 | sym(n: 1).qualifier = ParameterDeclarationAST::InOut; |
912 | } break; |
913 | |
914 | #line 1472 "./glsl.g" |
915 | |
916 | case 105: { |
917 | // nothing to do. |
918 | } break; |
919 | |
920 | #line 1479 "./glsl.g" |
921 | |
922 | case 106: { |
923 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
924 | (a1: sym(n: 1).declaration); |
925 | } break; |
926 | |
927 | #line 1487 "./glsl.g" |
928 | |
929 | case 107: { |
930 | TypeAST *type = VariableDeclarationAST::declarationType(decls: sym(n: 1).declaration_list); |
931 | DeclarationAST *decl = makeAstNode<VariableDeclarationAST>(a1: type, a2: string(n: 3)); |
932 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
933 | (a1: sym(n: 1).declaration_list, a2: decl); |
934 | } break; |
935 | |
936 | #line 1497 "./glsl.g" |
937 | |
938 | case 108: { |
939 | TypeAST *type = VariableDeclarationAST::declarationType(decls: sym(n: 1).declaration_list); |
940 | type = makeAstNode<ArrayTypeAST>(a1: type); |
941 | DeclarationAST *decl = makeAstNode<VariableDeclarationAST>(a1: type, a2: string(n: 3)); |
942 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
943 | (a1: sym(n: 1).declaration_list, a2: decl); |
944 | } break; |
945 | |
946 | #line 1508 "./glsl.g" |
947 | |
948 | case 109: { |
949 | TypeAST *type = VariableDeclarationAST::declarationType(decls: sym(n: 1).declaration_list); |
950 | type = makeAstNode<ArrayTypeAST>(a1: type, a2: expression(n: 5)); |
951 | DeclarationAST *decl = makeAstNode<VariableDeclarationAST>(a1: type, a2: string(n: 3)); |
952 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
953 | (a1: sym(n: 1).declaration_list, a2: decl); |
954 | } break; |
955 | |
956 | #line 1519 "./glsl.g" |
957 | |
958 | case 110: { |
959 | TypeAST *type = VariableDeclarationAST::declarationType(decls: sym(n: 1).declaration_list); |
960 | type = makeAstNode<ArrayTypeAST>(a1: type); |
961 | DeclarationAST *decl = makeAstNode<VariableDeclarationAST> |
962 | (a1: type, a2: string(n: 3), a3: expression(n: 7)); |
963 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
964 | (a1: sym(n: 1).declaration_list, a2: decl); |
965 | } break; |
966 | |
967 | #line 1531 "./glsl.g" |
968 | |
969 | case 111: { |
970 | TypeAST *type = VariableDeclarationAST::declarationType(decls: sym(n: 1).declaration_list); |
971 | type = makeAstNode<ArrayTypeAST>(a1: type, a2: expression(n: 5)); |
972 | DeclarationAST *decl = makeAstNode<VariableDeclarationAST> |
973 | (a1: type, a2: string(n: 3), a3: expression(n: 8)); |
974 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
975 | (a1: sym(n: 1).declaration_list, a2: decl); |
976 | } break; |
977 | |
978 | #line 1543 "./glsl.g" |
979 | |
980 | case 112: { |
981 | TypeAST *type = VariableDeclarationAST::declarationType(decls: sym(n: 1).declaration_list); |
982 | DeclarationAST *decl = makeAstNode<VariableDeclarationAST> |
983 | (a1: type, a2: string(n: 3), a3: expression(n: 5)); |
984 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
985 | (a1: sym(n: 1).declaration_list, a2: decl); |
986 | } break; |
987 | |
988 | #line 1554 "./glsl.g" |
989 | |
990 | case 113: { |
991 | ast(n: 1) = makeAstNode<TypeDeclarationAST>(a1: type(n: 1)); |
992 | } break; |
993 | |
994 | #line 1561 "./glsl.g" |
995 | |
996 | case 114: { |
997 | ast(n: 1) = makeAstNode<VariableDeclarationAST>(a1: type(n: 1), a2: string(n: 2)); |
998 | } break; |
999 | |
1000 | #line 1568 "./glsl.g" |
1001 | |
1002 | case 115: { |
1003 | ast(n: 1) = makeAstNode<VariableDeclarationAST> |
1004 | (a1: makeAstNode<ArrayTypeAST>(a1: type(n: 1)), a2: string(n: 2)); |
1005 | } break; |
1006 | |
1007 | #line 1576 "./glsl.g" |
1008 | |
1009 | case 116: { |
1010 | ast(n: 1) = makeAstNode<VariableDeclarationAST> |
1011 | (a1: makeAstNode<ArrayTypeAST>(a1: type(n: 1), a2: expression(n: 4)), a2: string(n: 2)); |
1012 | } break; |
1013 | |
1014 | #line 1584 "./glsl.g" |
1015 | |
1016 | case 117: { |
1017 | ast(n: 1) = makeAstNode<VariableDeclarationAST> |
1018 | (a1: makeAstNode<ArrayTypeAST>(a1: type(n: 1)), a2: string(n: 2), a3: expression(n: 6)); |
1019 | } break; |
1020 | |
1021 | #line 1592 "./glsl.g" |
1022 | |
1023 | case 118: { |
1024 | ast(n: 1) = makeAstNode<VariableDeclarationAST> |
1025 | (a1: makeAstNode<ArrayTypeAST>(a1: type(n: 1), a2: expression(n: 4)), |
1026 | a2: string(n: 2), a3: expression(n: 7)); |
1027 | } break; |
1028 | |
1029 | #line 1601 "./glsl.g" |
1030 | |
1031 | case 119: { |
1032 | ast(n: 1) = makeAstNode<VariableDeclarationAST> |
1033 | (a1: type(n: 1), a2: string(n: 2), a3: expression(n: 4)); |
1034 | } break; |
1035 | |
1036 | #line 1609 "./glsl.g" |
1037 | |
1038 | case 120: { |
1039 | ast(n: 1) = makeAstNode<InvariantDeclarationAST>(a1: string(n: 2)); |
1040 | } break; |
1041 | |
1042 | #line 1616 "./glsl.g" |
1043 | |
1044 | case 121: { |
1045 | ast(n: 1) = makeAstNode<QualifiedTypeAST>(a1: 0, a2: type(n: 1), a3: (List<LayoutQualifierAST *> *)nullptr); |
1046 | } break; |
1047 | |
1048 | #line 1623 "./glsl.g" |
1049 | |
1050 | case 122: { |
1051 | ast(n: 1) = makeAstNode<QualifiedTypeAST> |
1052 | (a1: sym(n: 1).type_qualifier.qualifier, a2: type(n: 2), |
1053 | a3: sym(n: 1).type_qualifier.layout_list); |
1054 | } break; |
1055 | |
1056 | #line 1632 "./glsl.g" |
1057 | |
1058 | case 123: { |
1059 | sym(n: 1).qualifier = QualifiedTypeAST::Invariant; |
1060 | } break; |
1061 | |
1062 | #line 1639 "./glsl.g" |
1063 | |
1064 | case 124: { |
1065 | sym(n: 1).qualifier = QualifiedTypeAST::Smooth; |
1066 | } break; |
1067 | |
1068 | #line 1646 "./glsl.g" |
1069 | |
1070 | case 125: { |
1071 | sym(n: 1).qualifier = QualifiedTypeAST::Flat; |
1072 | } break; |
1073 | |
1074 | #line 1653 "./glsl.g" |
1075 | |
1076 | case 126: { |
1077 | sym(n: 1).qualifier = QualifiedTypeAST::NoPerspective; |
1078 | } break; |
1079 | |
1080 | #line 1660 "./glsl.g" |
1081 | |
1082 | case 127: { |
1083 | sym(n: 1) = sym(n: 3); |
1084 | } break; |
1085 | |
1086 | #line 1667 "./glsl.g" |
1087 | |
1088 | case 128: { |
1089 | sym(n: 1).layout_list = makeAstNode< List<LayoutQualifierAST *> >(a1: sym(n: 1).layout); |
1090 | } break; |
1091 | |
1092 | #line 1674 "./glsl.g" |
1093 | |
1094 | case 129: { |
1095 | sym(n: 1).layout_list = makeAstNode< List<LayoutQualifierAST *> >(a1: sym(n: 1).layout_list, a2: sym(n: 3).layout); |
1096 | } break; |
1097 | |
1098 | #line 1681 "./glsl.g" |
1099 | |
1100 | case 130: { |
1101 | sym(n: 1).layout = makeAstNode<LayoutQualifierAST>(a1: string(n: 1), a2: (const QString *)nullptr); |
1102 | } break; |
1103 | |
1104 | #line 1688 "./glsl.g" |
1105 | |
1106 | case 131: { |
1107 | sym(n: 1).layout = makeAstNode<LayoutQualifierAST>(a1: string(n: 1), a2: string(n: 3)); |
1108 | } break; |
1109 | |
1110 | #line 1695 "./glsl.g" |
1111 | |
1112 | case 132: { |
1113 | sym(n: 1).qualifier = QualifiedTypeAST::Const; |
1114 | } break; |
1115 | |
1116 | #line 1702 "./glsl.g" |
1117 | |
1118 | case 133: { |
1119 | sym(n: 1).type_qualifier.qualifier = sym(n: 1).qualifier; |
1120 | sym(n: 1).type_qualifier.layout_list = nullptr; |
1121 | } break; |
1122 | |
1123 | #line 1710 "./glsl.g" |
1124 | |
1125 | case 134: { |
1126 | sym(n: 1).type_qualifier.layout_list = sym(n: 1).layout_list; |
1127 | sym(n: 1).type_qualifier.qualifier = 0; |
1128 | } break; |
1129 | |
1130 | #line 1718 "./glsl.g" |
1131 | |
1132 | case 135: { |
1133 | sym(n: 1).type_qualifier.layout_list = sym(n: 1).layout_list; |
1134 | sym(n: 1).type_qualifier.qualifier = sym(n: 2).qualifier; |
1135 | } break; |
1136 | |
1137 | #line 1726 "./glsl.g" |
1138 | |
1139 | case 136: { |
1140 | sym(n: 1).type_qualifier.qualifier = sym(n: 1).qualifier | sym(n: 2).qualifier; |
1141 | sym(n: 1).type_qualifier.layout_list = nullptr; |
1142 | } break; |
1143 | |
1144 | #line 1734 "./glsl.g" |
1145 | |
1146 | case 137: { |
1147 | sym(n: 1).type_qualifier.qualifier = sym(n: 1).qualifier; |
1148 | sym(n: 1).type_qualifier.layout_list = nullptr; |
1149 | } break; |
1150 | |
1151 | #line 1742 "./glsl.g" |
1152 | |
1153 | case 138: { |
1154 | sym(n: 1).type_qualifier.qualifier = sym(n: 1).qualifier | sym(n: 2).qualifier; |
1155 | sym(n: 1).type_qualifier.layout_list = nullptr; |
1156 | } break; |
1157 | |
1158 | #line 1750 "./glsl.g" |
1159 | |
1160 | case 139: { |
1161 | sym(n: 1).type_qualifier.qualifier = sym(n: 1).qualifier | sym(n: 2).qualifier | sym(n: 3).qualifier; |
1162 | sym(n: 1).type_qualifier.layout_list = nullptr; |
1163 | } break; |
1164 | |
1165 | #line 1758 "./glsl.g" |
1166 | |
1167 | case 140: { |
1168 | sym(n: 1).type_qualifier.qualifier = QualifiedTypeAST::Invariant; |
1169 | sym(n: 1).type_qualifier.layout_list = nullptr; |
1170 | } break; |
1171 | |
1172 | #line 1766 "./glsl.g" |
1173 | |
1174 | case 141: { |
1175 | sym(n: 1).qualifier = QualifiedTypeAST::Const; |
1176 | } break; |
1177 | |
1178 | #line 1773 "./glsl.g" |
1179 | |
1180 | case 142: { |
1181 | sym(n: 1).qualifier = QualifiedTypeAST::Attribute; |
1182 | } break; |
1183 | |
1184 | #line 1780 "./glsl.g" |
1185 | |
1186 | case 143: { |
1187 | sym(n: 1).qualifier = QualifiedTypeAST::Varying; |
1188 | } break; |
1189 | |
1190 | #line 1787 "./glsl.g" |
1191 | |
1192 | case 144: { |
1193 | sym(n: 1).qualifier = QualifiedTypeAST::CentroidVarying; |
1194 | } break; |
1195 | |
1196 | #line 1794 "./glsl.g" |
1197 | |
1198 | case 145: { |
1199 | sym(n: 1).qualifier = QualifiedTypeAST::In; |
1200 | } break; |
1201 | |
1202 | #line 1801 "./glsl.g" |
1203 | |
1204 | case 146: { |
1205 | sym(n: 1).qualifier = QualifiedTypeAST::Out; |
1206 | } break; |
1207 | |
1208 | #line 1808 "./glsl.g" |
1209 | |
1210 | case 147: { |
1211 | sym(n: 1).qualifier = QualifiedTypeAST::CentroidIn; |
1212 | } break; |
1213 | |
1214 | #line 1815 "./glsl.g" |
1215 | |
1216 | case 148: { |
1217 | sym(n: 1).qualifier = QualifiedTypeAST::CentroidOut; |
1218 | } break; |
1219 | |
1220 | #line 1822 "./glsl.g" |
1221 | |
1222 | case 149: { |
1223 | sym(n: 1).qualifier = QualifiedTypeAST::PatchIn; |
1224 | } break; |
1225 | |
1226 | #line 1829 "./glsl.g" |
1227 | |
1228 | case 150: { |
1229 | sym(n: 1).qualifier = QualifiedTypeAST::PatchOut; |
1230 | } break; |
1231 | |
1232 | #line 1836 "./glsl.g" |
1233 | |
1234 | case 151: { |
1235 | sym(n: 1).qualifier = QualifiedTypeAST::SampleIn; |
1236 | } break; |
1237 | |
1238 | #line 1843 "./glsl.g" |
1239 | |
1240 | case 152: { |
1241 | sym(n: 1).qualifier = QualifiedTypeAST::SampleOut; |
1242 | } break; |
1243 | |
1244 | #line 1850 "./glsl.g" |
1245 | |
1246 | case 153: { |
1247 | sym(n: 1).qualifier = QualifiedTypeAST::Uniform; |
1248 | } break; |
1249 | |
1250 | #line 1857 "./glsl.g" |
1251 | |
1252 | case 154: { |
1253 | // nothing to do. |
1254 | } break; |
1255 | |
1256 | #line 1864 "./glsl.g" |
1257 | |
1258 | case 155: { |
1259 | if (!type(n: 2)->setPrecision(sym(n: 1).precision)) { |
1260 | // TODO: issue an error about precision not allowed on this type. |
1261 | } |
1262 | ast(n: 1) = type(n: 2); |
1263 | } break; |
1264 | |
1265 | #line 1874 "./glsl.g" |
1266 | |
1267 | case 156: { |
1268 | // nothing to do. |
1269 | } break; |
1270 | |
1271 | #line 1881 "./glsl.g" |
1272 | |
1273 | case 157: { |
1274 | ast(n: 1) = makeAstNode<ArrayTypeAST>(a1: type(n: 1)); |
1275 | } break; |
1276 | |
1277 | #line 1888 "./glsl.g" |
1278 | |
1279 | case 158: { |
1280 | ast(n: 1) = makeAstNode<ArrayTypeAST>(a1: type(n: 1), a2: expression(n: 3)); |
1281 | } break; |
1282 | |
1283 | #line 1895 "./glsl.g" |
1284 | |
1285 | case 159: { |
1286 | ast(n: 1) = makeBasicType(token: T_VOID); |
1287 | } break; |
1288 | |
1289 | #line 1902 "./glsl.g" |
1290 | |
1291 | case 160: { |
1292 | ast(n: 1) = makeBasicType(token: T_FLOAT); |
1293 | } break; |
1294 | |
1295 | #line 1909 "./glsl.g" |
1296 | |
1297 | case 161: { |
1298 | ast(n: 1) = makeBasicType(token: T_DOUBLE); |
1299 | } break; |
1300 | |
1301 | #line 1916 "./glsl.g" |
1302 | |
1303 | case 162: { |
1304 | ast(n: 1) = makeBasicType(token: T_INT); |
1305 | } break; |
1306 | |
1307 | #line 1923 "./glsl.g" |
1308 | |
1309 | case 163: { |
1310 | ast(n: 1) = makeBasicType(token: T_UINT); |
1311 | } break; |
1312 | |
1313 | #line 1930 "./glsl.g" |
1314 | |
1315 | case 164: { |
1316 | ast(n: 1) = makeBasicType(token: T_BOOL); |
1317 | } break; |
1318 | |
1319 | #line 1937 "./glsl.g" |
1320 | |
1321 | case 165: { |
1322 | ast(n: 1) = makeBasicType(token: T_VEC2); |
1323 | } break; |
1324 | |
1325 | #line 1944 "./glsl.g" |
1326 | |
1327 | case 166: { |
1328 | ast(n: 1) = makeBasicType(token: T_VEC3); |
1329 | } break; |
1330 | |
1331 | #line 1951 "./glsl.g" |
1332 | |
1333 | case 167: { |
1334 | ast(n: 1) = makeBasicType(token: T_VEC4); |
1335 | } break; |
1336 | |
1337 | #line 1958 "./glsl.g" |
1338 | |
1339 | case 168: { |
1340 | ast(n: 1) = makeBasicType(token: T_DVEC2); |
1341 | } break; |
1342 | |
1343 | #line 1965 "./glsl.g" |
1344 | |
1345 | case 169: { |
1346 | ast(n: 1) = makeBasicType(token: T_DVEC3); |
1347 | } break; |
1348 | |
1349 | #line 1972 "./glsl.g" |
1350 | |
1351 | case 170: { |
1352 | ast(n: 1) = makeBasicType(token: T_DVEC4); |
1353 | } break; |
1354 | |
1355 | #line 1979 "./glsl.g" |
1356 | |
1357 | case 171: { |
1358 | ast(n: 1) = makeBasicType(token: T_BVEC2); |
1359 | } break; |
1360 | |
1361 | #line 1986 "./glsl.g" |
1362 | |
1363 | case 172: { |
1364 | ast(n: 1) = makeBasicType(token: T_BVEC3); |
1365 | } break; |
1366 | |
1367 | #line 1993 "./glsl.g" |
1368 | |
1369 | case 173: { |
1370 | ast(n: 1) = makeBasicType(token: T_BVEC4); |
1371 | } break; |
1372 | |
1373 | #line 2000 "./glsl.g" |
1374 | |
1375 | case 174: { |
1376 | ast(n: 1) = makeBasicType(token: T_IVEC2); |
1377 | } break; |
1378 | |
1379 | #line 2007 "./glsl.g" |
1380 | |
1381 | case 175: { |
1382 | ast(n: 1) = makeBasicType(token: T_IVEC3); |
1383 | } break; |
1384 | |
1385 | #line 2014 "./glsl.g" |
1386 | |
1387 | case 176: { |
1388 | ast(n: 1) = makeBasicType(token: T_IVEC4); |
1389 | } break; |
1390 | |
1391 | #line 2021 "./glsl.g" |
1392 | |
1393 | case 177: { |
1394 | ast(n: 1) = makeBasicType(token: T_UVEC2); |
1395 | } break; |
1396 | |
1397 | #line 2028 "./glsl.g" |
1398 | |
1399 | case 178: { |
1400 | ast(n: 1) = makeBasicType(token: T_UVEC3); |
1401 | } break; |
1402 | |
1403 | #line 2035 "./glsl.g" |
1404 | |
1405 | case 179: { |
1406 | ast(n: 1) = makeBasicType(token: T_UVEC4); |
1407 | } break; |
1408 | |
1409 | #line 2042 "./glsl.g" |
1410 | |
1411 | case 180: { |
1412 | ast(n: 1) = makeBasicType(token: T_MAT2); |
1413 | } break; |
1414 | |
1415 | #line 2049 "./glsl.g" |
1416 | |
1417 | case 181: { |
1418 | ast(n: 1) = makeBasicType(token: T_MAT3); |
1419 | } break; |
1420 | |
1421 | #line 2056 "./glsl.g" |
1422 | |
1423 | case 182: { |
1424 | ast(n: 1) = makeBasicType(token: T_MAT4); |
1425 | } break; |
1426 | |
1427 | #line 2063 "./glsl.g" |
1428 | |
1429 | case 183: { |
1430 | ast(n: 1) = makeBasicType(token: T_MAT2); |
1431 | } break; |
1432 | |
1433 | #line 2070 "./glsl.g" |
1434 | |
1435 | case 184: { |
1436 | ast(n: 1) = makeBasicType(token: T_MAT2X3); |
1437 | } break; |
1438 | |
1439 | #line 2077 "./glsl.g" |
1440 | |
1441 | case 185: { |
1442 | ast(n: 1) = makeBasicType(token: T_MAT2X4); |
1443 | } break; |
1444 | |
1445 | #line 2084 "./glsl.g" |
1446 | |
1447 | case 186: { |
1448 | ast(n: 1) = makeBasicType(token: T_MAT3X2); |
1449 | } break; |
1450 | |
1451 | #line 2091 "./glsl.g" |
1452 | |
1453 | case 187: { |
1454 | ast(n: 1) = makeBasicType(token: T_MAT3); |
1455 | } break; |
1456 | |
1457 | #line 2098 "./glsl.g" |
1458 | |
1459 | case 188: { |
1460 | ast(n: 1) = makeBasicType(token: T_MAT3X4); |
1461 | } break; |
1462 | |
1463 | #line 2105 "./glsl.g" |
1464 | |
1465 | case 189: { |
1466 | ast(n: 1) = makeBasicType(token: T_MAT4X2); |
1467 | } break; |
1468 | |
1469 | #line 2112 "./glsl.g" |
1470 | |
1471 | case 190: { |
1472 | ast(n: 1) = makeBasicType(token: T_MAT4X3); |
1473 | } break; |
1474 | |
1475 | #line 2119 "./glsl.g" |
1476 | |
1477 | case 191: { |
1478 | ast(n: 1) = makeBasicType(token: T_MAT4); |
1479 | } break; |
1480 | |
1481 | #line 2126 "./glsl.g" |
1482 | |
1483 | case 192: { |
1484 | ast(n: 1) = makeBasicType(token: T_DMAT2); |
1485 | } break; |
1486 | |
1487 | #line 2133 "./glsl.g" |
1488 | |
1489 | case 193: { |
1490 | ast(n: 1) = makeBasicType(token: T_DMAT3); |
1491 | } break; |
1492 | |
1493 | #line 2140 "./glsl.g" |
1494 | |
1495 | case 194: { |
1496 | ast(n: 1) = makeBasicType(token: T_DMAT4); |
1497 | } break; |
1498 | |
1499 | #line 2147 "./glsl.g" |
1500 | |
1501 | case 195: { |
1502 | ast(n: 1) = makeBasicType(token: T_DMAT2); |
1503 | } break; |
1504 | |
1505 | #line 2154 "./glsl.g" |
1506 | |
1507 | case 196: { |
1508 | ast(n: 1) = makeBasicType(token: T_DMAT2X3); |
1509 | } break; |
1510 | |
1511 | #line 2161 "./glsl.g" |
1512 | |
1513 | case 197: { |
1514 | ast(n: 1) = makeBasicType(token: T_DMAT2X4); |
1515 | } break; |
1516 | |
1517 | #line 2168 "./glsl.g" |
1518 | |
1519 | case 198: { |
1520 | ast(n: 1) = makeBasicType(token: T_DMAT3X2); |
1521 | } break; |
1522 | |
1523 | #line 2175 "./glsl.g" |
1524 | |
1525 | case 199: { |
1526 | ast(n: 1) = makeBasicType(token: T_DMAT3); |
1527 | } break; |
1528 | |
1529 | #line 2182 "./glsl.g" |
1530 | |
1531 | case 200: { |
1532 | ast(n: 1) = makeBasicType(token: T_DMAT3X4); |
1533 | } break; |
1534 | |
1535 | #line 2189 "./glsl.g" |
1536 | |
1537 | case 201: { |
1538 | ast(n: 1) = makeBasicType(token: T_DMAT4X2); |
1539 | } break; |
1540 | |
1541 | #line 2196 "./glsl.g" |
1542 | |
1543 | case 202: { |
1544 | ast(n: 1) = makeBasicType(token: T_DMAT4X3); |
1545 | } break; |
1546 | |
1547 | #line 2203 "./glsl.g" |
1548 | |
1549 | case 203: { |
1550 | ast(n: 1) = makeBasicType(token: T_DMAT4); |
1551 | } break; |
1552 | |
1553 | #line 2210 "./glsl.g" |
1554 | |
1555 | case 204: { |
1556 | ast(n: 1) = makeBasicType(token: T_SAMPLER1D); |
1557 | } break; |
1558 | |
1559 | #line 2217 "./glsl.g" |
1560 | |
1561 | case 205: { |
1562 | ast(n: 1) = makeBasicType(token: T_SAMPLER2D); |
1563 | } break; |
1564 | |
1565 | #line 2224 "./glsl.g" |
1566 | |
1567 | case 206: { |
1568 | ast(n: 1) = makeBasicType(token: T_SAMPLER3D); |
1569 | } break; |
1570 | |
1571 | #line 2231 "./glsl.g" |
1572 | |
1573 | case 207: { |
1574 | ast(n: 1) = makeBasicType(token: T_SAMPLERCUBE); |
1575 | } break; |
1576 | |
1577 | #line 2238 "./glsl.g" |
1578 | |
1579 | case 208: { |
1580 | ast(n: 1) = makeBasicType(token: T_SAMPLER1DSHADOW); |
1581 | } break; |
1582 | |
1583 | #line 2245 "./glsl.g" |
1584 | |
1585 | case 209: { |
1586 | ast(n: 1) = makeBasicType(token: T_SAMPLER2DSHADOW); |
1587 | } break; |
1588 | |
1589 | #line 2252 "./glsl.g" |
1590 | |
1591 | case 210: { |
1592 | ast(n: 1) = makeBasicType(token: T_SAMPLERCUBESHADOW); |
1593 | } break; |
1594 | |
1595 | #line 2259 "./glsl.g" |
1596 | |
1597 | case 211: { |
1598 | ast(n: 1) = makeBasicType(token: T_SAMPLER1DARRAY); |
1599 | } break; |
1600 | |
1601 | #line 2266 "./glsl.g" |
1602 | |
1603 | case 212: { |
1604 | ast(n: 1) = makeBasicType(token: T_SAMPLER2DARRAY); |
1605 | } break; |
1606 | |
1607 | #line 2273 "./glsl.g" |
1608 | |
1609 | case 213: { |
1610 | ast(n: 1) = makeBasicType(token: T_SAMPLER1DARRAYSHADOW); |
1611 | } break; |
1612 | |
1613 | #line 2280 "./glsl.g" |
1614 | |
1615 | case 214: { |
1616 | ast(n: 1) = makeBasicType(token: T_SAMPLER2DARRAYSHADOW); |
1617 | } break; |
1618 | |
1619 | #line 2287 "./glsl.g" |
1620 | |
1621 | case 215: { |
1622 | ast(n: 1) = makeBasicType(token: T_SAMPLERCUBEARRAY); |
1623 | } break; |
1624 | |
1625 | #line 2294 "./glsl.g" |
1626 | |
1627 | case 216: { |
1628 | ast(n: 1) = makeBasicType(token: T_SAMPLERCUBEARRAYSHADOW); |
1629 | } break; |
1630 | |
1631 | #line 2301 "./glsl.g" |
1632 | |
1633 | case 217: { |
1634 | ast(n: 1) = makeBasicType(token: T_ISAMPLER1D); |
1635 | } break; |
1636 | |
1637 | #line 2308 "./glsl.g" |
1638 | |
1639 | case 218: { |
1640 | ast(n: 1) = makeBasicType(token: T_ISAMPLER2D); |
1641 | } break; |
1642 | |
1643 | #line 2315 "./glsl.g" |
1644 | |
1645 | case 219: { |
1646 | ast(n: 1) = makeBasicType(token: T_ISAMPLER3D); |
1647 | } break; |
1648 | |
1649 | #line 2322 "./glsl.g" |
1650 | |
1651 | case 220: { |
1652 | ast(n: 1) = makeBasicType(token: T_ISAMPLERCUBE); |
1653 | } break; |
1654 | |
1655 | #line 2329 "./glsl.g" |
1656 | |
1657 | case 221: { |
1658 | ast(n: 1) = makeBasicType(token: T_ISAMPLER1DARRAY); |
1659 | } break; |
1660 | |
1661 | #line 2336 "./glsl.g" |
1662 | |
1663 | case 222: { |
1664 | ast(n: 1) = makeBasicType(token: T_ISAMPLER2DARRAY); |
1665 | } break; |
1666 | |
1667 | #line 2343 "./glsl.g" |
1668 | |
1669 | case 223: { |
1670 | ast(n: 1) = makeBasicType(token: T_ISAMPLERCUBEARRAY); |
1671 | } break; |
1672 | |
1673 | #line 2350 "./glsl.g" |
1674 | |
1675 | case 224: { |
1676 | ast(n: 1) = makeBasicType(token: T_USAMPLER1D); |
1677 | } break; |
1678 | |
1679 | #line 2357 "./glsl.g" |
1680 | |
1681 | case 225: { |
1682 | ast(n: 1) = makeBasicType(token: T_USAMPLER2D); |
1683 | } break; |
1684 | |
1685 | #line 2364 "./glsl.g" |
1686 | |
1687 | case 226: { |
1688 | ast(n: 1) = makeBasicType(token: T_USAMPLER3D); |
1689 | } break; |
1690 | |
1691 | #line 2371 "./glsl.g" |
1692 | |
1693 | case 227: { |
1694 | ast(n: 1) = makeBasicType(token: T_USAMPLERCUBE); |
1695 | } break; |
1696 | |
1697 | #line 2378 "./glsl.g" |
1698 | |
1699 | case 228: { |
1700 | ast(n: 1) = makeBasicType(token: T_USAMPLER1DARRAY); |
1701 | } break; |
1702 | |
1703 | #line 2385 "./glsl.g" |
1704 | |
1705 | case 229: { |
1706 | ast(n: 1) = makeBasicType(token: T_USAMPLER2DARRAY); |
1707 | } break; |
1708 | |
1709 | #line 2392 "./glsl.g" |
1710 | |
1711 | case 230: { |
1712 | ast(n: 1) = makeBasicType(token: T_USAMPLERCUBEARRAY); |
1713 | } break; |
1714 | |
1715 | #line 2399 "./glsl.g" |
1716 | |
1717 | case 231: { |
1718 | ast(n: 1) = makeBasicType(token: T_SAMPLER2DRECT); |
1719 | } break; |
1720 | |
1721 | #line 2406 "./glsl.g" |
1722 | |
1723 | case 232: { |
1724 | ast(n: 1) = makeBasicType(token: T_SAMPLER2DRECTSHADOW); |
1725 | } break; |
1726 | |
1727 | #line 2413 "./glsl.g" |
1728 | |
1729 | case 233: { |
1730 | ast(n: 1) = makeBasicType(token: T_ISAMPLER2DRECT); |
1731 | } break; |
1732 | |
1733 | #line 2420 "./glsl.g" |
1734 | |
1735 | case 234: { |
1736 | ast(n: 1) = makeBasicType(token: T_USAMPLER2DRECT); |
1737 | } break; |
1738 | |
1739 | #line 2427 "./glsl.g" |
1740 | |
1741 | case 235: { |
1742 | ast(n: 1) = makeBasicType(token: T_SAMPLERBUFFER); |
1743 | } break; |
1744 | |
1745 | #line 2434 "./glsl.g" |
1746 | |
1747 | case 236: { |
1748 | ast(n: 1) = makeBasicType(token: T_ISAMPLERBUFFER); |
1749 | } break; |
1750 | |
1751 | #line 2441 "./glsl.g" |
1752 | |
1753 | case 237: { |
1754 | ast(n: 1) = makeBasicType(token: T_USAMPLERBUFFER); |
1755 | } break; |
1756 | |
1757 | #line 2448 "./glsl.g" |
1758 | |
1759 | case 238: { |
1760 | ast(n: 1) = makeBasicType(token: T_SAMPLER2DMS); |
1761 | } break; |
1762 | |
1763 | #line 2455 "./glsl.g" |
1764 | |
1765 | case 239: { |
1766 | ast(n: 1) = makeBasicType(token: T_ISAMPLER2DMS); |
1767 | } break; |
1768 | |
1769 | #line 2462 "./glsl.g" |
1770 | |
1771 | case 240: { |
1772 | ast(n: 1) = makeBasicType(token: T_USAMPLER2DMS); |
1773 | } break; |
1774 | |
1775 | #line 2469 "./glsl.g" |
1776 | |
1777 | case 241: { |
1778 | ast(n: 1) = makeBasicType(token: T_SAMPLER2DMSARRAY); |
1779 | } break; |
1780 | |
1781 | #line 2476 "./glsl.g" |
1782 | |
1783 | case 242: { |
1784 | ast(n: 1) = makeBasicType(token: T_ISAMPLER2DMSARRAY); |
1785 | } break; |
1786 | |
1787 | #line 2483 "./glsl.g" |
1788 | |
1789 | case 243: { |
1790 | ast(n: 1) = makeBasicType(token: T_USAMPLER2DMSARRAY); |
1791 | } break; |
1792 | |
1793 | #line 2490 "./glsl.g" |
1794 | |
1795 | case 244: { |
1796 | // nothing to do. |
1797 | } break; |
1798 | |
1799 | #line 2497 "./glsl.g" |
1800 | |
1801 | case 245: { |
1802 | ast(n: 1) = makeAstNode<NamedTypeAST>(a1: string(n: 1)); |
1803 | } break; |
1804 | |
1805 | #line 2504 "./glsl.g" |
1806 | |
1807 | case 246: { |
1808 | sym(n: 1).precision = TypeAST::Highp; |
1809 | } break; |
1810 | |
1811 | #line 2511 "./glsl.g" |
1812 | |
1813 | case 247: { |
1814 | sym(n: 1).precision = TypeAST::Mediump; |
1815 | } break; |
1816 | |
1817 | #line 2518 "./glsl.g" |
1818 | |
1819 | case 248: { |
1820 | sym(n: 1).precision = TypeAST::Lowp; |
1821 | } break; |
1822 | |
1823 | #line 2525 "./glsl.g" |
1824 | |
1825 | case 249: { |
1826 | ast(n: 1) = makeAstNode<StructTypeAST>(a1: string(n: 2), a2: sym(n: 4).field_list); |
1827 | } break; |
1828 | |
1829 | #line 2532 "./glsl.g" |
1830 | |
1831 | case 250: { |
1832 | ast(n: 1) = makeAstNode<StructTypeAST>(a1: sym(n: 3).field_list); |
1833 | } break; |
1834 | |
1835 | #line 2539 "./glsl.g" |
1836 | |
1837 | case 251: { |
1838 | // nothing to do. |
1839 | } break; |
1840 | |
1841 | #line 2546 "./glsl.g" |
1842 | |
1843 | case 252: { |
1844 | sym(n: 1).field_list = appendLists(first: sym(n: 1).field_list, second: sym(n: 2).field_list); |
1845 | } break; |
1846 | |
1847 | #line 2553 "./glsl.g" |
1848 | |
1849 | case 253: { |
1850 | sym(n: 1).field_list = StructTypeAST::fixInnerTypes(innerType: type(n: 1), fields: sym(n: 2).field_list); |
1851 | } break; |
1852 | |
1853 | #line 2560 "./glsl.g" |
1854 | |
1855 | case 254: { |
1856 | sym(n: 1).field_list = StructTypeAST::fixInnerTypes |
1857 | (innerType: makeAstNode<QualifiedTypeAST> |
1858 | (a1: sym(n: 1).type_qualifier.qualifier, a2: type(n: 2), |
1859 | a3: sym(n: 1).type_qualifier.layout_list), fields: sym(n: 3).field_list); |
1860 | } break; |
1861 | |
1862 | #line 2570 "./glsl.g" |
1863 | |
1864 | case 255: { |
1865 | // nothing to do. |
1866 | sym(n: 1).field_list = makeAstNode< List<StructTypeAST::Field *> >(a1: sym(n: 1).field); |
1867 | } break; |
1868 | |
1869 | #line 2578 "./glsl.g" |
1870 | |
1871 | case 256: { |
1872 | sym(n: 1).field_list = makeAstNode< List<StructTypeAST::Field *> >(a1: sym(n: 1).field_list, a2: sym(n: 3).field); |
1873 | } break; |
1874 | |
1875 | #line 2585 "./glsl.g" |
1876 | |
1877 | case 257: { |
1878 | sym(n: 1).field = makeAstNode<StructTypeAST::Field>(a1: string(n: 1)); |
1879 | } break; |
1880 | |
1881 | #line 2592 "./glsl.g" |
1882 | |
1883 | case 258: { |
1884 | sym(n: 1).field = makeAstNode<StructTypeAST::Field> |
1885 | (a1: string(n: 1), a2: makeAstNode<ArrayTypeAST>(a1: (TypeAST *)nullptr)); |
1886 | } break; |
1887 | |
1888 | #line 2600 "./glsl.g" |
1889 | |
1890 | case 259: { |
1891 | sym(n: 1).field = makeAstNode<StructTypeAST::Field> |
1892 | (a1: string(n: 1), a2: makeAstNode<ArrayTypeAST>(a1: (TypeAST *)nullptr, a2: expression(n: 3))); |
1893 | } break; |
1894 | |
1895 | #line 2608 "./glsl.g" |
1896 | |
1897 | case 260: { |
1898 | // nothing to do. |
1899 | } break; |
1900 | |
1901 | #line 2615 "./glsl.g" |
1902 | |
1903 | case 261: { |
1904 | ast(n: 1) = makeAstNode<DeclarationStatementAST>(a1: sym(n: 1).declaration); |
1905 | } break; |
1906 | |
1907 | #line 2622 "./glsl.g" |
1908 | |
1909 | case 262: { |
1910 | // nothing to do. |
1911 | } break; |
1912 | |
1913 | #line 2629 "./glsl.g" |
1914 | |
1915 | case 263: { |
1916 | // nothing to do. |
1917 | } break; |
1918 | |
1919 | #line 2636 "./glsl.g" |
1920 | |
1921 | case 264: { |
1922 | // nothing to do. |
1923 | } break; |
1924 | |
1925 | #line 2643 "./glsl.g" |
1926 | |
1927 | case 265: { |
1928 | // nothing to do. |
1929 | } break; |
1930 | |
1931 | #line 2650 "./glsl.g" |
1932 | |
1933 | case 266: { |
1934 | // nothing to do. |
1935 | } break; |
1936 | |
1937 | #line 2657 "./glsl.g" |
1938 | |
1939 | case 267: { |
1940 | // nothing to do. |
1941 | } break; |
1942 | |
1943 | #line 2664 "./glsl.g" |
1944 | |
1945 | case 268: { |
1946 | // nothing to do. |
1947 | } break; |
1948 | |
1949 | #line 2671 "./glsl.g" |
1950 | |
1951 | case 269: { |
1952 | // nothing to do. |
1953 | } break; |
1954 | |
1955 | #line 2678 "./glsl.g" |
1956 | |
1957 | case 270: { |
1958 | // nothing to do. |
1959 | } break; |
1960 | |
1961 | #line 2685 "./glsl.g" |
1962 | |
1963 | case 271: { |
1964 | CompoundStatementAST *stmt = makeAstNode<CompoundStatementAST>(); |
1965 | stmt->start = tokenAt(index: location(n: 1)).begin(); |
1966 | stmt->end = tokenAt(index: location(n: 2)).end(); |
1967 | ast(n: 1) = stmt; |
1968 | } break; |
1969 | |
1970 | #line 2695 "./glsl.g" |
1971 | |
1972 | case 272: { |
1973 | CompoundStatementAST *stmt = makeAstNode<CompoundStatementAST>(a1: sym(n: 2).statement_list); |
1974 | stmt->start = tokenAt(index: location(n: 1)).begin(); |
1975 | stmt->end = tokenAt(index: location(n: 3)).end(); |
1976 | ast(n: 1) = stmt; |
1977 | } break; |
1978 | |
1979 | #line 2705 "./glsl.g" |
1980 | |
1981 | case 273: { |
1982 | // nothing to do. |
1983 | } break; |
1984 | |
1985 | #line 2712 "./glsl.g" |
1986 | |
1987 | case 274: { |
1988 | // nothing to do. |
1989 | } break; |
1990 | |
1991 | #line 2719 "./glsl.g" |
1992 | |
1993 | case 275: { |
1994 | CompoundStatementAST *stmt = makeAstNode<CompoundStatementAST>(); |
1995 | stmt->start = tokenAt(index: location(n: 1)).begin(); |
1996 | stmt->end = tokenAt(index: location(n: 2)).end(); |
1997 | ast(n: 1) = stmt; |
1998 | } break; |
1999 | |
2000 | #line 2729 "./glsl.g" |
2001 | |
2002 | case 276: { |
2003 | CompoundStatementAST *stmt = makeAstNode<CompoundStatementAST>(a1: sym(n: 2).statement_list); |
2004 | stmt->start = tokenAt(index: location(n: 1)).begin(); |
2005 | stmt->end = tokenAt(index: location(n: 3)).end(); |
2006 | ast(n: 1) = stmt; |
2007 | } break; |
2008 | |
2009 | #line 2739 "./glsl.g" |
2010 | |
2011 | case 277: { |
2012 | sym(n: 1).statement_list = makeAstNode< List<StatementAST *> >(a1: sym(n: 1).statement); |
2013 | } break; |
2014 | |
2015 | #line 2746 "./glsl.g" |
2016 | |
2017 | case 278: { |
2018 | sym(n: 1).statement_list = makeAstNode< List<StatementAST *> >(a1: sym(n: 1).statement_list, a2: sym(n: 2).statement); |
2019 | } break; |
2020 | |
2021 | #line 2753 "./glsl.g" |
2022 | |
2023 | case 279: { |
2024 | ast(n: 1) = makeAstNode<CompoundStatementAST>(); // Empty statement |
2025 | } break; |
2026 | |
2027 | #line 2760 "./glsl.g" |
2028 | |
2029 | case 280: { |
2030 | ast(n: 1) = makeAstNode<ExpressionStatementAST>(a1: expression(n: 1)); |
2031 | } break; |
2032 | |
2033 | #line 2767 "./glsl.g" |
2034 | |
2035 | case 281: { |
2036 | ast(n: 1) = makeAstNode<IfStatementAST>(a1: expression(n: 3), a2: sym(n: 5).ifstmt.thenClause, a3: sym(n: 5).ifstmt.elseClause); |
2037 | } break; |
2038 | |
2039 | #line 2774 "./glsl.g" |
2040 | |
2041 | case 282: { |
2042 | sym(n: 1).ifstmt.thenClause = statement(n: 1); |
2043 | sym(n: 1).ifstmt.elseClause = statement(n: 3); |
2044 | } break; |
2045 | |
2046 | #line 2782 "./glsl.g" |
2047 | |
2048 | case 283: { |
2049 | sym(n: 1).ifstmt.thenClause = statement(n: 1); |
2050 | sym(n: 1).ifstmt.elseClause = nullptr; |
2051 | } break; |
2052 | |
2053 | #line 2790 "./glsl.g" |
2054 | |
2055 | case 284: { |
2056 | // nothing to do. |
2057 | } break; |
2058 | |
2059 | #line 2797 "./glsl.g" |
2060 | |
2061 | case 285: { |
2062 | ast(n: 1) = makeAstNode<DeclarationExpressionAST> |
2063 | (a1: type(n: 1), a2: string(n: 2), a3: expression(n: 4)); |
2064 | } break; |
2065 | |
2066 | #line 2805 "./glsl.g" |
2067 | |
2068 | case 286: { |
2069 | ast(n: 1) = makeAstNode<SwitchStatementAST>(a1: expression(n: 3), a2: statement(n: 6)); |
2070 | } break; |
2071 | |
2072 | #line 2812 "./glsl.g" |
2073 | |
2074 | case 287: { |
2075 | ast(n: 1) = makeAstNode<CompoundStatementAST>(); |
2076 | } break; |
2077 | |
2078 | #line 2819 "./glsl.g" |
2079 | |
2080 | case 288: { |
2081 | ast(n: 1) = makeAstNode<CompoundStatementAST>(a1: sym(n: 1).statement_list); |
2082 | } break; |
2083 | |
2084 | #line 2826 "./glsl.g" |
2085 | |
2086 | case 289: { |
2087 | ast(n: 1) = makeAstNode<CaseLabelStatementAST>(a1: expression(n: 2)); |
2088 | } break; |
2089 | |
2090 | #line 2833 "./glsl.g" |
2091 | |
2092 | case 290: { |
2093 | ast(n: 1) = makeAstNode<CaseLabelStatementAST>(); |
2094 | } break; |
2095 | |
2096 | #line 2840 "./glsl.g" |
2097 | |
2098 | case 291: { |
2099 | ast(n: 1) = makeAstNode<WhileStatementAST>(a1: expression(n: 3), a2: statement(n: 5)); |
2100 | } break; |
2101 | |
2102 | #line 2847 "./glsl.g" |
2103 | |
2104 | case 292: { |
2105 | ast(n: 1) = makeAstNode<DoStatementAST>(a1: statement(n: 2), a2: expression(n: 5)); |
2106 | } break; |
2107 | |
2108 | #line 2854 "./glsl.g" |
2109 | |
2110 | case 293: { |
2111 | ast(n: 1) = makeAstNode<ForStatementAST>(a1: statement(n: 3), a2: sym(n: 4).forstmt.condition, a3: sym(n: 4).forstmt.increment, a4: statement(n: 6)); |
2112 | } break; |
2113 | |
2114 | #line 2861 "./glsl.g" |
2115 | |
2116 | case 294: { |
2117 | // nothing to do. |
2118 | } break; |
2119 | |
2120 | #line 2868 "./glsl.g" |
2121 | |
2122 | case 295: { |
2123 | // nothing to do. |
2124 | } break; |
2125 | |
2126 | #line 2875 "./glsl.g" |
2127 | |
2128 | case 296: { |
2129 | // nothing to do. |
2130 | } break; |
2131 | |
2132 | #line 2882 "./glsl.g" |
2133 | |
2134 | case 297: { |
2135 | // nothing to do. |
2136 | } break; |
2137 | |
2138 | #line 2889 "./glsl.g" |
2139 | |
2140 | case 298: { |
2141 | sym(n: 1).forstmt.condition = expression(n: 1); |
2142 | sym(n: 1).forstmt.increment = nullptr; |
2143 | } break; |
2144 | |
2145 | #line 2897 "./glsl.g" |
2146 | |
2147 | case 299: { |
2148 | sym(n: 1).forstmt.condition = expression(n: 1); |
2149 | sym(n: 1).forstmt.increment = expression(n: 3); |
2150 | } break; |
2151 | |
2152 | #line 2905 "./glsl.g" |
2153 | |
2154 | case 300: { |
2155 | ast(n: 1) = makeAstNode<JumpStatementAST>(a1: AST::Kind_Continue); |
2156 | } break; |
2157 | |
2158 | #line 2912 "./glsl.g" |
2159 | |
2160 | case 301: { |
2161 | ast(n: 1) = makeAstNode<JumpStatementAST>(a1: AST::Kind_Break); |
2162 | } break; |
2163 | |
2164 | #line 2919 "./glsl.g" |
2165 | |
2166 | case 302: { |
2167 | ast(n: 1) = makeAstNode<ReturnStatementAST>(); |
2168 | } break; |
2169 | |
2170 | #line 2926 "./glsl.g" |
2171 | |
2172 | case 303: { |
2173 | ast(n: 1) = makeAstNode<ReturnStatementAST>(a1: expression(n: 2)); |
2174 | } break; |
2175 | |
2176 | #line 2933 "./glsl.g" |
2177 | |
2178 | case 304: { |
2179 | ast(n: 1) = makeAstNode<JumpStatementAST>(a1: AST::Kind_Discard); |
2180 | } break; |
2181 | |
2182 | #line 2940 "./glsl.g" |
2183 | |
2184 | case 305: { |
2185 | ast(n: 1) = makeAstNode<TranslationUnitAST>(a1: sym(n: 1).declaration_list); |
2186 | } break; |
2187 | |
2188 | #line 2947 "./glsl.g" |
2189 | |
2190 | case 306: { |
2191 | if (sym(n: 1).declaration) { |
2192 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
2193 | (a1: sym(n: 1).declaration); |
2194 | } else { |
2195 | sym(n: 1).declaration_list = nullptr; |
2196 | } |
2197 | } break; |
2198 | |
2199 | #line 2959 "./glsl.g" |
2200 | |
2201 | case 307: { |
2202 | if (sym(n: 1).declaration_list && sym(n: 2).declaration) { |
2203 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
2204 | (a1: sym(n: 1).declaration_list, a2: sym(n: 2).declaration); |
2205 | } else if (!sym(n: 1).declaration_list) { |
2206 | if (sym(n: 2).declaration) { |
2207 | sym(n: 1).declaration_list = makeAstNode< List<DeclarationAST *> > |
2208 | (a1: sym(n: 2).declaration); |
2209 | } else { |
2210 | sym(n: 1).declaration_list = nullptr; |
2211 | } |
2212 | } |
2213 | } break; |
2214 | |
2215 | #line 2976 "./glsl.g" |
2216 | |
2217 | case 308: { |
2218 | // nothing to do. |
2219 | } break; |
2220 | |
2221 | #line 2983 "./glsl.g" |
2222 | |
2223 | case 309: { |
2224 | // nothing to do. |
2225 | } break; |
2226 | |
2227 | #line 2990 "./glsl.g" |
2228 | |
2229 | case 310: { |
2230 | ast(n: 1) = nullptr; |
2231 | } break; |
2232 | |
2233 | #line 2997 "./glsl.g" |
2234 | |
2235 | case 311: { |
2236 | function(n: 1)->body = statement(n: 2); |
2237 | } break; |
2238 | |
2239 | #line 3004 "./glsl.g" |
2240 | |
2241 | case 312: { |
2242 | ast(n: 1) = nullptr; |
2243 | } break; |
2244 | |
2245 | #line 3012 "./glsl.g" |
2246 | |
2247 | case 313: { |
2248 | ast(n: 1) = ast(n: 2); |
2249 | } break; |
2250 | |
2251 | #line 3019 "./glsl.g" |
2252 | |
2253 | case 314: { |
2254 | ast(n: 1) = ast(n: 2); |
2255 | } break; |
2256 | |
2257 | #line 3025 "./glsl.g" |
2258 | |
2259 | } // end switch |
2260 | } // end Parser::reduce() |
2261 | |