OSDN Git Service

Simple error recovery.
authorRoberto Raggi <roberto.raggi@nokia.com>
Mon, 29 Nov 2010 08:54:27 +0000 (09:54 +0100)
committerRoberto Raggi <roberto.raggi@nokia.com>
Mon, 29 Nov 2010 08:56:26 +0000 (09:56 +0100)
Well, it's not very advanced but it is probably good enough for now.

src/libs/glsl/glsl.g
src/libs/glsl/glslparser.cpp
src/libs/glsl/glslparser.h
src/libs/glsl/glslparsertable.cpp
src/libs/glsl/glslparsertable_p.h
src/plugins/glsleditor/glsleditor.cpp

index c30903c..b421569 100644 (file)
@@ -313,7 +313,11 @@ private:
     TypeAST *&type(int n) { return _symStack[_tos + n - 1].type; }
     FunctionDeclarationAST *&function(int n) { return _symStack[_tos + n - 1].function_declaration; }
 
-    inline int consumeToken() { return _index++; }
+    inline int consumeToken() {
+        if (_index < int(_tokens.size()))
+            return _index++;
+        return _tokens.size() - 1;
+    }
     inline const Token &tokenAt(int index) const { return _tokens.at(index); }
     inline int tokenKind(int index) const { return _tokens.at(index).kind; }
     void reduce(int ruleno);
@@ -380,6 +384,9 @@ private:
     int _tos;
     int _index;
     int yyloc;
+    int yytoken;
+    int yyrecovering;
+    bool _recovered;
     std::vector<int> _stateStack;
     std::vector<int> _locationStack;
     std::vector<Value> _symStack;
@@ -424,11 +431,12 @@ private:
 #include <iostream>
 #include <cstdio>
 #include <cassert>
+#include <QtCore/QDebug>
 
 using namespace GLSL;
 
 Parser::Parser(Engine *engine, const char *source, unsigned size, int variant)
-    : _engine(engine), _tos(-1), _index(0), yyloc(-1)
+    : _engine(engine), _tos(-1), _index(0), yyloc(-1), yytoken(-1), yyrecovering(0), _recovered(false)
 {
     _tokens.reserve(1024);
 
@@ -494,16 +502,28 @@ Parser::~Parser()
 TranslationUnitAST *Parser::parse()
 {
     int action = 0;
-    int yytoken = -1;
+    yytoken = -1;
     yyloc = -1;
     void *yyval = 0; // value of the current token.
 
+    _recovered = false;
     _tos = -1;
 
     do {
+    again:
+        if (unsigned(++_tos) == _stateStack.size()) {
+            _stateStack.resize(_tos * 2);
+            _locationStack.resize(_tos * 2);
+            _symStack.resize(_tos * 2);
+        }
+
+        _stateStack[_tos] = action;
+
         if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
             yyloc = consumeToken();
             yytoken = tokenKind(yyloc);
+            if (yyrecovering)
+                --yyrecovering;
             if (yytoken == T_IDENTIFIER && t_action(action, T_TYPE_NAME) != 0) {
                 const Token &la = tokenAt(_index);
 
@@ -517,13 +537,6 @@ TranslationUnitAST *Parser::parse()
             yyval = _tokens.at(yyloc).ptr;
         }
 
-        if (unsigned(++_tos) == _stateStack.size()) {
-            _stateStack.resize(_tos * 2);
-            _locationStack.resize(_tos * 2);
-            _symStack.resize(_tos * 2);
-        }
-
-        _stateStack[_tos] = action;
         action = t_action(action, yytoken);
         if (action > 0) {
             if (action == ACCEPT_STATE) {
@@ -539,20 +552,58 @@ TranslationUnitAST *Parser::parse()
             _tos -= N;
             reduce(ruleno);
             action = nt_action(_stateStack[_tos], lhs[ruleno] - TERMINAL_COUNT);
-        }
-    } while (action);
+        } 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);
+            }
 
-    const int line = _tokens[yyloc].line + 1;
-    QString message = QLatin1String("Syntax error");
-    if (yytoken != -1) {
-        const QLatin1String s(yytoken != -1 ? spell[yytoken] : "");
-        message = QString("Unexpected token `%1'").arg(s);
-    }
+            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,
+                    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;
+                    }
+                }
+            }
 
-    error(line, message);
+            if (! _recovered) {
+                _recovered = true;
+                error(line, message);
+            }
+        }
 
-//    fprintf(stderr, "unexpected token `%s' at line %d\n", yytoken != -1 ? spell[yytoken] : "",
-//        _tokens[yyloc].line + 1);
+    } while (action);
 
     return 0;
 }
index 8ddc3d3..8309d94 100644 (file)
@@ -1,5 +1,5 @@
 
-#line 392 "./glsl.g"
+#line 399 "glsl.g"
 
 /**************************************************************************
 **
 #include <iostream>
 #include <cstdio>
 #include <cassert>
+#include <QtCore/QDebug>
 
 using namespace GLSL;
 
 Parser::Parser(Engine *engine, const char *source, unsigned size, int variant)
-    : _engine(engine), _tos(-1), _index(0), yyloc(-1)
+    : _engine(engine), _tos(-1), _index(0), yyloc(-1), yytoken(-1), yyrecovering(0), _recovered(false)
 {
     _tokens.reserve(1024);
 
@@ -105,16 +106,28 @@ Parser::~Parser()
 TranslationUnitAST *Parser::parse()
 {
     int action = 0;
-    int yytoken = -1;
+    yytoken = -1;
     yyloc = -1;
     void *yyval = 0; // value of the current token.
 
+    _recovered = false;
     _tos = -1;
 
     do {
+    again:
+        if (unsigned(++_tos) == _stateStack.size()) {
+            _stateStack.resize(_tos * 2);
+            _locationStack.resize(_tos * 2);
+            _symStack.resize(_tos * 2);
+        }
+
+        _stateStack[_tos] = action;
+
         if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
             yyloc = consumeToken();
             yytoken = tokenKind(yyloc);
+            if (yyrecovering)
+                --yyrecovering;
             if (yytoken == T_IDENTIFIER && t_action(action, T_TYPE_NAME) != 0) {
                 const Token &la = tokenAt(_index);
 
@@ -128,13 +141,6 @@ TranslationUnitAST *Parser::parse()
             yyval = _tokens.at(yyloc).ptr;
         }
 
-        if (unsigned(++_tos) == _stateStack.size()) {
-            _stateStack.resize(_tos * 2);
-            _locationStack.resize(_tos * 2);
-            _symStack.resize(_tos * 2);
-        }
-
-        _stateStack[_tos] = action;
         action = t_action(action, yytoken);
         if (action > 0) {
             if (action == ACCEPT_STATE) {
@@ -150,155 +156,193 @@ TranslationUnitAST *Parser::parse()
             _tos -= N;
             reduce(ruleno);
             action = nt_action(_stateStack[_tos], lhs[ruleno] - TERMINAL_COUNT);
-        }
-    } while (action);
+        } 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);
+            }
 
-    const int line = _tokens[yyloc].line + 1;
-    QString message = QLatin1String("Syntax error");
-    if (yytoken != -1) {
-        const QLatin1String s(yytoken != -1 ? spell[yytoken] : "");
-        message = QString("Unexpected token `%1'").arg(s);
-    }
+            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,
+                    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;
+                    }
+                }
+            }
 
-    error(line, message);
+            if (! _recovered) {
+                _recovered = true;
+                error(line, message);
+            }
+        }
 
-//    fprintf(stderr, "unexpected token `%s' at line %d\n", yytoken != -1 ? spell[yytoken] : "",
-//        _tokens[yyloc].line + 1);
+    } while (action);
 
     return 0;
 }
 
-#line 563 "./glsl.g"
+#line 614 "glsl.g"
 
 void Parser::reduce(int ruleno)
 {
 switch(ruleno) {
 
-#line 572 "./glsl.g"
+#line 623 "glsl.g"
 
 case 0: {
     ast(1) = makeAstNode<IdentifierExpressionAST>(string(1));
 }   break;
 
-#line 579 "./glsl.g"
+#line 630 "glsl.g"
 
 case 1: {
     ast(1) = makeAstNode<LiteralExpressionAST>(string(1));
 }   break;
 
-#line 586 "./glsl.g"
+#line 637 "glsl.g"
 
 case 2: {
     ast(1) = makeAstNode<LiteralExpressionAST>(_engine->identifier("true", 4));
 }   break;
 
-#line 593 "./glsl.g"
+#line 644 "glsl.g"
 
 case 3: {
     ast(1) = makeAstNode<LiteralExpressionAST>(_engine->identifier("false", 5));
 }   break;
 
-#line 600 "./glsl.g"
+#line 651 "glsl.g"
 
 case 4: {
     // nothing to do.
 }   break;
 
-#line 607 "./glsl.g"
+#line 658 "glsl.g"
 
 case 5: {
     ast(1) = ast(2);
 }   break;
 
-#line 614 "./glsl.g"
+#line 665 "glsl.g"
 
 case 6: {
     // nothing to do.
 }   break;
 
-#line 621 "./glsl.g"
+#line 672 "glsl.g"
 
 case 7: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_ArrayAccess, expression(1), expression(3));
 }   break;
 
-#line 628 "./glsl.g"
+#line 679 "glsl.g"
 
 case 8: {
     // nothing to do.
 }   break;
 
-#line 635 "./glsl.g"
+#line 686 "glsl.g"
 
 case 9: {
     ast(1) = makeAstNode<MemberAccessExpressionAST>(expression(1), string(3));
 }   break;
 
-#line 642 "./glsl.g"
+#line 693 "glsl.g"
 
 case 10: {
     ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PostIncrement, expression(1));
 }   break;
 
-#line 649 "./glsl.g"
+#line 700 "glsl.g"
 
 case 11: {
     ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PostDecrement, expression(1));
 }   break;
 
-#line 656 "./glsl.g"
+#line 707 "glsl.g"
 
 case 12: {
     // nothing to do.
 }   break;
 
-#line 663 "./glsl.g"
+#line 714 "glsl.g"
 
 case 13: {
     // nothing to do.
 }   break;
 
-#line 670 "./glsl.g"
+#line 721 "glsl.g"
 
 case 14: {
     ast(1) = makeAstNode<FunctionCallExpressionAST>
         (sym(1).function.id, sym(1).function.arguments);
 }   break;
 
-#line 678 "./glsl.g"
+#line 729 "glsl.g"
 
 case 15: {
     ast(1) = makeAstNode<FunctionCallExpressionAST>
         (expression(1), sym(3).function.id, sym(3).function.arguments);
 }   break;
 
-#line 686 "./glsl.g"
+#line 737 "glsl.g"
 
 case 16: {
     // nothing to do.
 }   break;
 
-#line 693 "./glsl.g"
+#line 744 "glsl.g"
 
 case 17: {
     // nothing to do.
 }   break;
 
-#line 700 "./glsl.g"
+#line 751 "glsl.g"
 
 case 18: {
     sym(1).function.id = sym(1).function_identifier;
     sym(1).function.arguments = 0;
 }   break;
 
-#line 708 "./glsl.g"
+#line 759 "glsl.g"
 
 case 19: {
     sym(1).function.id = sym(1).function_identifier;
     sym(1).function.arguments = 0;
 }   break;
 
-#line 716 "./glsl.g"
+#line 767 "glsl.g"
 
 case 20: {
     sym(1).function.id = sym(1).function_identifier;
@@ -306,7 +350,7 @@ case 20: {
         makeAstNode< List<ExpressionAST *> >(expression(2));
 }   break;
 
-#line 725 "./glsl.g"
+#line 776 "glsl.g"
 
 case 21: {
     sym(1).function.arguments =
@@ -314,379 +358,379 @@ case 21: {
             (sym(1).function.arguments, expression(3));
 }   break;
 
-#line 734 "./glsl.g"
+#line 785 "glsl.g"
 
 case 22: {
     // nothing to do.
 }   break;
 
-#line 741 "./glsl.g"
+#line 792 "glsl.g"
 
 case 23: {
     ast(1) = makeAstNode<FunctionIdentifierAST>(type(1));
 }   break;
 
-#line 748 "./glsl.g"
+#line 799 "glsl.g"
 
 case 24: {
     ast(1) = makeAstNode<FunctionIdentifierAST>(string(1));
 }   break;
 
-#line 755 "./glsl.g"
+#line 806 "glsl.g"
 
 case 25: {
     // nothing to do.
 }   break;
 
-#line 762 "./glsl.g"
+#line 813 "glsl.g"
 
 case 26: {
     ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PreIncrement, expression(2));
 }   break;
 
-#line 769 "./glsl.g"
+#line 820 "glsl.g"
 
 case 27: {
     ast(1) = makeAstNode<UnaryExpressionAST>(AST::Kind_PreDecrement, expression(2));
 }   break;
 
-#line 776 "./glsl.g"
+#line 827 "glsl.g"
 
 case 28: {
     ast(1) = makeAstNode<UnaryExpressionAST>(sym(1).kind, expression(2));
 }   break;
 
-#line 783 "./glsl.g"
+#line 834 "glsl.g"
 
 case 29: {
     sym(1).kind = AST::Kind_UnaryPlus;
 }   break;
 
-#line 790 "./glsl.g"
+#line 841 "glsl.g"
 
 case 30: {
     sym(1).kind = AST::Kind_UnaryMinus;
 }   break;
 
-#line 797 "./glsl.g"
+#line 848 "glsl.g"
 
 case 31: {
     sym(1).kind = AST::Kind_LogicalNot;
 }   break;
 
-#line 804 "./glsl.g"
+#line 855 "glsl.g"
 
 case 32: {
     sym(1).kind = AST::Kind_BitwiseNot;
 }   break;
 
-#line 811 "./glsl.g"
+#line 862 "glsl.g"
 
 case 33: {
     // nothing to do.
 }   break;
 
-#line 818 "./glsl.g"
+#line 869 "glsl.g"
 
 case 34: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Multiply, expression(1), expression(3));
 }   break;
 
-#line 825 "./glsl.g"
+#line 876 "glsl.g"
 
 case 35: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Divide, expression(1), expression(3));
 }   break;
 
-#line 832 "./glsl.g"
+#line 883 "glsl.g"
 
 case 36: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Modulus, expression(1), expression(3));
 }   break;
 
-#line 839 "./glsl.g"
+#line 890 "glsl.g"
 
 case 37: {
     // nothing to do.
 }   break;
 
-#line 846 "./glsl.g"
+#line 897 "glsl.g"
 
 case 38: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Plus, expression(1), expression(3));
 }   break;
 
-#line 853 "./glsl.g"
+#line 904 "glsl.g"
 
 case 39: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Minus, expression(1), expression(3));
 }   break;
 
-#line 860 "./glsl.g"
+#line 911 "glsl.g"
 
 case 40: {
     // nothing to do.
 }   break;
 
-#line 867 "./glsl.g"
+#line 918 "glsl.g"
 
 case 41: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_ShiftLeft, expression(1), expression(3));
 }   break;
 
-#line 874 "./glsl.g"
+#line 925 "glsl.g"
 
 case 42: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_ShiftRight, expression(1), expression(3));
 }   break;
 
-#line 881 "./glsl.g"
+#line 932 "glsl.g"
 
 case 43: {
     // nothing to do.
 }   break;
 
-#line 888 "./glsl.g"
+#line 939 "glsl.g"
 
 case 44: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LessThan, expression(1), expression(3));
 }   break;
 
-#line 895 "./glsl.g"
+#line 946 "glsl.g"
 
 case 45: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_GreaterThan, expression(1), expression(3));
 }   break;
 
-#line 902 "./glsl.g"
+#line 953 "glsl.g"
 
 case 46: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LessEqual, expression(1), expression(3));
 }   break;
 
-#line 909 "./glsl.g"
+#line 960 "glsl.g"
 
 case 47: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_GreaterEqual, expression(1), expression(3));
 }   break;
 
-#line 916 "./glsl.g"
+#line 967 "glsl.g"
 
 case 48: {
     // nothing to do.
 }   break;
 
-#line 923 "./glsl.g"
+#line 974 "glsl.g"
 
 case 49: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Equal, expression(1), expression(3));
 }   break;
 
-#line 930 "./glsl.g"
+#line 981 "glsl.g"
 
 case 50: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_NotEqual, expression(1), expression(3));
 }   break;
 
-#line 937 "./glsl.g"
+#line 988 "glsl.g"
 
 case 51: {
     // nothing to do.
 }   break;
 
-#line 944 "./glsl.g"
+#line 995 "glsl.g"
 
 case 52: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_BitwiseAnd, expression(1), expression(3));
 }   break;
 
-#line 951 "./glsl.g"
+#line 1002 "glsl.g"
 
 case 53: {
     // nothing to do.
 }   break;
 
-#line 958 "./glsl.g"
+#line 1009 "glsl.g"
 
 case 54: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_BitwiseXor, expression(1), expression(3));
 }   break;
 
-#line 965 "./glsl.g"
+#line 1016 "glsl.g"
 
 case 55: {
     // nothing to do.
 }   break;
 
-#line 972 "./glsl.g"
+#line 1023 "glsl.g"
 
 case 56: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_BitwiseOr, expression(1), expression(3));
 }   break;
 
-#line 979 "./glsl.g"
+#line 1030 "glsl.g"
 
 case 57: {
     // nothing to do.
 }   break;
 
-#line 986 "./glsl.g"
+#line 1037 "glsl.g"
 
 case 58: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LogicalAnd, expression(1), expression(3));
 }   break;
 
-#line 993 "./glsl.g"
+#line 1044 "glsl.g"
 
 case 59: {
     // nothing to do.
 }   break;
 
-#line 1000 "./glsl.g"
+#line 1051 "glsl.g"
 
 case 60: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LogicalXor, expression(1), expression(3));
 }   break;
 
-#line 1007 "./glsl.g"
+#line 1058 "glsl.g"
 
 case 61: {
     // nothing to do.
 }   break;
 
-#line 1014 "./glsl.g"
+#line 1065 "glsl.g"
 
 case 62: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_LogicalOr, expression(1), expression(3));
 }   break;
 
-#line 1021 "./glsl.g"
+#line 1072 "glsl.g"
 
 case 63: {
     // nothing to do.
 }   break;
 
-#line 1028 "./glsl.g"
+#line 1079 "glsl.g"
 
 case 64: {
     ast(1) = makeAstNode<TernaryExpressionAST>(AST::Kind_Conditional, expression(1), expression(3), expression(5));
 }   break;
 
-#line 1035 "./glsl.g"
+#line 1086 "glsl.g"
 
 case 65: {
     // nothing to do.
 }   break;
 
-#line 1042 "./glsl.g"
+#line 1093 "glsl.g"
 
 case 66: {
     ast(1) = makeAstNode<AssignmentExpressionAST>(sym(2).kind, expression(1), expression(3));
 }   break;
 
-#line 1049 "./glsl.g"
+#line 1100 "glsl.g"
 
 case 67: {
     sym(1).kind = AST::Kind_Assign;
 }   break;
 
-#line 1056 "./glsl.g"
+#line 1107 "glsl.g"
 
 case 68: {
     sym(1).kind = AST::Kind_AssignMultiply;
 }   break;
 
-#line 1063 "./glsl.g"
+#line 1114 "glsl.g"
 
 case 69: {
     sym(1).kind = AST::Kind_AssignDivide;
 }   break;
 
-#line 1070 "./glsl.g"
+#line 1121 "glsl.g"
 
 case 70: {
     sym(1).kind = AST::Kind_AssignModulus;
 }   break;
 
-#line 1077 "./glsl.g"
+#line 1128 "glsl.g"
 
 case 71: {
     sym(1).kind = AST::Kind_AssignPlus;
 }   break;
 
-#line 1084 "./glsl.g"
+#line 1135 "glsl.g"
 
 case 72: {
     sym(1).kind = AST::Kind_AssignMinus;
 }   break;
 
-#line 1091 "./glsl.g"
+#line 1142 "glsl.g"
 
 case 73: {
     sym(1).kind = AST::Kind_AssignShiftLeft;
 }   break;
 
-#line 1098 "./glsl.g"
+#line 1149 "glsl.g"
 
 case 74: {
     sym(1).kind = AST::Kind_AssignShiftRight;
 }   break;
 
-#line 1105 "./glsl.g"
+#line 1156 "glsl.g"
 
 case 75: {
     sym(1).kind = AST::Kind_AssignAnd;
 }   break;
 
-#line 1112 "./glsl.g"
+#line 1163 "glsl.g"
 
 case 76: {
     sym(1).kind = AST::Kind_AssignXor;
 }   break;
 
-#line 1119 "./glsl.g"
+#line 1170 "glsl.g"
 
 case 77: {
     sym(1).kind = AST::Kind_AssignOr;
 }   break;
 
-#line 1126 "./glsl.g"
+#line 1177 "glsl.g"
 
 case 78: {
     // nothing to do.
 }   break;
 
-#line 1133 "./glsl.g"
+#line 1184 "glsl.g"
 
 case 79: {
     ast(1) = makeAstNode<BinaryExpressionAST>(AST::Kind_Comma, expression(1), expression(3));
 }   break;
 
-#line 1140 "./glsl.g"
+#line 1191 "glsl.g"
 
 case 80: {
     // nothing to do.
 }   break;
 
-#line 1147 "./glsl.g"
+#line 1198 "glsl.g"
 
 case 81: {
     // nothing to do.
 }   break;
 
-#line 1154 "./glsl.g"
+#line 1205 "glsl.g"
 
 case 82: {
     ast(1) = makeAstNode<InitDeclarationAST>(sym(1).declaration_list);
 }   break;
 
-#line 1161 "./glsl.g"
+#line 1212 "glsl.g"
 
 case 83: {
     ast(1) = makeAstNode<PrecisionDeclarationAST>(sym(2).precision, type(3));
 }   break;
 
-#line 1168 "./glsl.g"
+#line 1219 "glsl.g"
 
 case 84: {
     if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) {
@@ -696,7 +740,7 @@ case 84: {
     ast(1) = makeAstNode<TypeDeclarationAST>(type);
 }   break;
 
-#line 1179 "./glsl.g"
+#line 1230 "glsl.g"
 
 case 85: {
     if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) {
@@ -714,7 +758,7 @@ case 85: {
          makeAstNode<VariableDeclarationAST>(qualtype, string(6)));
 }   break;
 
-#line 1198 "./glsl.g"
+#line 1249 "glsl.g"
 
 case 86: {
     if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) {
@@ -733,7 +777,7 @@ case 86: {
             (makeAstNode<ArrayTypeAST>(qualtype), string(6)));
 }   break;
 
-#line 1218 "./glsl.g"
+#line 1269 "glsl.g"
 
 case 87: {
     if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) {
@@ -752,7 +796,7 @@ case 87: {
             (makeAstNode<ArrayTypeAST>(qualtype, expression(8)), string(6)));
 }   break;
 
-#line 1238 "./glsl.g"
+#line 1289 "glsl.g"
 
 case 88: {
     TypeAST *type = makeAstNode<QualifiedTypeAST>
@@ -761,59 +805,59 @@ case 88: {
     ast(1) = makeAstNode<TypeDeclarationAST>(type);
 }   break;
 
-#line 1248 "./glsl.g"
+#line 1299 "glsl.g"
 
 case 89: {
     function(1)->finishParams();
 }   break;
 
-#line 1255 "./glsl.g"
+#line 1306 "glsl.g"
 
 case 90: {
     // nothing to do.
 }   break;
 
-#line 1262 "./glsl.g"
+#line 1313 "glsl.g"
 
 case 91: {
     // nothing to do.
 }   break;
 
-#line 1269 "./glsl.g"
+#line 1320 "glsl.g"
 
 case 92: {
     function(1)->params = makeAstNode< List<ParameterDeclarationAST *> >
         (sym(2).param_declaration);
 }   break;
 
-#line 1277 "./glsl.g"
+#line 1328 "glsl.g"
 
 case 93: {
     function(1)->params = makeAstNode< List<ParameterDeclarationAST *> >
         (function(1)->params, sym(3).param_declaration);
 }   break;
 
-#line 1285 "./glsl.g"
+#line 1336 "glsl.g"
 
 case 94: {
     function(1) = makeAstNode<FunctionDeclarationAST>(type(1), string(2));
 }   break;
 
-#line 1292 "./glsl.g"
+#line 1343 "glsl.g"
 
 case 95: {
     sym(1).param_declarator.type = type(1);
     sym(1).param_declarator.name = string(2);
 }   break;
 
-#line 1300 "./glsl.g"
+#line 1351 "glsl.g"
 
 case 96: {
     sym(1).param_declarator.type = makeAstNode<ArrayTypeAST>(type(1), expression(4));
     sym(1).param_declarator.name = string(2);
 }   break;
 
-#line 1308 "./glsl.g"
+#line 1359 "glsl.g"
 
 case 97: {
     ast(1) = makeAstNode<ParameterDeclarationAST>
@@ -824,7 +868,7 @@ case 97: {
          sym(3).param_declarator.name);
 }   break;
 
-#line 1320 "./glsl.g"
+#line 1371 "glsl.g"
 
 case 98: {
     ast(1) = makeAstNode<ParameterDeclarationAST>
@@ -833,7 +877,7 @@ case 98: {
          sym(2).param_declarator.name);
 }   break;
 
-#line 1330 "./glsl.g"
+#line 1381 "glsl.g"
 
 case 99: {
     ast(1) = makeAstNode<ParameterDeclarationAST>
@@ -843,7 +887,7 @@ case 99: {
          (const QString *)0);
 }   break;
 
-#line 1341 "./glsl.g"
+#line 1392 "glsl.g"
 
 case 100: {
     ast(1) = makeAstNode<ParameterDeclarationAST>
@@ -851,44 +895,44 @@ case 100: {
          (const QString *)0);
 }   break;
 
-#line 1350 "./glsl.g"
+#line 1401 "glsl.g"
 
 case 101: {
     sym(1).qualifier = ParameterDeclarationAST::In;
 }   break;
 
-#line 1357 "./glsl.g"
+#line 1408 "glsl.g"
 
 case 102: {
     sym(1).qualifier = ParameterDeclarationAST::In;
 }   break;
 
-#line 1364 "./glsl.g"
+#line 1415 "glsl.g"
 
 case 103: {
     sym(1).qualifier = ParameterDeclarationAST::Out;
 }   break;
 
-#line 1371 "./glsl.g"
+#line 1422 "glsl.g"
 
 case 104: {
     sym(1).qualifier = ParameterDeclarationAST::InOut;
 }   break;
 
-#line 1378 "./glsl.g"
+#line 1429 "glsl.g"
 
 case 105: {
     // nothing to do.
 }   break;
 
-#line 1385 "./glsl.g"
+#line 1436 "glsl.g"
 
 case 106: {
     sym(1).declaration_list = makeAstNode< List<DeclarationAST *> >
         (sym(1).declaration);
 }   break;
 
-#line 1393 "./glsl.g"
+#line 1444 "glsl.g"
 
 case 107: {
     TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list);
@@ -897,7 +941,7 @@ case 107: {
             (sym(1).declaration_list, decl);
 }   break;
 
-#line 1403 "./glsl.g"
+#line 1454 "glsl.g"
 
 case 108: {
     TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list);
@@ -907,7 +951,7 @@ case 108: {
             (sym(1).declaration_list, decl);
 }   break;
 
-#line 1414 "./glsl.g"
+#line 1465 "glsl.g"
 
 case 109: {
     TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list);
@@ -917,7 +961,7 @@ case 109: {
             (sym(1).declaration_list, decl);
 }   break;
 
-#line 1425 "./glsl.g"
+#line 1476 "glsl.g"
 
 case 110: {
     TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list);
@@ -928,7 +972,7 @@ case 110: {
             (sym(1).declaration_list, decl);
 }   break;
 
-#line 1437 "./glsl.g"
+#line 1488 "glsl.g"
 
 case 111: {
     TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list);
@@ -939,7 +983,7 @@ case 111: {
             (sym(1).declaration_list, decl);
 }   break;
 
-#line 1449 "./glsl.g"
+#line 1500 "glsl.g"
 
 case 112: {
     TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list);
@@ -949,40 +993,40 @@ case 112: {
             (sym(1).declaration_list, decl);
 }   break;
 
-#line 1460 "./glsl.g"
+#line 1511 "glsl.g"
 
 case 113: {
     ast(1) = makeAstNode<TypeDeclarationAST>(type(1));
 }   break;
 
-#line 1467 "./glsl.g"
+#line 1518 "glsl.g"
 
 case 114: {
     ast(1) = makeAstNode<VariableDeclarationAST>(type(1), string(2));
 }   break;
 
-#line 1474 "./glsl.g"
+#line 1525 "glsl.g"
 
 case 115: {
     ast(1) = makeAstNode<VariableDeclarationAST>
         (makeAstNode<ArrayTypeAST>(type(1)), string(2));
 }   break;
 
-#line 1482 "./glsl.g"
+#line 1533 "glsl.g"
 
 case 116: {
     ast(1) = makeAstNode<VariableDeclarationAST>
         (makeAstNode<ArrayTypeAST>(type(1), expression(4)), string(2));
 }   break;
 
-#line 1490 "./glsl.g"
+#line 1541 "glsl.g"
 
 case 117: {
     ast(1) = makeAstNode<VariableDeclarationAST>
         (makeAstNode<ArrayTypeAST>(type(1)), string(2), expression(6));
 }   break;
 
-#line 1498 "./glsl.g"
+#line 1549 "glsl.g"
 
 case 118: {
     ast(1) = makeAstNode<VariableDeclarationAST>
@@ -990,26 +1034,26 @@ case 118: {
          string(2), expression(7));
 }   break;
 
-#line 1507 "./glsl.g"
+#line 1558 "glsl.g"
 
 case 119: {
     ast(1) = makeAstNode<VariableDeclarationAST>
         (type(1), string(2), expression(4));
 }   break;
 
-#line 1515 "./glsl.g"
+#line 1566 "glsl.g"
 
 case 120: {
     ast(1) = makeAstNode<InvariantDeclarationAST>(string(2));
 }   break;
 
-#line 1522 "./glsl.g"
+#line 1573 "glsl.g"
 
 case 121: {
     ast(1) = makeAstNode<QualifiedTypeAST>(0, type(1), (List<LayoutQualifier *> *)0);
 }   break;
 
-#line 1529 "./glsl.g"
+#line 1580 "glsl.g"
 
 case 122: {
     ast(1) = makeAstNode<QualifiedTypeAST>
@@ -1017,207 +1061,207 @@ case 122: {
          sym(1).type_qualifier.layout_list);
 }   break;
 
-#line 1538 "./glsl.g"
+#line 1589 "glsl.g"
 
 case 123: {
     sym(1).qualifier = QualifiedTypeAST::Invariant;
 }   break;
 
-#line 1545 "./glsl.g"
+#line 1596 "glsl.g"
 
 case 124: {
     sym(1).qualifier = QualifiedTypeAST::Smooth;
 }   break;
 
-#line 1552 "./glsl.g"
+#line 1603 "glsl.g"
 
 case 125: {
     sym(1).qualifier = QualifiedTypeAST::Flat;
 }   break;
 
-#line 1559 "./glsl.g"
+#line 1610 "glsl.g"
 
 case 126: {
     sym(1).qualifier = QualifiedTypeAST::NoPerspective;
 }   break;
 
-#line 1566 "./glsl.g"
+#line 1617 "glsl.g"
 
 case 127: {
     sym(1) = sym(3);
 }   break;
 
-#line 1573 "./glsl.g"
+#line 1624 "glsl.g"
 
 case 128: {
     sym(1).layout_list = makeAstNode< List<LayoutQualifier *> >(sym(1).layout);
 }   break;
 
-#line 1580 "./glsl.g"
+#line 1631 "glsl.g"
 
 case 129: {
     sym(1).layout_list = makeAstNode< List<LayoutQualifier *> >(sym(1).layout_list, sym(3).layout);
 }   break;
 
-#line 1587 "./glsl.g"
+#line 1638 "glsl.g"
 
 case 130: {
     sym(1).layout = makeAstNode<LayoutQualifier>(string(1), (const QString *)0);
 }   break;
 
-#line 1594 "./glsl.g"
+#line 1645 "glsl.g"
 
 case 131: {
     sym(1).layout = makeAstNode<LayoutQualifier>(string(1), string(3));
 }   break;
 
-#line 1601 "./glsl.g"
+#line 1652 "glsl.g"
 
 case 132: {
     sym(1).qualifier = QualifiedTypeAST::Const;
 }   break;
 
-#line 1608 "./glsl.g"
+#line 1659 "glsl.g"
 
 case 133: {
     sym(1).type_qualifier.qualifier = sym(1).qualifier;
     sym(1).type_qualifier.layout_list = 0;
 }   break;
 
-#line 1616 "./glsl.g"
+#line 1667 "glsl.g"
 
 case 134: {
     sym(1).type_qualifier.layout_list = sym(1).layout_list;
     sym(1).type_qualifier.qualifier = 0;
 }   break;
 
-#line 1624 "./glsl.g"
+#line 1675 "glsl.g"
 
 case 135: {
     sym(1).type_qualifier.layout_list = sym(1).layout_list;
     sym(1).type_qualifier.qualifier = sym(2).qualifier;
 }   break;
 
-#line 1632 "./glsl.g"
+#line 1683 "glsl.g"
 
 case 136: {
     sym(1).type_qualifier.qualifier = sym(1).qualifier | sym(2).qualifier;
     sym(1).type_qualifier.layout_list = 0;
 }   break;
 
-#line 1640 "./glsl.g"
+#line 1691 "glsl.g"
 
 case 137: {
     sym(1).type_qualifier.qualifier = sym(1).qualifier;
     sym(1).type_qualifier.layout_list = 0;
 }   break;
 
-#line 1648 "./glsl.g"
+#line 1699 "glsl.g"
 
 case 138: {
     sym(1).type_qualifier.qualifier = sym(1).qualifier | sym(2).qualifier;
     sym(1).type_qualifier.layout_list = 0;
 }   break;
 
-#line 1656 "./glsl.g"
+#line 1707 "glsl.g"
 
 case 139: {
     sym(1).type_qualifier.qualifier = sym(1).qualifier | sym(2).qualifier | sym(3).qualifier;
     sym(1).type_qualifier.layout_list = 0;
 }   break;
 
-#line 1664 "./glsl.g"
+#line 1715 "glsl.g"
 
 case 140: {
     sym(1).type_qualifier.qualifier = QualifiedTypeAST::Invariant;
     sym(1).type_qualifier.layout_list = 0;
 }   break;
 
-#line 1672 "./glsl.g"
+#line 1723 "glsl.g"
 
 case 141: {
     sym(1).qualifier = QualifiedTypeAST::Const;
 }   break;
 
-#line 1679 "./glsl.g"
+#line 1730 "glsl.g"
 
 case 142: {
     sym(1).qualifier = QualifiedTypeAST::Attribute;
 }   break;
 
-#line 1686 "./glsl.g"
+#line 1737 "glsl.g"
 
 case 143: {
     sym(1).qualifier = QualifiedTypeAST::Varying;
 }   break;
 
-#line 1693 "./glsl.g"
+#line 1744 "glsl.g"
 
 case 144: {
     sym(1).qualifier = QualifiedTypeAST::CentroidVarying;
 }   break;
 
-#line 1700 "./glsl.g"
+#line 1751 "glsl.g"
 
 case 145: {
     sym(1).qualifier = QualifiedTypeAST::In;
 }   break;
 
-#line 1707 "./glsl.g"
+#line 1758 "glsl.g"
 
 case 146: {
     sym(1).qualifier = QualifiedTypeAST::Out;
 }   break;
 
-#line 1714 "./glsl.g"
+#line 1765 "glsl.g"
 
 case 147: {
     sym(1).qualifier = QualifiedTypeAST::CentroidIn;
 }   break;
 
-#line 1721 "./glsl.g"
+#line 1772 "glsl.g"
 
 case 148: {
     sym(1).qualifier = QualifiedTypeAST::CentroidOut;
 }   break;
 
-#line 1728 "./glsl.g"
+#line 1779 "glsl.g"
 
 case 149: {
     sym(1).qualifier = QualifiedTypeAST::PatchIn;
 }   break;
 
-#line 1735 "./glsl.g"
+#line 1786 "glsl.g"
 
 case 150: {
     sym(1).qualifier = QualifiedTypeAST::PatchOut;
 }   break;
 
-#line 1742 "./glsl.g"
+#line 1793 "glsl.g"
 
 case 151: {
     sym(1).qualifier = QualifiedTypeAST::SampleIn;
 }   break;
 
-#line 1749 "./glsl.g"
+#line 1800 "glsl.g"
 
 case 152: {
     sym(1).qualifier = QualifiedTypeAST::SampleOut;
 }   break;
 
-#line 1756 "./glsl.g"
+#line 1807 "glsl.g"
 
 case 153: {
     sym(1).qualifier = QualifiedTypeAST::Uniform;
 }   break;
 
-#line 1763 "./glsl.g"
+#line 1814 "glsl.g"
 
 case 154: {
     // nothing to do.
 }   break;
 
-#line 1770 "./glsl.g"
+#line 1821 "glsl.g"
 
 case 155: {
     if (!type(2)->setPrecision(sym(1).precision)) {
@@ -1226,595 +1270,595 @@ case 155: {
     ast(1) = type(2);
 }   break;
 
-#line 1780 "./glsl.g"
+#line 1831 "glsl.g"
 
 case 156: {
     // nothing to do.
 }   break;
 
-#line 1787 "./glsl.g"
+#line 1838 "glsl.g"
 
 case 157: {
     ast(1) = makeAstNode<ArrayTypeAST>(type(1));
 }   break;
 
-#line 1794 "./glsl.g"
+#line 1845 "glsl.g"
 
 case 158: {
     ast(1) = makeAstNode<ArrayTypeAST>(type(1), expression(3));
 }   break;
 
-#line 1801 "./glsl.g"
+#line 1852 "glsl.g"
 
 case 159: {
     ast(1) = makeBasicType(T_VOID);
 }   break;
 
-#line 1808 "./glsl.g"
+#line 1859 "glsl.g"
 
 case 160: {
     ast(1) = makeBasicType(T_FLOAT);
 }   break;
 
-#line 1815 "./glsl.g"
+#line 1866 "glsl.g"
 
 case 161: {
     ast(1) = makeBasicType(T_DOUBLE);
 }   break;
 
-#line 1822 "./glsl.g"
+#line 1873 "glsl.g"
 
 case 162: {
     ast(1) = makeBasicType(T_INT);
 }   break;
 
-#line 1829 "./glsl.g"
+#line 1880 "glsl.g"
 
 case 163: {
     ast(1) = makeBasicType(T_UINT);
 }   break;
 
-#line 1836 "./glsl.g"
+#line 1887 "glsl.g"
 
 case 164: {
     ast(1) = makeBasicType(T_BOOL);
 }   break;
 
-#line 1843 "./glsl.g"
+#line 1894 "glsl.g"
 
 case 165: {
     ast(1) = makeBasicType(T_VEC2);
 }   break;
 
-#line 1850 "./glsl.g"
+#line 1901 "glsl.g"
 
 case 166: {
     ast(1) = makeBasicType(T_VEC3);
 }   break;
 
-#line 1857 "./glsl.g"
+#line 1908 "glsl.g"
 
 case 167: {
     ast(1) = makeBasicType(T_VEC4);
 }   break;
 
-#line 1864 "./glsl.g"
+#line 1915 "glsl.g"
 
 case 168: {
     ast(1) = makeBasicType(T_DVEC2);
 }   break;
 
-#line 1871 "./glsl.g"
+#line 1922 "glsl.g"
 
 case 169: {
     ast(1) = makeBasicType(T_DVEC3);
 }   break;
 
-#line 1878 "./glsl.g"
+#line 1929 "glsl.g"
 
 case 170: {
     ast(1) = makeBasicType(T_DVEC4);
 }   break;
 
-#line 1885 "./glsl.g"
+#line 1936 "glsl.g"
 
 case 171: {
     ast(1) = makeBasicType(T_BVEC2);
 }   break;
 
-#line 1892 "./glsl.g"
+#line 1943 "glsl.g"
 
 case 172: {
     ast(1) = makeBasicType(T_BVEC3);
 }   break;
 
-#line 1899 "./glsl.g"
+#line 1950 "glsl.g"
 
 case 173: {
     ast(1) = makeBasicType(T_BVEC4);
 }   break;
 
-#line 1906 "./glsl.g"
+#line 1957 "glsl.g"
 
 case 174: {
     ast(1) = makeBasicType(T_IVEC2);
 }   break;
 
-#line 1913 "./glsl.g"
+#line 1964 "glsl.g"
 
 case 175: {
     ast(1) = makeBasicType(T_IVEC3);
 }   break;
 
-#line 1920 "./glsl.g"
+#line 1971 "glsl.g"
 
 case 176: {
     ast(1) = makeBasicType(T_IVEC4);
 }   break;
 
-#line 1927 "./glsl.g"
+#line 1978 "glsl.g"
 
 case 177: {
     ast(1) = makeBasicType(T_UVEC2);
 }   break;
 
-#line 1934 "./glsl.g"
+#line 1985 "glsl.g"
 
 case 178: {
     ast(1) = makeBasicType(T_UVEC3);
 }   break;
 
-#line 1941 "./glsl.g"
+#line 1992 "glsl.g"
 
 case 179: {
     ast(1) = makeBasicType(T_UVEC4);
 }   break;
 
-#line 1948 "./glsl.g"
+#line 1999 "glsl.g"
 
 case 180: {
     ast(1) = makeBasicType(T_MAT2);
 }   break;
 
-#line 1955 "./glsl.g"
+#line 2006 "glsl.g"
 
 case 181: {
     ast(1) = makeBasicType(T_MAT3);
 }   break;
 
-#line 1962 "./glsl.g"
+#line 2013 "glsl.g"
 
 case 182: {
     ast(1) = makeBasicType(T_MAT4);
 }   break;
 
-#line 1969 "./glsl.g"
+#line 2020 "glsl.g"
 
 case 183: {
     ast(1) = makeBasicType(T_MAT2);
 }   break;
 
-#line 1976 "./glsl.g"
+#line 2027 "glsl.g"
 
 case 184: {
     ast(1) = makeBasicType(T_MAT2X3);
 }   break;
 
-#line 1983 "./glsl.g"
+#line 2034 "glsl.g"
 
 case 185: {
     ast(1) = makeBasicType(T_MAT2X4);
 }   break;
 
-#line 1990 "./glsl.g"
+#line 2041 "glsl.g"
 
 case 186: {
     ast(1) = makeBasicType(T_MAT3X2);
 }   break;
 
-#line 1997 "./glsl.g"
+#line 2048 "glsl.g"
 
 case 187: {
     ast(1) = makeBasicType(T_MAT3);
 }   break;
 
-#line 2004 "./glsl.g"
+#line 2055 "glsl.g"
 
 case 188: {
     ast(1) = makeBasicType(T_MAT3X4);
 }   break;
 
-#line 2011 "./glsl.g"
+#line 2062 "glsl.g"
 
 case 189: {
     ast(1) = makeBasicType(T_MAT4X2);
 }   break;
 
-#line 2018 "./glsl.g"
+#line 2069 "glsl.g"
 
 case 190: {
     ast(1) = makeBasicType(T_MAT4X3);
 }   break;
 
-#line 2025 "./glsl.g"
+#line 2076 "glsl.g"
 
 case 191: {
     ast(1) = makeBasicType(T_MAT4);
 }   break;
 
-#line 2032 "./glsl.g"
+#line 2083 "glsl.g"
 
 case 192: {
     ast(1) = makeBasicType(T_DMAT2);
 }   break;
 
-#line 2039 "./glsl.g"
+#line 2090 "glsl.g"
 
 case 193: {
     ast(1) = makeBasicType(T_DMAT3);
 }   break;
 
-#line 2046 "./glsl.g"
+#line 2097 "glsl.g"
 
 case 194: {
     ast(1) = makeBasicType(T_DMAT4);
 }   break;
 
-#line 2053 "./glsl.g"
+#line 2104 "glsl.g"
 
 case 195: {
     ast(1) = makeBasicType(T_DMAT2);
 }   break;
 
-#line 2060 "./glsl.g"
+#line 2111 "glsl.g"
 
 case 196: {
     ast(1) = makeBasicType(T_DMAT2X3);
 }   break;
 
-#line 2067 "./glsl.g"
+#line 2118 "glsl.g"
 
 case 197: {
     ast(1) = makeBasicType(T_DMAT2X4);
 }   break;
 
-#line 2074 "./glsl.g"
+#line 2125 "glsl.g"
 
 case 198: {
     ast(1) = makeBasicType(T_DMAT3X2);
 }   break;
 
-#line 2081 "./glsl.g"
+#line 2132 "glsl.g"
 
 case 199: {
     ast(1) = makeBasicType(T_DMAT3);
 }   break;
 
-#line 2088 "./glsl.g"
+#line 2139 "glsl.g"
 
 case 200: {
     ast(1) = makeBasicType(T_DMAT3X4);
 }   break;
 
-#line 2095 "./glsl.g"
+#line 2146 "glsl.g"
 
 case 201: {
     ast(1) = makeBasicType(T_DMAT4X2);
 }   break;
 
-#line 2102 "./glsl.g"
+#line 2153 "glsl.g"
 
 case 202: {
     ast(1) = makeBasicType(T_DMAT4X3);
 }   break;
 
-#line 2109 "./glsl.g"
+#line 2160 "glsl.g"
 
 case 203: {
     ast(1) = makeBasicType(T_DMAT4);
 }   break;
 
-#line 2116 "./glsl.g"
+#line 2167 "glsl.g"
 
 case 204: {
     ast(1) = makeBasicType(T_SAMPLER1D);
 }   break;
 
-#line 2123 "./glsl.g"
+#line 2174 "glsl.g"
 
 case 205: {
     ast(1) = makeBasicType(T_SAMPLER2D);
 }   break;
 
-#line 2130 "./glsl.g"
+#line 2181 "glsl.g"
 
 case 206: {
     ast(1) = makeBasicType(T_SAMPLER3D);
 }   break;
 
-#line 2137 "./glsl.g"
+#line 2188 "glsl.g"
 
 case 207: {
     ast(1) = makeBasicType(T_SAMPLERCUBE);
 }   break;
 
-#line 2144 "./glsl.g"
+#line 2195 "glsl.g"
 
 case 208: {
     ast(1) = makeBasicType(T_SAMPLER1DSHADOW);
 }   break;
 
-#line 2151 "./glsl.g"
+#line 2202 "glsl.g"
 
 case 209: {
     ast(1) = makeBasicType(T_SAMPLER2DSHADOW);
 }   break;
 
-#line 2158 "./glsl.g"
+#line 2209 "glsl.g"
 
 case 210: {
     ast(1) = makeBasicType(T_SAMPLERCUBESHADOW);
 }   break;
 
-#line 2165 "./glsl.g"
+#line 2216 "glsl.g"
 
 case 211: {
     ast(1) = makeBasicType(T_SAMPLER1DARRAY);
 }   break;
 
-#line 2172 "./glsl.g"
+#line 2223 "glsl.g"
 
 case 212: {
     ast(1) = makeBasicType(T_SAMPLER2DARRAY);
 }   break;
 
-#line 2179 "./glsl.g"
+#line 2230 "glsl.g"
 
 case 213: {
     ast(1) = makeBasicType(T_SAMPLER1DARRAYSHADOW);
 }   break;
 
-#line 2186 "./glsl.g"
+#line 2237 "glsl.g"
 
 case 214: {
     ast(1) = makeBasicType(T_SAMPLER2DARRAYSHADOW);
 }   break;
 
-#line 2193 "./glsl.g"
+#line 2244 "glsl.g"
 
 case 215: {
     ast(1) = makeBasicType(T_SAMPLERCUBEARRAY);
 }   break;
 
-#line 2200 "./glsl.g"
+#line 2251 "glsl.g"
 
 case 216: {
     ast(1) = makeBasicType(T_SAMPLERCUBEARRAYSHADOW);
 }   break;
 
-#line 2207 "./glsl.g"
+#line 2258 "glsl.g"
 
 case 217: {
     ast(1) = makeBasicType(T_ISAMPLER1D);
 }   break;
 
-#line 2214 "./glsl.g"
+#line 2265 "glsl.g"
 
 case 218: {
     ast(1) = makeBasicType(T_ISAMPLER2D);
 }   break;
 
-#line 2221 "./glsl.g"
+#line 2272 "glsl.g"
 
 case 219: {
     ast(1) = makeBasicType(T_ISAMPLER3D);
 }   break;
 
-#line 2228 "./glsl.g"
+#line 2279 "glsl.g"
 
 case 220: {
     ast(1) = makeBasicType(T_ISAMPLERCUBE);
 }   break;
 
-#line 2235 "./glsl.g"
+#line 2286 "glsl.g"
 
 case 221: {
     ast(1) = makeBasicType(T_ISAMPLER1DARRAY);
 }   break;
 
-#line 2242 "./glsl.g"
+#line 2293 "glsl.g"
 
 case 222: {
     ast(1) = makeBasicType(T_ISAMPLER2DARRAY);
 }   break;
 
-#line 2249 "./glsl.g"
+#line 2300 "glsl.g"
 
 case 223: {
     ast(1) = makeBasicType(T_ISAMPLERCUBEARRAY);
 }   break;
 
-#line 2256 "./glsl.g"
+#line 2307 "glsl.g"
 
 case 224: {
     ast(1) = makeBasicType(T_USAMPLER1D);
 }   break;
 
-#line 2263 "./glsl.g"
+#line 2314 "glsl.g"
 
 case 225: {
     ast(1) = makeBasicType(T_USAMPLER2D);
 }   break;
 
-#line 2270 "./glsl.g"
+#line 2321 "glsl.g"
 
 case 226: {
     ast(1) = makeBasicType(T_USAMPLER3D);
 }   break;
 
-#line 2277 "./glsl.g"
+#line 2328 "glsl.g"
 
 case 227: {
     ast(1) = makeBasicType(T_USAMPLERCUBE);
 }   break;
 
-#line 2284 "./glsl.g"
+#line 2335 "glsl.g"
 
 case 228: {
     ast(1) = makeBasicType(T_USAMPLER1DARRAY);
 }   break;
 
-#line 2291 "./glsl.g"
+#line 2342 "glsl.g"
 
 case 229: {
     ast(1) = makeBasicType(T_USAMPLER2DARRAY);
 }   break;
 
-#line 2298 "./glsl.g"
+#line 2349 "glsl.g"
 
 case 230: {
     ast(1) = makeBasicType(T_USAMPLERCUBEARRAY);
 }   break;
 
-#line 2305 "./glsl.g"
+#line 2356 "glsl.g"
 
 case 231: {
     ast(1) = makeBasicType(T_SAMPLER2DRECT);
 }   break;
 
-#line 2312 "./glsl.g"
+#line 2363 "glsl.g"
 
 case 232: {
     ast(1) = makeBasicType(T_SAMPLER2DRECTSHADOW);
 }   break;
 
-#line 2319 "./glsl.g"
+#line 2370 "glsl.g"
 
 case 233: {
     ast(1) = makeBasicType(T_ISAMPLER2DRECT);
 }   break;
 
-#line 2326 "./glsl.g"
+#line 2377 "glsl.g"
 
 case 234: {
     ast(1) = makeBasicType(T_USAMPLER2DRECT);
 }   break;
 
-#line 2333 "./glsl.g"
+#line 2384 "glsl.g"
 
 case 235: {
     ast(1) = makeBasicType(T_SAMPLERBUFFER);
 }   break;
 
-#line 2340 "./glsl.g"
+#line 2391 "glsl.g"
 
 case 236: {
     ast(1) = makeBasicType(T_ISAMPLERBUFFER);
 }   break;
 
-#line 2347 "./glsl.g"
+#line 2398 "glsl.g"
 
 case 237: {
     ast(1) = makeBasicType(T_USAMPLERBUFFER);
 }   break;
 
-#line 2354 "./glsl.g"
+#line 2405 "glsl.g"
 
 case 238: {
     ast(1) = makeBasicType(T_SAMPLER2DMS);
 }   break;
 
-#line 2361 "./glsl.g"
+#line 2412 "glsl.g"
 
 case 239: {
     ast(1) = makeBasicType(T_ISAMPLER2DMS);
 }   break;
 
-#line 2368 "./glsl.g"
+#line 2419 "glsl.g"
 
 case 240: {
     ast(1) = makeBasicType(T_USAMPLER2DMS);
 }   break;
 
-#line 2375 "./glsl.g"
+#line 2426 "glsl.g"
 
 case 241: {
     ast(1) = makeBasicType(T_SAMPLER2DMSARRAY);
 }   break;
 
-#line 2382 "./glsl.g"
+#line 2433 "glsl.g"
 
 case 242: {
     ast(1) = makeBasicType(T_ISAMPLER2DMSARRAY);
 }   break;
 
-#line 2389 "./glsl.g"
+#line 2440 "glsl.g"
 
 case 243: {
     ast(1) = makeBasicType(T_USAMPLER2DMSARRAY);
 }   break;
 
-#line 2396 "./glsl.g"
+#line 2447 "glsl.g"
 
 case 244: {
     // nothing to do.
 }   break;
 
-#line 2403 "./glsl.g"
+#line 2454 "glsl.g"
 
 case 245: {
     ast(1) = makeAstNode<NamedTypeAST>(string(1));
 }   break;
 
-#line 2410 "./glsl.g"
+#line 2461 "glsl.g"
 
 case 246: {
     sym(1).precision = TypeAST::Highp;
 }   break;
 
-#line 2417 "./glsl.g"
+#line 2468 "glsl.g"
 
 case 247: {
     sym(1).precision = TypeAST::Mediump;
 }   break;
 
-#line 2424 "./glsl.g"
+#line 2475 "glsl.g"
 
 case 248: {
     sym(1).precision = TypeAST::Lowp;
 }   break;
 
-#line 2431 "./glsl.g"
+#line 2482 "glsl.g"
 
 case 249: {
     ast(1) = makeAstNode<StructTypeAST>(string(2), sym(4).field_list);
 }   break;
 
-#line 2438 "./glsl.g"
+#line 2489 "glsl.g"
 
 case 250: {
     ast(1) = makeAstNode<StructTypeAST>(sym(3).field_list);
 }   break;
 
-#line 2445 "./glsl.g"
+#line 2496 "glsl.g"
 
 case 251: {
     // nothing to do.
 }   break;
 
-#line 2452 "./glsl.g"
+#line 2503 "glsl.g"
 
 case 252: {
     sym(1).field_list = appendLists(sym(1).field_list, sym(2).field_list);
 }   break;
 
-#line 2459 "./glsl.g"
+#line 2510 "glsl.g"
 
 case 253: {
     sym(1).field_list = StructTypeAST::fixInnerTypes(type(1), sym(2).field_list);
 }   break;
 
-#line 2466 "./glsl.g"
+#line 2517 "glsl.g"
 
 case 254: {
     sym(1).field_list = StructTypeAST::fixInnerTypes
@@ -1823,321 +1867,321 @@ case 254: {
              sym(1).type_qualifier.layout_list), sym(3).field_list);
 }   break;
 
-#line 2476 "./glsl.g"
+#line 2527 "glsl.g"
 
 case 255: {
     // nothing to do.
     sym(1).field_list = makeAstNode< List<StructTypeAST::Field *> >(sym(1).field);
 }   break;
 
-#line 2484 "./glsl.g"
+#line 2535 "glsl.g"
 
 case 256: {
     sym(1).field_list = makeAstNode< List<StructTypeAST::Field *> >(sym(1).field_list, sym(3).field);
 }   break;
 
-#line 2491 "./glsl.g"
+#line 2542 "glsl.g"
 
 case 257: {
     sym(1).field = makeAstNode<StructTypeAST::Field>(string(1));
 }   break;
 
-#line 2498 "./glsl.g"
+#line 2549 "glsl.g"
 
 case 258: {
     sym(1).field = makeAstNode<StructTypeAST::Field>
         (string(1), makeAstNode<ArrayTypeAST>((TypeAST *)0));
 }   break;
 
-#line 2506 "./glsl.g"
+#line 2557 "glsl.g"
 
 case 259: {
     sym(1).field = makeAstNode<StructTypeAST::Field>
         (string(1), makeAstNode<ArrayTypeAST>((TypeAST *)0, expression(3)));
 }   break;
 
-#line 2514 "./glsl.g"
+#line 2565 "glsl.g"
 
 case 260: {
     // nothing to do.
 }   break;
 
-#line 2521 "./glsl.g"
+#line 2572 "glsl.g"
 
 case 261: {
     ast(1) = makeAstNode<DeclarationStatementAST>(sym(1).declaration);
 }   break;
 
-#line 2528 "./glsl.g"
+#line 2579 "glsl.g"
 
 case 262: {
     // nothing to do.
 }   break;
 
-#line 2535 "./glsl.g"
+#line 2586 "glsl.g"
 
 case 263: {
     // nothing to do.
 }   break;
 
-#line 2542 "./glsl.g"
+#line 2593 "glsl.g"
 
 case 264: {
     // nothing to do.
 }   break;
 
-#line 2549 "./glsl.g"
+#line 2600 "glsl.g"
 
 case 265: {
     // nothing to do.
 }   break;
 
-#line 2556 "./glsl.g"
+#line 2607 "glsl.g"
 
 case 266: {
     // nothing to do.
 }   break;
 
-#line 2563 "./glsl.g"
+#line 2614 "glsl.g"
 
 case 267: {
     // nothing to do.
 }   break;
 
-#line 2570 "./glsl.g"
+#line 2621 "glsl.g"
 
 case 268: {
     // nothing to do.
 }   break;
 
-#line 2577 "./glsl.g"
+#line 2628 "glsl.g"
 
 case 269: {
     // nothing to do.
 }   break;
 
-#line 2584 "./glsl.g"
+#line 2635 "glsl.g"
 
 case 270: {
     // nothing to do.
 }   break;
 
-#line 2591 "./glsl.g"
+#line 2642 "glsl.g"
 
 case 271: {
     ast(1) = makeAstNode<CompoundStatementAST>();
 }   break;
 
-#line 2598 "./glsl.g"
+#line 2649 "glsl.g"
 
 case 272: {
     ast(1) = makeAstNode<CompoundStatementAST>(sym(2).statement_list);
 }   break;
 
-#line 2605 "./glsl.g"
+#line 2656 "glsl.g"
 
 case 273: {
     // nothing to do.
 }   break;
 
-#line 2612 "./glsl.g"
+#line 2663 "glsl.g"
 
 case 274: {
     // nothing to do.
 }   break;
 
-#line 2619 "./glsl.g"
+#line 2670 "glsl.g"
 
 case 275: {
     ast(1) = makeAstNode<CompoundStatementAST>();
 }   break;
 
-#line 2626 "./glsl.g"
+#line 2677 "glsl.g"
 
 case 276: {
     ast(1) = makeAstNode<CompoundStatementAST>(sym(2).statement_list);
 }   break;
 
-#line 2633 "./glsl.g"
+#line 2684 "glsl.g"
 
 case 277: {
     sym(1).statement_list = makeAstNode< List<StatementAST *> >(sym(1).statement);
 }   break;
 
-#line 2640 "./glsl.g"
+#line 2691 "glsl.g"
 
 case 278: {
     sym(1).statement_list = makeAstNode< List<StatementAST *> >(sym(1).statement_list, sym(2).statement);
 }   break;
 
-#line 2647 "./glsl.g"
+#line 2698 "glsl.g"
 
 case 279: {
     ast(1) = makeAstNode<CompoundStatementAST>();  // Empty statement
 }   break;
 
-#line 2654 "./glsl.g"
+#line 2705 "glsl.g"
 
 case 280: {
     ast(1) = makeAstNode<ExpressionStatementAST>(expression(1));
 }   break;
 
-#line 2661 "./glsl.g"
+#line 2712 "glsl.g"
 
 case 281: {
     ast(1) = makeAstNode<IfStatementAST>(expression(3), sym(5).ifstmt.thenClause, sym(5).ifstmt.elseClause);
 }   break;
 
-#line 2668 "./glsl.g"
+#line 2719 "glsl.g"
 
 case 282: {
     sym(1).ifstmt.thenClause = statement(1);
     sym(1).ifstmt.elseClause = statement(3);
 }   break;
 
-#line 2676 "./glsl.g"
+#line 2727 "glsl.g"
 
 case 283: {
     sym(1).ifstmt.thenClause = statement(1);
     sym(1).ifstmt.elseClause = 0;
 }   break;
 
-#line 2684 "./glsl.g"
+#line 2735 "glsl.g"
 
 case 284: {
     // nothing to do.
 }   break;
 
-#line 2691 "./glsl.g"
+#line 2742 "glsl.g"
 
 case 285: {
     ast(1) = makeAstNode<DeclarationExpressionAST>
         (type(1), string(2), expression(4));
 }   break;
 
-#line 2699 "./glsl.g"
+#line 2750 "glsl.g"
 
 case 286: {
     ast(1) = makeAstNode<SwitchStatementAST>(expression(3), statement(6));
 }   break;
 
-#line 2706 "./glsl.g"
+#line 2757 "glsl.g"
 
 case 287: {
     ast(1) = makeAstNode<CompoundStatementAST>();
 }   break;
 
-#line 2713 "./glsl.g"
+#line 2764 "glsl.g"
 
 case 288: {
     ast(1) = makeAstNode<CompoundStatementAST>(sym(1).statement_list);
 }   break;
 
-#line 2720 "./glsl.g"
+#line 2771 "glsl.g"
 
 case 289: {
     ast(1) = makeAstNode<CaseLabelStatementAST>(expression(2));
 }   break;
 
-#line 2727 "./glsl.g"
+#line 2778 "glsl.g"
 
 case 290: {
     ast(1) = makeAstNode<CaseLabelStatementAST>();
 }   break;
 
-#line 2734 "./glsl.g"
+#line 2785 "glsl.g"
 
 case 291: {
     ast(1) = makeAstNode<WhileStatementAST>(expression(3), statement(5));
 }   break;
 
-#line 2741 "./glsl.g"
+#line 2792 "glsl.g"
 
 case 292: {
     ast(1) = makeAstNode<DoStatementAST>(statement(2), expression(5));
 }   break;
 
-#line 2748 "./glsl.g"
+#line 2799 "glsl.g"
 
 case 293: {
     ast(1) = makeAstNode<ForStatementAST>(statement(3), sym(4).forstmt.condition, sym(4).forstmt.increment, statement(6));
 }   break;
 
-#line 2755 "./glsl.g"
+#line 2806 "glsl.g"
 
 case 294: {
     // nothing to do.
 }   break;
 
-#line 2762 "./glsl.g"
+#line 2813 "glsl.g"
 
 case 295: {
     // nothing to do.
 }   break;
 
-#line 2769 "./glsl.g"
+#line 2820 "glsl.g"
 
 case 296: {
     // nothing to do.
 }   break;
 
-#line 2776 "./glsl.g"
+#line 2827 "glsl.g"
 
 case 297: {
     // nothing to do.
 }   break;
 
-#line 2783 "./glsl.g"
+#line 2834 "glsl.g"
 
 case 298: {
     sym(1).forstmt.condition = expression(1);
     sym(1).forstmt.increment = 0;
 }   break;
 
-#line 2791 "./glsl.g"
+#line 2842 "glsl.g"
 
 case 299: {
     sym(1).forstmt.condition = expression(1);
     sym(1).forstmt.increment = expression(3);
 }   break;
 
-#line 2799 "./glsl.g"
+#line 2850 "glsl.g"
 
 case 300: {
     ast(1) = makeAstNode<JumpStatementAST>(AST::Kind_Continue);
 }   break;
 
-#line 2806 "./glsl.g"
+#line 2857 "glsl.g"
 
 case 301: {
     ast(1) = makeAstNode<JumpStatementAST>(AST::Kind_Break);
 }   break;
 
-#line 2813 "./glsl.g"
+#line 2864 "glsl.g"
 
 case 302: {
     ast(1) = makeAstNode<ReturnStatementAST>();
 }   break;
 
-#line 2820 "./glsl.g"
+#line 2871 "glsl.g"
 
 case 303: {
     ast(1) = makeAstNode<ReturnStatementAST>(expression(2));
 }   break;
 
-#line 2827 "./glsl.g"
+#line 2878 "glsl.g"
 
 case 304: {
     ast(1) = makeAstNode<JumpStatementAST>(AST::Kind_Discard);
 }   break;
 
-#line 2834 "./glsl.g"
+#line 2885 "glsl.g"
 
 case 305: {
     ast(1) = makeAstNode<TranslationUnitAST>(sym(1).declaration_list);
 }   break;
 
-#line 2841 "./glsl.g"
+#line 2892 "glsl.g"
 
 case 306: {
     if (sym(1).declaration) {
@@ -2148,7 +2192,7 @@ case 306: {
     }
 }   break;
 
-#line 2853 "./glsl.g"
+#line 2904 "glsl.g"
 
 case 307: {
     if (sym(1).declaration_list && sym(2).declaration) {
@@ -2164,37 +2208,37 @@ case 307: {
     }
 }   break;
 
-#line 2870 "./glsl.g"
+#line 2921 "glsl.g"
 
 case 308: {
     // nothing to do.
 }   break;
 
-#line 2877 "./glsl.g"
+#line 2928 "glsl.g"
 
 case 309: {
     // nothing to do.
 }   break;
 
-#line 2884 "./glsl.g"
+#line 2935 "glsl.g"
 
 case 310: {
     ast(1) = 0;
 }   break;
 
-#line 2891 "./glsl.g"
+#line 2942 "glsl.g"
 
 case 311: {
     function(1)->body = statement(2);
 }   break;
 
-#line 2898 "./glsl.g"
+#line 2949 "glsl.g"
 
 case 312: {
     ast(1) = 0;
 }   break;
 
-#line 2906 "./glsl.g"
+#line 2957 "glsl.g"
 
 } // end switch
 } // end Parser::reduce()
index 9359140..278739f 100644 (file)
@@ -1,5 +1,5 @@
 
-#line 214 "./glsl.g"
+#line 214 "glsl.g"
 
 /**************************************************************************
 **
@@ -102,7 +102,11 @@ private:
     TypeAST *&type(int n) { return _symStack[_tos + n - 1].type; }
     FunctionDeclarationAST *&function(int n) { return _symStack[_tos + n - 1].function_declaration; }
 
-    inline int consumeToken() { return _index++; }
+    inline int consumeToken() {
+        if (_index < int(_tokens.size()))
+            return _index++;
+        return _tokens.size() - 1;
+    }
     inline const Token &tokenAt(int index) const { return _tokens.at(index); }
     inline int tokenKind(int index) const { return _tokens.at(index).kind; }
     void reduce(int ruleno);
@@ -169,6 +173,9 @@ private:
     int _tos;
     int _index;
     int yyloc;
+    int yytoken;
+    int yyrecovering;
+    bool _recovered;
     std::vector<int> _stateStack;
     std::vector<int> _locationStack;
     std::vector<Value> _symStack;
index 9e9cf2d..1dd6716 100644 (file)
@@ -1,49 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** 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.
-**
-** 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.
-**
-** 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.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
 // This file was generated by qlalr - DO NOT EDIT!
 #include "glslparsertable_p.h"
 
-QT_BEGIN_NAMESPACE
-
 const char *const GLSLParserTable::spell [] = {
   "end of file", "+=", "&", "&=", "&&", "attribute", "!", "bool", "break", "bvec2", 
   "bvec3", "bvec4", "^", "case", "centroid", ":", ",", "const", "continue", "-", 
@@ -62,7 +19,19 @@ const char *const GLSLParserTable::spell [] = {
   "~", "type_name", "uint", "uniform", "usampler1D", "usampler1DArray", "usampler2D", "usampler2DArray", "usampler2DMS", "usampler2DMSarray", 
   "usampler2DRect", "usampler3D", "usamplerBuffer", "usamplerCube", "usamplerCubeArray", "uvec2", "uvec3", "uvec4", "varying", "vec2", 
   "vec3", "vec4", "|", "void", "while", "^=", "^", "true", "false", "preprocessor directive", 
-  "comment", "error", "reserved word"};
+  "comment", "error", "reserved word", 
+#ifndef QLALR_NO_GLSLPARSERTABLE_DEBUG_INFO
+"translation_unit", "variable_identifier", "primary_expression", "expression", "postfix_expression", "integer_expression", "function_call", 
+  "function_call_or_method", "function_call_generic", "function_call_header_with_parameters", "function_call_header_no_parameters", "function_call_header", "assignment_expression", "function_identifier", "type_specifier", "unary_expression", "unary_operator", 
+  "multiplicative_expression", "additive_expression", "shift_expression", "relational_expression", "equality_expression", "and_expression", "exclusive_or_expression", "inclusive_or_expression", "logical_and_expression", "logical_xor_expression", 
+  "logical_or_expression", "conditional_expression", "assignment_operator", "constant_expression", "declaration", "function_prototype", "init_declarator_list", "precision_qualifier", "type_specifier_no_prec", "type_qualifier", 
+  "struct_declaration_list", "function_declarator", "function_header", "function_header_with_parameters", "parameter_declaration", "fully_specified_type", "parameter_declarator", "parameter_type_qualifier", "parameter_qualifier", "parameter_type_specifier", 
+  "empty", "single_declaration", "initializer", "invariant_qualifier", "interpolation_qualifier", "layout_qualifier", "layout_qualifier_id_list", "layout_qualifier_id", "storage_qualifier", "type_specifier_nonarray", 
+  "struct_specifier", "struct_declaration", "struct_declarator_list", "struct_declarator", "declaration_statement", "statement", "compound_statement", "simple_statement", "expression_statement", "selection_statement", 
+  "switch_statement", "case_label", "iteration_statement", "jump_statement", "statement_list", "statement_no_new_scope", "compound_statement_no_new_scope", "selection_rest_statement", "condition", "switch_statement_list", 
+  "for_init_statement", "for_rest_statement", "conditionopt", "external_declaration_list", "external_declaration", "function_definition", "$accept"
+#endif // QLALR_NO_GLSLPARSERTABLE_DEBUG_INFO
+};
 
 const short GLSLParserTable::lhs [] = {
   174, 175, 175, 175, 175, 175, 177, 177, 177, 177, 
@@ -132,6 +101,359 @@ const short GLSLParserTable::rhs [] = {
   2, 2, 2, 3, 2, 1, 1, 2, 1, 1, 
   1, 2, 0, 2};
 
+
+#ifndef QLALR_NO_GLSLPARSERTABLE_DEBUG_INFO
+const int GLSLParserTable::rule_info [] = {
+    174, 50
+  , 175, 97
+  , 175, 167
+  , 175, 168
+  , 175, 174
+  , 175, 77, 176, 112
+  , 177, 175
+  , 177, 177, 75, 178, 110
+  , 177, 179
+  , 177, 177, 37, 50
+  , 177, 177, 53
+  , 177, 177, 20
+  , 178, 176
+  , 179, 180
+  , 180, 181
+  , 180, 177, 37, 181
+  , 181, 182, 112
+  , 181, 183, 112
+  , 183, 184, 163
+  , 183, 184
+  , 182, 184, 185
+  , 182, 182, 16, 185
+  , 184, 186, 77
+  , 186, 187
+  , 186, 50
+  , 188, 177
+  , 188, 53, 188
+  , 188, 20, 188
+  , 188, 189, 188
+  , 189, 103
+  , 189, 19
+  , 189, 6
+  , 189, 140
+  , 190, 188
+  , 190, 190, 135, 188
+  , 190, 190, 133, 188
+  , 190, 190, 102, 188
+  , 191, 190
+  , 191, 191, 103, 190
+  , 191, 191, 19, 190
+  , 192, 191
+  , 192, 192, 76, 191
+  , 192, 192, 111, 191
+  , 193, 192
+  , 193, 193, 72, 192
+  , 193, 193, 107, 192
+  , 193, 193, 78, 192
+  , 193, 193, 48, 192
+  , 194, 193
+  , 194, 194, 44, 193
+  , 194, 194, 95, 193
+  , 195, 194
+  , 195, 195, 2, 194
+  , 196, 195
+  , 196, 196, 12, 195
+  , 197, 196
+  , 197, 197, 162, 196
+  , 198, 197
+  , 198, 198, 4, 197
+  , 199, 198
+  , 199, 199, 166, 198
+  , 200, 199
+  , 200, 200, 99, 199
+  , 201, 200
+  , 201, 200, 105, 176, 15, 185
+  , 185, 201
+  , 185, 188, 202, 185
+  , 202, 43
+  , 202, 94
+  , 202, 23
+  , 202, 93
+  , 202, 1
+  , 202, 138
+  , 202, 73
+  , 202, 108
+  , 202, 3
+  , 202, 165
+  , 202, 98
+  , 176, 185
+  , 176, 176, 16, 185
+  , 203, 201
+  , 204, 205, 132
+  , 204, 206, 132
+  , 204, 104, 207, 208, 132
+  , 204, 209, 50, 74, 210, 109, 132
+  , 204, 209, 50, 74, 210, 109, 50, 132
+  , 204, 209, 50, 74, 210, 109, 50, 75, 110, 132
+  , 204, 209, 50, 74, 210, 109, 50, 75, 203, 110, 132
+  , 204, 209, 132
+  , 205, 211, 112
+  , 211, 212
+  , 211, 213
+  , 213, 212, 214
+  , 213, 213, 16, 214
+  , 212, 215, 50, 77
+  , 216, 187, 50
+  , 216, 187, 50, 75, 203, 110
+  , 214, 217, 218, 216
+  , 214, 218, 216
+  , 214, 217, 218, 219
+  , 214, 218, 219
+  , 218, 220
+  , 218, 52
+  , 218, 100
+  , 218, 54
+  , 219, 187
+  , 206, 221
+  , 206, 206, 16, 50
+  , 206, 206, 16, 50, 75, 110
+  , 206, 206, 16, 50, 75, 203, 110
+  , 206, 206, 16, 50, 75, 110, 43, 222
+  , 206, 206, 16, 50, 75, 203, 110, 43, 222
+  , 206, 206, 16, 50, 43, 222
+  , 221, 215
+  , 221, 215, 50
+  , 221, 215, 50, 75, 110
+  , 221, 215, 50, 75, 203, 110
+  , 221, 215, 50, 75, 110, 43, 222
+  , 221, 215, 50, 75, 203, 110, 43, 222
+  , 221, 215, 50, 43, 222
+  , 221, 56, 50
+  , 215, 187
+  , 215, 209, 187
+  , 223, 56
+  , 224, 134
+  , 224, 45
+  , 224, 96
+  , 225, 71, 77, 226, 112
+  , 226, 227
+  , 226, 226, 16, 227
+  , 227, 50
+  , 227, 50, 43, 97
+  , 217, 17
+  , 209, 228
+  , 209, 225
+  , 209, 225, 228
+  , 209, 224, 228
+  , 209, 224
+  , 209, 223, 228
+  , 209, 223, 224, 228
+  , 209, 56
+  , 228, 17
+  , 228, 5
+  , 228, 158
+  , 228, 14, 158
+  , 228, 52
+  , 228, 100
+  , 228, 14, 52
+  , 228, 14, 100
+  , 228, 101, 52
+  , 228, 101, 100
+  , 228, 113, 52
+  , 228, 113, 100
+  , 228, 143
+  , 187, 208
+  , 187, 207, 208
+  , 208, 229
+  , 208, 229, 75, 110
+  , 208, 229, 75, 203, 110
+  , 229, 163
+  , 229, 46
+  , 229, 38
+  , 229, 55
+  , 229, 142
+  , 229, 7
+  , 229, 159
+  , 229, 160
+  , 229, 161
+  , 229, 39
+  , 229, 40
+  , 229, 41
+  , 229, 9
+  , 229, 10
+  , 229, 11
+  , 229, 68
+  , 229, 69
+  , 229, 70
+  , 229, 155
+  , 229, 156
+  , 229, 157
+  , 229, 80
+  , 229, 84
+  , 229, 88
+  , 229, 81
+  , 229, 82
+  , 229, 83
+  , 229, 85
+  , 229, 86
+  , 229, 87
+  , 229, 89
+  , 229, 90
+  , 229, 91
+  , 229, 24
+  , 229, 28
+  , 229, 32
+  , 229, 25
+  , 229, 26
+  , 229, 27
+  , 229, 29
+  , 229, 30
+  , 229, 31
+  , 229, 33
+  , 229, 34
+  , 229, 35
+  , 229, 114
+  , 229, 118
+  , 229, 126
+  , 229, 128
+  , 229, 117
+  , 229, 125
+  , 229, 131
+  , 229, 115
+  , 229, 119
+  , 229, 116
+  , 229, 120
+  , 229, 129
+  , 229, 130
+  , 229, 57
+  , 229, 59
+  , 229, 64
+  , 229, 66
+  , 229, 58
+  , 229, 60
+  , 229, 67
+  , 229, 144
+  , 229, 146
+  , 229, 151
+  , 229, 153
+  , 229, 145
+  , 229, 147
+  , 229, 154
+  , 229, 123
+  , 229, 124
+  , 229, 63
+  , 229, 150
+  , 229, 127
+  , 229, 65
+  , 229, 152
+  , 229, 121
+  , 229, 61
+  , 229, 148
+  , 229, 122
+  , 229, 62
+  , 229, 149
+  , 229, 230
+  , 229, 141
+  , 207, 49
+  , 207, 92
+  , 207, 79
+  , 230, 136, 50, 74, 210, 109
+  , 230, 136, 74, 210, 109
+  , 210, 231
+  , 210, 210, 231
+  , 231, 187, 232, 132
+  , 231, 209, 187, 232, 132
+  , 232, 233
+  , 232, 232, 16, 233
+  , 233, 50
+  , 233, 50, 75, 110
+  , 233, 50, 75, 203, 110
+  , 222, 185
+  , 234, 204
+  , 235, 236
+  , 235, 237
+  , 237, 234
+  , 237, 238
+  , 237, 239
+  , 237, 240
+  , 237, 241
+  , 237, 242
+  , 237, 243
+  , 236, 74, 109
+  , 236, 74, 244, 109
+  , 245, 246
+  , 245, 237
+  , 246, 74, 109
+  , 246, 74, 244, 109
+  , 244, 235
+  , 244, 244, 235
+  , 238, 132
+  , 238, 176, 132
+  , 239, 51, 77, 176, 112, 247
+  , 247, 235, 42, 235
+  , 247, 235
+  , 248, 176
+  , 248, 215, 50, 43, 222
+  , 240, 139, 77, 176, 112, 74, 249, 109
+  , 249, 220
+  , 249, 244
+  , 241, 13, 176, 15
+  , 241, 21, 15
+  , 242, 164, 77, 248, 112, 245
+  , 242, 36, 235, 164, 77, 176, 112, 132
+  , 242, 47, 77, 250, 251, 112, 245
+  , 250, 238
+  , 250, 234
+  , 252, 220
+  , 252, 248
+  , 251, 252, 132
+  , 251, 252, 132, 176
+  , 243, 18, 132
+  , 243, 8, 132
+  , 243, 106, 132
+  , 243, 106, 176, 132
+  , 243, 22, 132
+  , 173, 253
+  , 253, 254
+  , 253, 253, 254
+  , 254, 255
+  , 254, 204
+  , 254, 132
+  , 255, 205, 246
+  , 220
+  , 256, 173, 0};
+
+const int GLSLParserTable::rule_index [] = {
+  0, 2, 4, 6, 8, 10, 14, 16, 21, 23, 
+  27, 30, 33, 35, 37, 39, 43, 46, 49, 52, 
+  54, 57, 61, 64, 66, 68, 70, 73, 76, 79, 
+  81, 83, 85, 87, 89, 93, 97, 101, 103, 107, 
+  111, 113, 117, 121, 123, 127, 131, 135, 139, 141, 
+  145, 149, 151, 155, 157, 161, 163, 167, 169, 173, 
+  175, 179, 181, 185, 187, 193, 195, 199, 201, 203, 
+  205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 
+  227, 229, 232, 235, 240, 247, 255, 265, 276, 279, 
+  282, 284, 286, 289, 293, 297, 300, 306, 310, 313, 
+  317, 320, 322, 324, 326, 328, 330, 332, 336, 342, 
+  349, 357, 366, 372, 374, 377, 382, 388, 395, 403, 
+  408, 411, 413, 416, 418, 420, 422, 424, 429, 431, 
+  435, 437, 441, 443, 445, 447, 450, 453, 455, 458, 
+  462, 464, 466, 468, 470, 473, 475, 477, 480, 483, 
+  486, 489, 492, 495, 497, 499, 502, 504, 508, 513, 
+  515, 517, 519, 521, 523, 525, 527, 529, 531, 533, 
+  535, 537, 539, 541, 543, 545, 547, 549, 551, 553, 
+  555, 557, 559, 561, 563, 565, 567, 569, 571, 573, 
+  575, 577, 579, 581, 583, 585, 587, 589, 591, 593, 
+  595, 597, 599, 601, 603, 605, 607, 609, 611, 613, 
+  615, 617, 619, 621, 623, 625, 627, 629, 631, 633, 
+  635, 637, 639, 641, 643, 645, 647, 649, 651, 653, 
+  655, 657, 659, 661, 663, 665, 667, 669, 671, 673, 
+  675, 677, 679, 681, 683, 685, 687, 689, 691, 693, 
+  699, 704, 706, 709, 713, 718, 720, 724, 726, 730, 
+  735, 737, 739, 741, 743, 745, 747, 749, 751, 753, 
+  755, 757, 760, 764, 766, 768, 771, 775, 777, 780, 
+  782, 785, 791, 795, 797, 799, 804, 812, 814, 816, 
+  820, 823, 829, 837, 844, 846, 848, 850, 852, 855, 
+  859, 862, 865, 868, 872, 875, 877, 879, 882, 884, 
+  886, 888, 891, 892};
+#endif // QLALR_NO_GLSLPARSERTABLE_DEBUG_INFO
+
 const short GLSLParserTable::action_default [] = {
   0, 143, 165, 172, 173, 174, 0, 142, 193, 196, 
   197, 198, 194, 199, 200, 201, 195, 202, 203, 204, 
@@ -1292,4 +1614,3 @@ const short GLSLParserTable::action_check [] = {
   -1, 75, -1, -1, -1, -1, -1, -1, -1, -1, 
   -1};
 
-QT_END_NAMESPACE
index 4faa7e6..eef2fc1 100644 (file)
@@ -1,63 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** 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.
-**
-** 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.
-**
-** 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.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the Qt API.  It exists for the convenience
-// of other Qt classes.  This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
 // This file was generated by qlalr - DO NOT EDIT!
 #ifndef GLSLPARSERTABLE_P_H
 #define GLSLPARSERTABLE_P_H
 
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
 class GLSLParserTable
 {
 public:
@@ -250,6 +194,12 @@ public:
   static const char  *const    spell [];
   static const short             lhs [];
   static const short             rhs [];
+
+#ifndef QLALR_NO_GLSLPARSERTABLE_DEBUG_INFO
+  static const int     rule_index [];
+  static const int      rule_info [];
+#endif // QLALR_NO_GLSLPARSERTABLE_DEBUG_INFO
+
   static const short    goto_default [];
   static const short  action_default [];
   static const short    action_index [];
@@ -277,6 +227,5 @@ public:
 };
 
 
-QT_END_NAMESPACE
 #endif // GLSLPARSERTABLE_P_H
 
index 4eb6172..94fe457 100644 (file)
@@ -273,49 +273,50 @@ void GLSLTextEditor::updateDocumentNow()
     Engine engine;
     Parser parser(&engine, preprocessedCode.constData(), preprocessedCode.size(), variant);
     TranslationUnitAST *ast = parser.parse();
-
-    GLSLEditorPlugin *plugin = GLSLEditorPlugin::instance();
-
-    Semantic sem;
-    Scope *globalScope = engine.newNamespace();
-    sem.translationUnit(plugin->shaderInit()->ast, globalScope, plugin->shaderInit()->engine);
-    if (variant & Lexer::Variant_VertexShader)
-        sem.translationUnit(plugin->vertexShaderInit()->ast, globalScope, plugin->vertexShaderInit()->engine);
-    if (variant & Lexer::Variant_FragmentShader)
-        sem.translationUnit(plugin->fragmentShaderInit()->ast, globalScope, plugin->fragmentShaderInit()->engine);
-    sem.translationUnit(ast, globalScope, &engine);
-
-    QTextCharFormat errorFormat;
-    errorFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
-    errorFormat.setUnderlineColor(Qt::red);
-
-    QTextCharFormat warningFormat;
-    warningFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
-    warningFormat.setUnderlineColor(Qt::darkYellow);
-
-    QList<QTextEdit::ExtraSelection> sels;
-    QSet<int> errors;
-
-    foreach (const DiagnosticMessage &m, engine.diagnosticMessages()) {
-        if (! m.line())
-            continue;
-        else if (errors.contains(m.line()))
-            continue;
-
-        errors.insert(m.line());
-
-        QTextCursor cursor(document()->findBlockByNumber(m.line() - 1));
-        cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
-
-        QTextEdit::ExtraSelection sel;
-        sel.cursor = cursor;
-        sel.format = m.isError() ? errorFormat : warningFormat;
-        sel.format.setToolTip(m.message());
-        sels.append(sel);
+    if (ast != 0 || extraSelections(CodeWarningsSelection).isEmpty()) {
+        GLSLEditorPlugin *plugin = GLSLEditorPlugin::instance();
+
+        Semantic sem;
+        Scope *globalScope = engine.newNamespace();
+        sem.translationUnit(plugin->shaderInit()->ast, globalScope, plugin->shaderInit()->engine);
+        if (variant & Lexer::Variant_VertexShader)
+            sem.translationUnit(plugin->vertexShaderInit()->ast, globalScope, plugin->vertexShaderInit()->engine);
+        if (variant & Lexer::Variant_FragmentShader)
+            sem.translationUnit(plugin->fragmentShaderInit()->ast, globalScope, plugin->fragmentShaderInit()->engine);
+        sem.translationUnit(ast, globalScope, &engine);
+
+        QTextCharFormat errorFormat;
+        errorFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+        errorFormat.setUnderlineColor(Qt::red);
+
+        QTextCharFormat warningFormat;
+        warningFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+        warningFormat.setUnderlineColor(Qt::darkYellow);
+
+        QList<QTextEdit::ExtraSelection> sels;
+        QSet<int> errors;
+
+        foreach (const DiagnosticMessage &m, engine.diagnosticMessages()) {
+            if (! m.line())
+                continue;
+            else if (errors.contains(m.line()))
+                continue;
+
+            errors.insert(m.line());
+
+            QTextCursor cursor(document()->findBlockByNumber(m.line() - 1));
+            cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+
+            QTextEdit::ExtraSelection sel;
+            sel.cursor = cursor;
+            sel.format = m.isError() ? errorFormat : warningFormat;
+            sel.format.setToolTip(m.message());
+            sels.append(sel);
+        }
+
+        setExtraSelections(CodeWarningsSelection, sels);
     }
 
-    setExtraSelections(CodeWarningsSelection, sels);
-
     // refresh the identifiers.
     m_identifiers = engine.identifiers();
 }