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

source code of qtscript/src/script/parser/qscriptparser_p.h