/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
class Engine;
+class QML_PARSER_EXPORT Directives {
+public:
+ virtual ~Directives() {}
+
+ virtual void pragmaLibrary()
+ {
+ }
+
+ virtual void importFile(const QString &jsfile, const QString &module)
+ {
+ Q_UNUSED(jsfile);
+ Q_UNUSED(module);
+ }
+
+ virtual void importModule(const QString &uri, const QString &version, const QString &module)
+ {
+ Q_UNUSED(uri);
+ Q_UNUSED(version);
+ Q_UNUSED(module);
+ }
+};
+
class QML_PARSER_EXPORT Lexer: public QDeclarativeJSGrammar
{
public:
EqualPrefix
};
+ enum RegExpFlag {
+ RegExp_Global = 0x01,
+ RegExp_IgnoreCase = 0x02,
+ RegExp_Multiline = 0x04
+ };
+
public:
Lexer(Engine *engine);
+ bool qmlMode() const;
+
QString code() const;
- void setCode(const QString &code, int lineno);
+ void setCode(const QString &code, int lineno, bool qmlMode = true);
int lex();
bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix);
+ bool scanDirectives(Directives *directives);
int regExpFlags() const { return _patternFlags; }
QString regExpPattern() const { return _tokenText; }
+ int tokenKind() const;
int tokenOffset() const;
int tokenLength() const;
QString errorMessage() const;
bool prevTerminator() const;
+ bool followsClosingBrace() const;
+ bool canInsertAutomaticSemicolon(int token) const;
enum ParenthesesState {
IgnoreParentheses,
BalancedParentheses
};
+protected:
+ int classify(const QChar *s, int n, bool qmlMode);
+
private:
- void scanChar();
+ inline void scanChar();
int scanToken();
- int classify(const QChar *s, int n);
-
bool isLineTerminator() const;
static bool isIdentLetter(QChar c);
static bool isDecimalDigit(ushort c);
int _stackToken;
int _patternFlags;
+ int _tokenKind;
int _tokenLength;
int _tokenLine;
bool _prohibitAutomaticSemicolon;
bool _restrictedKeyword;
bool _terminator;
+ bool _followsClosingBrace;
bool _delimited;
+ bool _qmlMode;
};
} // end of namespace QDeclarativeJS