[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdelibs/kjs
From:       Harri Porten <porten () kde ! org>
Date:       2007-02-22 18:50:07
Message-ID: 1172170207.402970.29744.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 636290 by porten:

backport from trunk: keywords can't contain escape sequences,
keywords can be escaped. test in parse.js.


 M  +6 -3      lexer.cpp  
 M  +2 -0      lexer.h  


--- branches/KDE/3.5/kdelibs/kjs/lexer.cpp #636289:636290
@@ -221,7 +221,7 @@
         stringType = current;
       } else if (isIdentLetter(current)) {
         record16(current);
-        state = InIdentifier;
+        state = InIdentifierOrKeyword;
       } else if (current == '\\') {
         state = InIdentifierUnicodeEscapeStart;
       } else if (current == '0') {
@@ -347,13 +347,14 @@
         shift(1);
       }
       break;
+    case InIdentifierOrKeyword:
     case InIdentifier:
       if (isIdentLetter(current) || isDecimalDigit(current))
         record16(current);
       else if (current == '\\')
         state = InIdentifierUnicodeEscapeStart;
       else
-        setDone(Identifier);
+        setDone(state == InIdentifierOrKeyword ? IdentifierOrKeyword : Identifier);
       break;
     case InNum0:
       if (current == 'x' || current == 'X') {
@@ -508,6 +509,7 @@
     printf("(Other)\n");
     break;
   case Identifier:
+  case IdentifierOrKeyword:
     printf("(Identifier)/(Keyword)\n");
     break;
   case String:
@@ -538,8 +540,9 @@
       delimited = true;
     }
     break;
+  case IdentifierOrKeyword:
+    if ((token = Lookup::find(&mainTable, buffer16, pos16)) < 0) {
   case Identifier:
-    if ((token = Lookup::find(&mainTable, buffer16, pos16)) < 0) {
       // Lookup for keyword failed, means this is an identifier
       // Apply anonymous-function hack below (eat the identifier)
       if (convertNextIdentifier) {
--- branches/KDE/3.5/kdelibs/kjs/lexer.h #636289:636290
@@ -46,7 +46,9 @@
     bool prevTerminator() const { return terminator; }
 
     enum State { Start,
+                 IdentifierOrKeyword,
                  Identifier,
+                 InIdentifierOrKeyword,
                  InIdentifier,
                  InIdentifierUnicodeEscapeStart,
                  InIdentifierUnicodeEscape,
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic