Move JS RegExp flag definitions to header file
authorKent Hansen <kent.hansen@nokia.com>
Tue, 13 Sep 2011 11:07:38 +0000 (13:07 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Sep 2011 10:07:46 +0000 (12:07 +0200)
This way they can be used by tools that use the lexer
(e.g. qml minifier).

Change-Id: I226d1712089b01defd3b45ccb99db596955bff8b
Reviewed-on: http://codereview.qt-project.org/4762
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
src/declarative/qml/parser/qdeclarativejslexer.cpp
src/declarative/qml/parser/qdeclarativejslexer_p.h

index 342b1a8..4127468 100644 (file)
@@ -53,18 +53,12 @@ QT_END_NAMESPACE
 
 using namespace QDeclarativeJS;
 
-enum RegExpFlag {
-    Global     = 0x01,
-    IgnoreCase = 0x02,
-    Multiline  = 0x04
-};
-
-static int flagFromChar(const QChar &ch)
+static int regExpFlagFromChar(const QChar &ch)
 {
     switch (ch.unicode()) {
-    case 'g': return Global;
-    case 'i': return IgnoreCase;
-    case 'm': return Multiline;
+    case 'g': return Lexer::RegExp_Global;
+    case 'i': return Lexer::RegExp_IgnoreCase;
+    case 'm': return Lexer::RegExp_Multiline;
     }
     return 0;
 }
@@ -863,7 +857,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
             // scan the flags
             _patternFlags = 0;
             while (isIdentLetter(_char)) {
-                int flag = flagFromChar(_char);
+                int flag = regExpFlagFromChar(_char);
                 if (flag == 0) {
                     _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Invalid regular expression flag '%0'")
                              .arg(QChar(_char));
index dd9f0de..a0f02af 100644 (file)
@@ -136,6 +136,12 @@ public:
         EqualPrefix
     };
 
+    enum RegExpFlag {
+        RegExp_Global     = 0x01,
+        RegExp_IgnoreCase = 0x02,
+        RegExp_Multiline  = 0x04
+    };
+
 public:
     Lexer(Engine *engine);