QmlJS: Merge parser updates from Qt5.

Change-Id: Ibed38abca8f7e7bae7d424751a18c83f4c9e9bc5
Reviewed-on: http://codereview.qt-project.org/4732
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Christian Kamm
2011-09-13 08:42:52 +02:00
parent c0c9312495
commit b531209002
19 changed files with 3175 additions and 2801 deletions

View File

@@ -46,61 +46,17 @@
#include "qmljsglobal_p.h"
#include "qmljsastfwd_p.h"
#include "qmljsmemorypool_p.h"
#include <QString>
#include <QSet>
QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
class QML_PARSER_EXPORT NameId
{
QString _text;
public:
NameId(const QChar *u, int s)
: _text(u, s)
{ }
const QString asString() const
{ return _text; }
bool operator == (const NameId &other) const
{ return _text == other._text; }
bool operator != (const NameId &other) const
{ return _text != other._text; }
bool operator < (const NameId &other) const
{ return _text < other._text; }
};
uint qHash(const QmlJS::NameId &id);
} // end of namespace QmlJS
namespace QmlJS {
class Lexer;
class NodePool;
namespace Ecma {
class QML_PARSER_EXPORT RegExp
{
public:
enum RegExpFlag {
Global = 0x01,
IgnoreCase = 0x02,
Multiline = 0x04
};
public:
static int flagFromChar(const QChar &);
static QString flagsToString(int flags);
};
} // end of namespace Ecma
class MemoryPool;
class QML_PARSER_EXPORT DiagnosticMessage
{
@@ -127,30 +83,33 @@ public:
class QML_PARSER_EXPORT Engine
{
Lexer *_lexer;
NodePool *_nodePool;
QSet<NameId> _literals;
QList<QmlJS::AST::SourceLocation> _comments;
MemoryPool _pool;
QList<AST::SourceLocation> _comments;
QString _extraCode;
QString _code;
public:
Engine();
~Engine();
QSet<NameId> literals() const;
void setCode(const QString &code);
void addComment(int pos, int len, int line, int col);
QList<QmlJS::AST::SourceLocation> comments() const;
NameId *intern(const QChar *u, int s);
static QString toString(NameId *id);
QList<AST::SourceLocation> comments() const;
Lexer *lexer() const;
void setLexer(Lexer *lexer);
NodePool *nodePool() const;
void setNodePool(NodePool *nodePool);
MemoryPool *pool();
inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); }
QStringRef newStringRef(const QString &s);
QStringRef newStringRef(const QChar *chars, int size);
};
double integerFromString(const char *buf, int size, int radix);
} // end of namespace QmlJS
QT_QML_END_NAMESPACE