| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtScript module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | // This file was generated by qlalr - DO NOT EDIT! | 
|---|
| 43 |  | 
|---|
| 44 | // | 
|---|
| 45 | //  W A R N I N G | 
|---|
| 46 | //  ------------- | 
|---|
| 47 | // | 
|---|
| 48 | // This file is not part of the Qt API.  It exists purely as an | 
|---|
| 49 | // implementation detail.  This header file may change from version to | 
|---|
| 50 | // version without notice, or even be removed. | 
|---|
| 51 | // | 
|---|
| 52 | // We mean it. | 
|---|
| 53 | // | 
|---|
| 54 |  | 
|---|
| 55 | // | 
|---|
| 56 | // This file is automatically generated from qscript.g. | 
|---|
| 57 | // Changes will be lost. | 
|---|
| 58 | // | 
|---|
| 59 |  | 
|---|
| 60 | #ifndef QSCRIPTPARSER_P_H | 
|---|
| 61 | #define QSCRIPTPARSER_P_H | 
|---|
| 62 |  | 
|---|
| 63 | #include "qscriptgrammar_p.h" | 
|---|
| 64 |  | 
|---|
| 65 | #ifndef QT_NO_SCRIPT | 
|---|
| 66 |  | 
|---|
| 67 | #include "qscriptastfwd_p.h" | 
|---|
| 68 |  | 
|---|
| 69 | QT_BEGIN_NAMESPACE | 
|---|
| 70 |  | 
|---|
| 71 | class QString; | 
|---|
| 72 | class QScriptEnginePrivate; | 
|---|
| 73 | class QScriptNameIdImpl; | 
|---|
| 74 |  | 
|---|
| 75 | class QScriptParser: protected QScriptGrammar | 
|---|
| 76 | { | 
|---|
| 77 | public: | 
|---|
| 78 | union Value { | 
|---|
| 79 | int ival; | 
|---|
| 80 | double dval; | 
|---|
| 81 | QScriptNameIdImpl *sval; | 
|---|
| 82 | QScript::AST::ArgumentList *ArgumentList; | 
|---|
| 83 | QScript::AST::CaseBlock *CaseBlock; | 
|---|
| 84 | QScript::AST::CaseClause *CaseClause; | 
|---|
| 85 | QScript::AST::CaseClauses *CaseClauses; | 
|---|
| 86 | QScript::AST::Catch *Catch; | 
|---|
| 87 | QScript::AST::DefaultClause *DefaultClause; | 
|---|
| 88 | QScript::AST::ElementList *ElementList; | 
|---|
| 89 | QScript::AST::Elision *Elision; | 
|---|
| 90 | QScript::AST::ExpressionNode *Expression; | 
|---|
| 91 | QScript::AST::Finally *Finally; | 
|---|
| 92 | QScript::AST::FormalParameterList *FormalParameterList; | 
|---|
| 93 | QScript::AST::FunctionBody *FunctionBody; | 
|---|
| 94 | QScript::AST::FunctionDeclaration *FunctionDeclaration; | 
|---|
| 95 | QScript::AST::Node *Node; | 
|---|
| 96 | QScript::AST::PropertyName *PropertyName; | 
|---|
| 97 | QScript::AST::PropertyNameAndValueList *PropertyNameAndValueList; | 
|---|
| 98 | QScript::AST::SourceElement *SourceElement; | 
|---|
| 99 | QScript::AST::SourceElements *SourceElements; | 
|---|
| 100 | QScript::AST::Statement *Statement; | 
|---|
| 101 | QScript::AST::StatementList *StatementList; | 
|---|
| 102 | QScript::AST::VariableDeclaration *VariableDeclaration; | 
|---|
| 103 | QScript::AST::VariableDeclarationList *VariableDeclarationList; | 
|---|
| 104 | }; | 
|---|
| 105 |  | 
|---|
| 106 | struct Location { | 
|---|
| 107 | int startLine; | 
|---|
| 108 | int startColumn; | 
|---|
| 109 | int endLine; | 
|---|
| 110 | int endColumn; | 
|---|
| 111 | }; | 
|---|
| 112 |  | 
|---|
| 113 | public: | 
|---|
| 114 | QScriptParser(); | 
|---|
| 115 | ~QScriptParser(); | 
|---|
| 116 |  | 
|---|
| 117 | bool parse(QScriptEnginePrivate *driver); | 
|---|
| 118 |  | 
|---|
| 119 | inline QString errorMessage() const | 
|---|
| 120 | { return error_message; } | 
|---|
| 121 | inline int errorLineNumber() const | 
|---|
| 122 | { return error_lineno; } | 
|---|
| 123 | inline int errorColumnNumber() const | 
|---|
| 124 | { return error_column; } | 
|---|
| 125 |  | 
|---|
| 126 | protected: | 
|---|
| 127 | inline void reallocateStack(); | 
|---|
| 128 |  | 
|---|
| 129 | inline Value &sym(int index) | 
|---|
| 130 | { return sym_stack [tos + index - 1]; } | 
|---|
| 131 |  | 
|---|
| 132 | inline Location &loc(int index) | 
|---|
| 133 | { return location_stack [tos + index - 2]; } | 
|---|
| 134 |  | 
|---|
| 135 | protected: | 
|---|
| 136 | int tos; | 
|---|
| 137 | int stack_size; | 
|---|
| 138 | Value *sym_stack; | 
|---|
| 139 | int *state_stack; | 
|---|
| 140 | Location *location_stack; | 
|---|
| 141 | QString error_message; | 
|---|
| 142 | int error_lineno; | 
|---|
| 143 | int error_column; | 
|---|
| 144 | }; | 
|---|
| 145 |  | 
|---|
| 146 | inline void QScriptParser::reallocateStack() | 
|---|
| 147 | { | 
|---|
| 148 | if (! stack_size) | 
|---|
| 149 | stack_size = 128; | 
|---|
| 150 | else | 
|---|
| 151 | stack_size <<= 1; | 
|---|
| 152 |  | 
|---|
| 153 | sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value))); | 
|---|
| 154 | state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int))); | 
|---|
| 155 | location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location))); | 
|---|
| 156 | } | 
|---|
| 157 |  | 
|---|
| 158 |  | 
|---|
| 159 | #define Q_SCRIPT_REGEXPLITERAL_RULE1 7 | 
|---|
| 160 |  | 
|---|
| 161 | #define Q_SCRIPT_REGEXPLITERAL_RULE2 8 | 
|---|
| 162 |  | 
|---|
| 163 | QT_END_NAMESPACE | 
|---|
| 164 |  | 
|---|
| 165 | #endif // QT_NO_SCRIPT | 
|---|
| 166 |  | 
|---|
| 167 | #endif // QSCRIPTPARSER_P_H | 
|---|