OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / qmljs / parser / qmljsengine_p.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 ** GNU Lesser General Public License Usage
10 **
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
14 ** Please review the following information to ensure the GNU Lesser General
15 ** Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** Other Usage
23 **
24 ** Alternatively, this file may be used in accordance with the terms and
25 ** conditions contained in a signed written agreement between you and Nokia.
26 **
27 ** If you have questions regarding the use of this file, please contact
28 ** Nokia at qt-info@nokia.com.
29 **
30 **************************************************************************/
31
32 #ifndef QMLJSENGINE_P_H
33 #define QMLJSENGINE_P_H
34
35 //
36 //  W A R N I N G
37 //  -------------
38 //
39 // This file is not part of the Qt API.  It exists purely as an
40 // implementation detail.  This header file may change from version to
41 // version without notice, or even be removed.
42 //
43 // We mean it.
44 //
45
46 #include "qmljsglobal_p.h"
47 #include "qmljsastfwd_p.h"
48
49 #include <QString>
50 #include <QSet>
51
52 QT_QML_BEGIN_NAMESPACE
53
54 namespace QmlJS {
55 class QML_PARSER_EXPORT NameId
56 {
57     QString _text;
58
59 public:
60     NameId(const QChar *u, int s)
61         : _text(u, s)
62     { }
63
64     const QString asString() const
65     { return _text; }
66
67     bool operator == (const NameId &other) const
68     { return _text == other._text; }
69
70     bool operator != (const NameId &other) const
71     { return _text != other._text; }
72
73     bool operator < (const NameId &other) const
74     { return _text < other._text; }
75 };
76
77 uint qHash(const QmlJS::NameId &id);
78
79 } // end of namespace QmlJS
80
81 #if defined(Q_CC_MSVC) && _MSC_VER <= 1300
82 //this ensures that code outside QmlJS can use the hash function
83 //it also a workaround for some compilers
84 inline uint qHash(const QmlJS::NameId &nameId) { return QmlJS::qHash(nameId); }
85 #endif
86
87 namespace QmlJS {
88
89 class Lexer;
90 class NodePool;
91
92 namespace Ecma {
93
94 class QML_PARSER_EXPORT RegExp
95 {
96 public:
97     enum RegExpFlag {
98         Global     = 0x01,
99         IgnoreCase = 0x02,
100         Multiline  = 0x04
101     };
102
103 public:
104     static int flagFromChar(const QChar &);
105     static QString flagsToString(int flags);
106 };
107
108 } // end of namespace Ecma
109
110 class QML_PARSER_EXPORT DiagnosticMessage
111 {
112 public:
113     enum Kind { Warning, Error };
114
115     DiagnosticMessage()
116         : kind(Error) {}
117
118     DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
119         : kind(kind), loc(loc), message(message) {}
120
121     bool isWarning() const
122     { return kind == Warning; }
123
124     bool isError() const
125     { return kind == Error; }
126
127     Kind kind;
128     AST::SourceLocation loc;
129     QString message;
130 };
131
132 class QML_PARSER_EXPORT Engine
133 {
134     Lexer *_lexer;
135     NodePool *_nodePool;
136     QSet<NameId> _literals;
137     QList<QmlJS::AST::SourceLocation> _comments;
138
139 public:
140     Engine();
141     ~Engine();
142
143     QSet<NameId> literals() const;
144
145     void addComment(int pos, int len, int line, int col);
146     QList<QmlJS::AST::SourceLocation> comments() const;
147
148     NameId *intern(const QChar *u, int s);
149
150     static QString toString(NameId *id);
151
152     Lexer *lexer() const;
153     void setLexer(Lexer *lexer);
154
155     NodePool *nodePool() const;
156     void setNodePool(NodePool *nodePool);
157 };
158
159 } // end of namespace QmlJS
160
161 QT_QML_END_NAMESPACE
162
163 #endif // QMLJSENGINE_P_H