glslparser.cpp 44.4 KB
Newer Older
1

Erik Verbruggen's avatar
Erik Verbruggen committed
2
#line 429 "./glsl.g"
3

4
5
6
7
/**************************************************************************
**
** This file is part of Qt Creator
**
con's avatar
con committed
8
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
9
10
11
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
con's avatar
con committed
12
** No Commercial Usage
13
**
con's avatar
con committed
14
15
16
17
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
18
19
20
21
22
23
24
25
26
27
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
con's avatar
con committed
28
29
30
31
32
33
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
34
35
36
**
**************************************************************************/

37
#include "glslparser.h"
38
#include "glslengine.h"
39
#include <iostream>
40
#include <cstdio>
41
#include <cassert>
Roberto Raggi's avatar
Roberto Raggi committed
42
#include <QtCore/QDebug>
43
44
45

using namespace GLSL;

46
Parser::Parser(Engine *engine, const char *source, unsigned size, int variant)
Roberto Raggi's avatar
Roberto Raggi committed
47
    : _engine(engine), _tos(-1), _index(0), yyloc(-1), yytoken(-1), yyrecovering(0), _recovered(false)
48
49
50
51
52
{
    _tokens.reserve(1024);

    _stateStack.resize(128);
    _locationStack.resize(128);
53
    _symStack.resize(128);
54
55
56
57
58
59
60

    _tokens.push_back(Token()); // invalid token

    std::stack<int> parenStack;
    std::stack<int> bracketStack;
    std::stack<int> braceStack;

61
    Lexer lexer(engine, source, size);
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    lexer.setVariant(variant);
    Token tk;
    do {
        lexer.yylex(&tk);

        switch (tk.kind) {
        case T_LEFT_PAREN:
            parenStack.push(_tokens.size());
            break;
        case T_LEFT_BRACKET:
            bracketStack.push(_tokens.size());
            break;
        case T_LEFT_BRACE:
            braceStack.push(_tokens.size());
            break;

        case T_RIGHT_PAREN:
            if (! parenStack.empty()) {
                _tokens[parenStack.top()].matchingBrace = _tokens.size();
                parenStack.pop();
            }
            break;
        case T_RIGHT_BRACKET:
            if (! bracketStack.empty()) {
                _tokens[bracketStack.top()].matchingBrace = _tokens.size();
                bracketStack.pop();
            }
            break;
        case T_RIGHT_BRACE:
            if (! braceStack.empty()) {
                _tokens[braceStack.top()].matchingBrace = _tokens.size();
                braceStack.pop();
            }
            break;
        default:
            break;
        }

        _tokens.push_back(tk);
    } while (tk.isNot(EOF_SYMBOL));

103
    _index = 0;
104
105
106
107
108
109
}

Parser::~Parser()
{
}

110
AST *Parser::parse(int startToken)
111
112
{
    int action = 0;
Roberto Raggi's avatar
Roberto Raggi committed
113
    yytoken = -1;
114
    yyloc = -1;
115
    void *yyval = 0; // value of the current token.
116

Roberto Raggi's avatar
Roberto Raggi committed
117
    _recovered = false;
118
    _tos = -1;
119
    _startToken.kind = startToken;
120
121

    do {
Roberto Raggi's avatar
Roberto Raggi committed
122
123
124
125
126
127
128
129
130
    again:
        if (unsigned(++_tos) == _stateStack.size()) {
            _stateStack.resize(_tos * 2);
            _locationStack.resize(_tos * 2);
            _symStack.resize(_tos * 2);
        }

        _stateStack[_tos] = action;

131
132
133
        if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
            yyloc = consumeToken();
            yytoken = tokenKind(yyloc);
Roberto Raggi's avatar
Roberto Raggi committed
134
135
            if (yyrecovering)
                --yyrecovering;
136
137
138
139
140
141
142
143
144
145
            if (yytoken == T_IDENTIFIER && t_action(action, T_TYPE_NAME) != 0) {
                const Token &la = tokenAt(_index);

                if (la.is(T_IDENTIFIER)) {
                    yytoken = T_TYPE_NAME;
                } else if (la.is(T_LEFT_BRACKET) && la.matchingBrace != 0 &&
                           tokenAt(la.matchingBrace + 1).is(T_IDENTIFIER)) {
                    yytoken = T_TYPE_NAME;
                }
            }
146
            yyval = _tokens.at(yyloc).ptr;
147
148
149
150
151
152
        }

        action = t_action(action, yytoken);
        if (action > 0) {
            if (action == ACCEPT_STATE) {
                --_tos;
153
                return _symStack[0].translation_unit;
154
            }
155
            _symStack[_tos].ptr = yyval;
156
157
158
159
160
161
            _locationStack[_tos] = yyloc;
            yytoken = -1;
        } else if (action < 0) {
            const int ruleno = -action - 1;
            const int N = rhs[ruleno];
            _tos -= N;
162
            reduce(ruleno);
163
            action = nt_action(_stateStack[_tos], lhs[ruleno] - TERMINAL_COUNT);
Roberto Raggi's avatar
Roberto Raggi committed
164
165
166
167
168
169
170
        } else if (action == 0) {
            const int line = _tokens[yyloc].line + 1;
            QString message = QLatin1String("Syntax error");
            if (yytoken != -1) {
                const QLatin1String s(spell[yytoken]);
                message = QString("Unexpected token `%1'").arg(s);
            }
171

Roberto Raggi's avatar
Roberto Raggi committed
172
173
174
175
176
177
178
179
            for (; _tos; --_tos) {
                const int state = _stateStack[_tos];

                static int tks[] = {
                    T_RIGHT_BRACE, T_RIGHT_PAREN, T_RIGHT_BRACKET,
                    T_SEMICOLON, T_COMMA, T_COLON,
                    T_NUMBER, T_TYPE_NAME, T_IDENTIFIER,
                    T_LEFT_BRACE, T_LEFT_PAREN, T_LEFT_BRACKET,
180
                    T_WHILE,
Roberto Raggi's avatar
Roberto Raggi committed
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
                    0
                };

                for (int *tptr = tks; *tptr; ++tptr) {
                    const int next = t_action(state, *tptr);
                    if (next > 0) {
                        if (! yyrecovering && ! _recovered) {
                            _recovered = true;
                            error(line, QString("Expected `%1'").arg(QLatin1String(spell[*tptr])));
                        }

                        yyrecovering = 3;
                        if (*tptr == T_IDENTIFIER)
                            yyval = (void *) _engine->identifier(QLatin1String("$identifier"));
                        else if (*tptr == T_NUMBER || *tptr == T_TYPE_NAME)
                            yyval = (void *) _engine->identifier(QLatin1String("$0"));
                        else
                            yyval = 0;

                        _symStack[_tos].ptr = yyval;
                        _locationStack[_tos] = yyloc;
                        yytoken = -1;

                        action = next;
                        goto again;
                    }
                }
            }
Roberto Raggi's avatar
Roberto Raggi committed
209

Roberto Raggi's avatar
Roberto Raggi committed
210
211
212
213
214
            if (! _recovered) {
                _recovered = true;
                error(line, message);
            }
        }
Roberto Raggi's avatar
Roberto Raggi committed
215

Roberto Raggi's avatar
Roberto Raggi committed
216
    } while (action);
217

218
    return 0;
219
}
220

Erik Verbruggen's avatar
Erik Verbruggen committed
221
#line 650 "./glsl.g"
222
223
224
225
226

void Parser::reduce(int ruleno)
{
switch(ruleno) {

Erik Verbruggen's avatar
Erik Verbruggen committed
227
#line 659 "./glsl.g"
228
229

case 0: {
230
    ast(1) = makeAstNode<IdentifierExpressionAST>(string(1));
231
232
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
233
#line 666 "./glsl.g"
234
235

case 1: {
236
    ast(1) = makeAstNode<LiteralExpressionAST>(string(1));
237
238
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
239
#line 673 "./glsl.g"
240
241

case 2: {
242
    ast(1) = makeAstNode<LiteralExpressionAST>(_engine->identifier("true", 4));
243
244
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
245
#line 680 "./glsl.g"
246
247

case 3: {
248
    ast(1) = makeAstNode<LiteralExpressionAST>(_engine->identifier("false", 5));
249
250
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
251
#line 687 "./glsl.g"
252
253

case 4: {
254
    // nothing to do.
255
256
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
257
#line 694 "./glsl.g"
258
259

case 5: {
260
    ast(1) = ast(2);
261
262
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
263
#line 701 "./glsl.g"
264
265

case 6: {
266
    // nothing to do.
267
268
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
269
#line 708 "./glsl.g"
270
271

case 7: {
272
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_ArrayAccess, expression(1), expression(3));
273
274
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
275
#line 715 "./glsl.g"
276
277

case 8: {
278
    // nothing to do.
279
280
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
281
#line 722 "./glsl.g"
282
283

case 9: {
284
    ast(1) = makeAstNode<MemberAccessExpressionAST>(expression(1), string(3));
285
286
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
287
#line 729 "./glsl.g"
288
289

case 10: {
290
    ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PostIncrement, expression(1));
291
292
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
293
#line 736 "./glsl.g"
294
295

case 11: {
296
    ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PostDecrement, expression(1));
297
298
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
299
#line 743 "./glsl.g"
300
301

case 12: {
302
    // nothing to do.
303
304
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
305
#line 750 "./glsl.g"
306
307

case 13: {
308
    // nothing to do.
309
310
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
311
#line 757 "./glsl.g"
312
313

case 14: {
314
    ast(1) = makeAstNode<FunctionCallExpressionAST>
315
        (sym(1).function.id, sym(1).function.arguments);
316
317
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
318
#line 765 "./glsl.g"
319
320

case 15: {
321
    ast(1) = makeAstNode<FunctionCallExpressionAST>
322
        (expression(1), sym(3).function.id, sym(3).function.arguments);
323
324
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
325
#line 773 "./glsl.g"
326
327

case 16: {
328
    // nothing to do.
329
330
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
331
#line 780 "./glsl.g"
332
333

case 17: {
334
    // nothing to do.
335
336
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
337
#line 787 "./glsl.g"
338
339

case 18: {
340
341
    sym(1).function.id = sym(1).function_identifier;
    sym(1).function.arguments = 0;
342
343
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
344
#line 795 "./glsl.g"
345
346

case 19: {
347
348
    sym(1).function.id = sym(1).function_identifier;
    sym(1).function.arguments = 0;
349
350
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
351
#line 803 "./glsl.g"
352
353

case 20: {
354
355
    sym(1).function.id = sym(1).function_identifier;
    sym(1).function.arguments =
356
        makeAstNode< List<ExpressionAST *> >(expression(2));
357
358
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
359
#line 812 "./glsl.g"
360
361

case 21: {
362
    sym(1).function.arguments =
363
        makeAstNode< List<ExpressionAST *> >
364
            (sym(1).function.arguments, expression(3));
365
366
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
367
#line 821 "./glsl.g"
368
369

case 22: {
370
    // nothing to do.
371
372
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
373
#line 828 "./glsl.g"
374
375

case 23: {
376
    ast(1) = makeAstNode<FunctionIdentifierAST>(type(1));
377
378
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
379
#line 835 "./glsl.g"
380
381

case 24: {
382
    ast(1) = makeAstNode<FunctionIdentifierAST>(string(1));
383
384
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
385
#line 842 "./glsl.g"
386
387

case 25: {
388
    // nothing to do.
389
390
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
391
#line 849 "./glsl.g"
392
393

case 26: {
394
    ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PreIncrement, expression(2));
395
396
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
397
#line 856 "./glsl.g"
398
399

case 27: {
400
    ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PreDecrement, expression(2));
401
402
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
403
#line 863 "./glsl.g"
404
405

case 28: {
406
    ast(1) = makeAstNode<UnaryExpressionAST>(sym(1).kind, expression(2));
407
408
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
409
#line 870 "./glsl.g"
410
411

case 29: {
412
    sym(1).kind = AST::Kind_UnaryPlus;
413
414
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
415
#line 877 "./glsl.g"
416
417

case 30: {
418
    sym(1).kind = AST::Kind_UnaryMinus;
419
420
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
421
#line 884 "./glsl.g"
422
423

case 31: {
424
    sym(1).kind = AST::Kind_LogicalNot;
425
426
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
427
#line 891 "./glsl.g"
428
429

case 32: {
430
    sym(1).kind = AST::Kind_BitwiseNot;
431
432
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
433
#line 898 "./glsl.g"
434
435

case 33: {
436
    // nothing to do.
437
438
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
439
#line 905 "./glsl.g"
440
441

case 34: {
442
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Multiply, expression(1), expression(3));
443
444
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
445
#line 912 "./glsl.g"
446
447

case 35: {
448
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Divide, expression(1), expression(3));
449
450
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
451
#line 919 "./glsl.g"
452
453

case 36: {
454
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Modulus, expression(1), expression(3));
455
456
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
457
#line 926 "./glsl.g"
458
459

case 37: {
460
    // nothing to do.
461
462
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
463
#line 933 "./glsl.g"
464
465

case 38: {
466
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Plus, expression(1), expression(3));
467
468
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
469
#line 940 "./glsl.g"
470
471

case 39: {
472
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Minus, expression(1), expression(3));
473
474
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
475
#line 947 "./glsl.g"
476
477

case 40: {
478
    // nothing to do.
479
480
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
481
#line 954 "./glsl.g"
482
483

case 41: {
484
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_ShiftLeft, expression(1), expression(3));
485
486
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
487
#line 961 "./glsl.g"
488
489

case 42: {
490
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_ShiftRight, expression(1), expression(3));
491
492
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
493
#line 968 "./glsl.g"
494
495

case 43: {
496
    // nothing to do.
497
498
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
499
#line 975 "./glsl.g"
500
501

case 44: {
502
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LessThan, expression(1), expression(3));
503
504
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
505
#line 982 "./glsl.g"
506
507

case 45: {
508
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_GreaterThan, expression(1), expression(3));
509
510
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
511
#line 989 "./glsl.g"
512
513

case 46: {
514
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LessEqual, expression(1), expression(3));
515
516
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
517
#line 996 "./glsl.g"
518
519

case 47: {
520
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_GreaterEqual, expression(1), expression(3));
521
522
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
523
#line 1003 "./glsl.g"
524
525

case 48: {
526
    // nothing to do.
527
528
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
529
#line 1010 "./glsl.g"
530
531

case 49: {
532
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Equal, expression(1), expression(3));
533
534
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
535
#line 1017 "./glsl.g"
536
537

case 50: {
538
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_NotEqual, expression(1), expression(3));
539
540
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
541
#line 1024 "./glsl.g"
542
543

case 51: {
544
    // nothing to do.
545
546
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
547
#line 1031 "./glsl.g"
548
549

case 52: {
550
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_BitwiseAnd, expression(1), expression(3));
551
552
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
553
#line 1038 "./glsl.g"
554
555

case 53: {
556
    // nothing to do.
557
558
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
559
#line 1045 "./glsl.g"
560
561

case 54: {
562
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_BitwiseXor, expression(1), expression(3));
563
564
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
565
#line 1052 "./glsl.g"
566
567

case 55: {
568
    // nothing to do.
569
570
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
571
#line 1059 "./glsl.g"
572
573

case 56: {
574
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_BitwiseOr, expression(1), expression(3));
575
576
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
577
#line 1066 "./glsl.g"
578
579

case 57: {
580
    // nothing to do.
581
582
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
583
#line 1073 "./glsl.g"
584
585

case 58: {
586
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LogicalAnd, expression(1), expression(3));
587
588
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
589
#line 1080 "./glsl.g"
590
591

case 59: {
592
    // nothing to do.
593
594
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
595
#line 1087 "./glsl.g"
596
597

case 60: {
598
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LogicalXor, expression(1), expression(3));
599
600
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
601
#line 1094 "./glsl.g"
602
603

case 61: {
604
    // nothing to do.
605
606
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
607
#line 1101 "./glsl.g"
608
609

case 62: {
610
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LogicalOr, expression(1), expression(3));
611
612
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
613
#line 1108 "./glsl.g"
614
615

case 63: {
616
    // nothing to do.
617
618
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
619
#line 1115 "./glsl.g"
620
621

case 64: {
622
    ast(1) = makeAstNode<TernaryExpressionAST>(AST::Kind_Conditional, expression(1), expression(3), expression(5));
623
624
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
625
#line 1122 "./glsl.g"
626
627

case 65: {
628
    // nothing to do.
629
630
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
631
#line 1129 "./glsl.g"
632
633

case 66: {
634
    ast(1) = makeAstNode<AssignmentExpressionAST>(sym(2).kind, expression(1), expression(3));
635
636
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
637
#line 1136 "./glsl.g"
638
639

case 67: {
640
    sym(1).kind = AST::Kind_Assign;
641
642
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
643
#line 1143 "./glsl.g"
644
645

case 68: {
646
    sym(1).kind = AST::Kind_AssignMultiply;
647
648
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
649
#line 1150 "./glsl.g"
650
651

case 69: {
652
    sym(1).kind = AST::Kind_AssignDivide;
653
654
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
655
#line 1157 "./glsl.g"
656
657

case 70: {
658
    sym(1).kind = AST::Kind_AssignModulus;
659
660
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
661
#line 1164 "./glsl.g"
662
663

case 71: {
664
    sym(1).kind = AST::Kind_AssignPlus;
665
666
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
667
#line 1171 "./glsl.g"
668
669

case 72: {
670
    sym(1).kind = AST::Kind_AssignMinus;
671
672
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
673
#line 1178 "./glsl.g"
674
675

case 73: {
676
    sym(1).kind = AST::Kind_AssignShiftLeft;
677
678
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
679
#line 1185 "./glsl.g"
680
681

case 74: {
682
    sym(1).kind = AST::Kind_AssignShiftRight;
683
684
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
685
#line 1192 "./glsl.g"
686
687

case 75: {
688
    sym(1).kind = AST::Kind_AssignAnd;
689
690
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
691
#line 1199 "./glsl.g"
692
693

case 76: {
694
    sym(1).kind = AST::Kind_AssignXor;
695
696
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
697
#line 1206 "./glsl.g"
698
699

case 77: {
700
    sym(1).kind = AST::Kind_AssignOr;
701
702
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
703
#line 1213 "./glsl.g"
704
705

case 78: {
706
    // nothing to do.
707
708
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
709
#line 1220 "./glsl.g"
710
711

case 79: {
712
    ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Comma, expression(1), expression(3));
713
714
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
715
#line 1227 "./glsl.g"
716
717

case 80: {
718
    // nothing to do.
719
720
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
721
#line 1234 "./glsl.g"
722
723

case 81: {
724
    // nothing to do.
725
726
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
727
#line 1241 "./glsl.g"
728
729

case 82: {
730
    ast(1) = makeAstNode<InitDeclarationAST>(sym(1).declaration_list);
731
732
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
733
#line 1248 "./glsl.g"
734
735

case 83: {
736
    ast(1) = makeAstNode<PrecisionDeclarationAST>(sym(2).precision, type(3));
737
738
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
739
#line 1255 "./glsl.g"
740
741

case 84: {
742
    if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) {
743
744
        // TODO: issue an error if the qualifier is not "struct".
    }
745
746
    TypeAST *type = makeAstNode<StructTypeAST>(string(2), sym(4).field_list);
    ast(1) = makeAstNode<TypeDeclarationAST>(type);
747
748
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
749
#line 1266 "./glsl.g"
750
751

case 85: {
752
    if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) {
753
754
        // TODO: issue an error if the qualifier does not contain "struct".
    }
755
756
757
758
759
    TypeAST *type = makeAstNode<StructTypeAST>(string(2), sym(4).field_list);
    TypeAST *qualtype = type;
    if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) {
        qualtype = makeAstNode<QualifiedTypeAST>
            (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype,
760
761
             sym(1).type_qualifier.layout_list);
    }
762
763
764
    ast(1) = makeAstNode<TypeAndVariableDeclarationAST>
        (makeAstNode<TypeDeclarationAST>(type),
         makeAstNode<VariableDeclarationAST>(qualtype, string(6)));
765
766
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
767
#line 1285 "./glsl.g"
768
769

case 86: {
770
    if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) {
771
772
        // TODO: issue an error if the qualifier does not contain "struct".
    }
773
774
775
776
777
    TypeAST *type = makeAstNode<StructTypeAST>(string(2), sym(4).field_list);
    TypeAST *qualtype = type;
    if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) {
        qualtype = makeAstNode<QualifiedTypeAST>
            (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype,
778
779
             sym(1).type_qualifier.layout_list);
    }
780
781
782
783
    ast(1) = makeAstNode<TypeAndVariableDeclarationAST>
        (makeAstNode<TypeDeclarationAST>(type),
         makeAstNode<VariableDeclarationAST>
            (makeAstNode<ArrayTypeAST>(qualtype), string(6)));
784
785
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
786
#line 1305 "./glsl.g"
787
788

case 87: {
789
    if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) {
790
791
        // TODO: issue an error if the qualifier does not contain "struct".
    }
792
793
794
795
796
    TypeAST *type = makeAstNode<StructTypeAST>(string(2), sym(4).field_list);
    TypeAST *qualtype = type;
    if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) {
        qualtype = makeAstNode<QualifiedTypeAST>
            (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype,
797
798
             sym(1).type_qualifier.layout_list);
    }
799
800
801
802
    ast(1) = makeAstNode<TypeAndVariableDeclarationAST>
        (makeAstNode<TypeDeclarationAST>(type),
         makeAstNode<VariableDeclarationAST>
            (makeAstNode<ArrayTypeAST>(qualtype, expression(8)), string(6)));
803
804
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
805
#line 1325 "./glsl.g"
806
807

case 88: {
808
809
    TypeAST *type = makeAstNode<QualifiedTypeAST>
        (sym(1).type_qualifier.qualifier, (TypeAST *)0,
810
         sym(1).type_qualifier.layout_list);
811
    ast(1) = makeAstNode<TypeDeclarationAST>(type);
812
813
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
814
#line 1335 "./glsl.g"
815
816

case 89: {
817
    function(1)->finishParams();
818
819
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
820
#line 1342 "./glsl.g"
821
822

case 90: {
823
    // nothing to do.
824
825
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
826
#line 1349 "./glsl.g"
827
828

case 91: {
829
    // nothing to do.
830
831
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed
832
#line 1356 "./glsl.g"
833
834

case 92: {
835
    function(1)->params = makeAstNode< List<ParameterDeclarationAST *> >
836
        (sym(2).param_declaration);
837
838
}   break;

Erik Verbruggen's avatar
Erik Verbruggen committed