Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / parser / qdeclarativejslexer_p.h
index 4bc5cc5..806603e 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** 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.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
@@ -63,6 +63,28 @@ namespace QDeclarativeJS {
 
 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:
@@ -114,19 +136,29 @@ 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;
 
@@ -144,6 +176,8 @@ public:
     QString errorMessage() const;
 
     bool prevTerminator() const;
+    bool followsClosingBrace() const;
+    bool canInsertAutomaticSemicolon(int token) const;
 
     enum ParenthesesState {
         IgnoreParentheses,
@@ -151,12 +185,13 @@ public:
         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);
@@ -193,6 +228,7 @@ private:
     int _stackToken;
 
     int _patternFlags;
+    int _tokenKind;
     int _tokenLength;
     int _tokenLine;
 
@@ -200,7 +236,9 @@ private:
     bool _prohibitAutomaticSemicolon;
     bool _restrictedKeyword;
     bool _terminator;
+    bool _followsClosingBrace;
     bool _delimited;
+    bool _qmlMode;
 };
 
 } // end of namespace QDeclarativeJS