1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
9 ** GNU Lesser General Public License Usage
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.
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.
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.
27 ** If you have questions regarding the use of this file, please contact
28 ** Nokia at qt-info@nokia.com.
30 **************************************************************************/
32 #ifndef QMLJSENGINE_P_H
33 #define QMLJSENGINE_P_H
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.
46 #include "qmljsglobal_p.h"
47 #include "qmljsastfwd_p.h"
52 QT_QML_BEGIN_NAMESPACE
55 class QML_PARSER_EXPORT NameId
60 NameId(const QChar *u, int s)
64 const QString asString() const
67 bool operator == (const NameId &other) const
68 { return _text == other._text; }
70 bool operator != (const NameId &other) const
71 { return _text != other._text; }
73 bool operator < (const NameId &other) const
74 { return _text < other._text; }
77 uint qHash(const QmlJS::NameId &id);
79 } // end of namespace QmlJS
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); }
94 class QML_PARSER_EXPORT RegExp
104 static int flagFromChar(const QChar &);
105 static QString flagsToString(int flags);
108 } // end of namespace Ecma
110 class QML_PARSER_EXPORT DiagnosticMessage
113 enum Kind { Warning, Error };
118 DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
119 : kind(kind), loc(loc), message(message) {}
121 bool isWarning() const
122 { return kind == Warning; }
125 { return kind == Error; }
128 AST::SourceLocation loc;
132 class QML_PARSER_EXPORT Engine
136 QSet<NameId> _literals;
137 QList<QmlJS::AST::SourceLocation> _comments;
143 QSet<NameId> literals() const;
145 void addComment(int pos, int len, int line, int col);
146 QList<QmlJS::AST::SourceLocation> comments() const;
148 NameId *intern(const QChar *u, int s);
150 static QString toString(NameId *id);
152 Lexer *lexer() const;
153 void setLexer(Lexer *lexer);
155 NodePool *nodePool() const;
156 void setNodePool(NodePool *nodePool);
159 } // end of namespace QmlJS
163 #endif // QMLJSENGINE_P_H