Rename HTML editor to Smarty editor
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index e4ed1ce..a19a44d 100644 (file)
@@ -27,8 +27,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
         * stream - currentPosition-1 gives the sourceEnd position into the stream
         */
        // 1.4 feature
-//     private boolean assertMode;
-
+       // private boolean assertMode;
        public boolean useAssertAsAnIndentifier = false;
 
        // flag indicating if processed source contains occurrences of keyword assert
@@ -199,6 +198,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                ObviousIdentCharNatures['"'] = C_SEPARATOR;
                ObviousIdentCharNatures['\''] = C_SEPARATOR;
        }
+
        static final char[] initCharArray = new char[] { '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' };
 
        static final int TableSize = 30, InternalTableSize = 6;
@@ -285,10 +285,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
         */
        public static boolean isPHPIdentOrVarStart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DOLLAR;
+                       return ObviousIdentCharNatures[ch] == C_LETTER || ObviousIdentCharNatures[ch] == C_DOLLAR;
                }
                return false;
-               //return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+               // return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F <=
+               // ch && ch <= 0xFF);
        }
 
        /**
@@ -299,10 +300,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
         */
        public static boolean isPHPIdentifierStart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER;
+                       return ObviousIdentCharNatures[ch] == C_LETTER;
                }
                return false;
-//             return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+               // return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <=
+               // 0xFF);
        }
 
        /**
@@ -311,15 +313,16 @@ public class Scanner implements IScanner, ITerminalSymbols {
         */
        public static boolean isPHPIdentifierPart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DIGIT;
+                       return ObviousIdentCharNatures[ch] == C_LETTER || ObviousIdentCharNatures[ch] == C_DIGIT;
                }
                return false;
-//             return Character.isLetterOrDigit(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+               // return Character.isLetterOrDigit(ch) || (ch == '_') || (0x7F <= ch && ch
+               // <= 0xFF);
        }
 
        public static boolean isSQLIdentifierPart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DIGIT;
+                       return ObviousIdentCharNatures[ch] == C_LETTER || ObviousIdentCharNatures[ch] == C_DIGIT;
                }
                return false;
        }
@@ -419,6 +422,18 @@ public class Scanner implements IScanner, ITerminalSymbols {
                return result;
        }
 
+       public final boolean equalsCurrentTokenSource(char[] word) {
+               if (word.length != currentPosition - startPosition) {
+                       return false;
+               }
+               for (int i = 0; i < word.length; i++) {
+                       if (word[i] != source[startPosition + i]) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
        public final char[] getRawTokenSourceEnd() {
                int length = this.eofPosition - this.currentPosition - 1;
                char[] sourceEnd = new char[length];
@@ -889,8 +904,9 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        do {
                                currentCharacter = source[currentPosition++];
                        } while (currentCharacter == ' ' || currentCharacter == '\t');
-                       while (ObviousIdentCharNatures[currentCharacter]==C_LETTER) {
-                               //      while((currentCharacter >= 'a' && currentCharacter <= 'z') || (currentCharacter >= 'A' && currentCharacter <= 'Z')) {
+                       while (ObviousIdentCharNatures[currentCharacter] == C_LETTER) {
+                               // while((currentCharacter >= 'a' && currentCharacter <= 'z') ||
+                               // (currentCharacter >= 'A' && currentCharacter <= 'Z')) {
                                buf.append(currentCharacter);
                                currentCharacter = source[currentPosition++];
                        }
@@ -2429,7 +2445,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                        break;
                                }
                                default:
-                                       if (isPHPIdentOrVarStart(currentCharacter) ) {
+                                       if (isPHPIdentOrVarStart(currentCharacter)) {
                                                try {
                                                        scanIdentifierOrKeyword((currentCharacter == '$'));
                                                } catch (InvalidInputException ex) {
@@ -2437,8 +2453,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                ;
                                                break;
                                        }
-                               if ( ObviousIdentCharNatures[currentCharacter]==C_DIGIT) {
-//                                     if (Character.isDigit(currentCharacter)) {
+                                       if (ObviousIdentCharNatures[currentCharacter] == C_DIGIT) {
+                                               // if (Character.isDigit(currentCharacter)) {
                                                try {
                                                        scanNumber(false);
                                                } catch (InvalidInputException ex) {
@@ -3516,8 +3532,13 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        } else
                                return TokenNameIdentifier;
                case 's':
-                       // static switch
+                       // self static switch
                        switch (length) {
+//                     case 4:
+//                             if ((data[++index] == 'e') && (data[++index] == 'l') && (data[++index] == 'f')) {
+//                                     return TokenNameself;
+//                             }
+//                             return TokenNameIdentifier;
                        case 6:
                                if (data[++index] == 't')
                                        if ((data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'i') && (data[++index] == 'c')) {
@@ -3945,6 +3966,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        return "require_once"; //$NON-NLS-1$
                case TokenNamereturn:
                        return "return"; //$NON-NLS-1$
+//             case TokenNameself:
+//                     return "self"; //$NON-NLS-1$
                case TokenNamestatic:
                        return "static"; //$NON-NLS-1$
                case TokenNameswitch:
@@ -3973,10 +3996,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        return "StringInterpolated(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                case TokenNameEncapsedString0:
                        return "`"; //$NON-NLS-1$
-                       // case TokenNameEncapsedString1:
-                       // return "\'"; //$NON-NLS-1$
-                       // case TokenNameEncapsedString2:
-                       // return "\""; //$NON-NLS-1$
+               // case TokenNameEncapsedString1:
+               // return "\'"; //$NON-NLS-1$
+               // case TokenNameEncapsedString2:
+               // return "\""; //$NON-NLS-1$
                case TokenNameSTRING:
                        return "STRING_DQ(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                case TokenNameHEREDOC:
@@ -4151,7 +4174,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                this.tokenizeWhiteSpace = tokenizeWhiteSpace;
                this.tokenizeStrings = tokenizeStrings;
                this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
-//             this.assertMode = assertMode;
+               // this.assertMode = assertMode;
                // this.encapsedStringStack = null;
                this.taskTags = taskTags;
                this.taskPriorities = taskPriorities;
@@ -4325,8 +4348,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        continue nextTag;
                                                if ((sc = src[i + t]) != (tc = tag[t])) { // case sensitive check
                                                        if (this.isTaskCaseSensitive || (Character.toLowerCase(sc) != Character.toLowerCase(tc))) { // case
-                                                                                                                                                                                                                                                                                                                                                                                                                                       // insensitive
-                                                                                                                                                                                                                                                                                                                                                                                                                                       // check
+                                                               // insensitive
+                                                               // check
                                                                continue nextTag;
                                                        }
                                                }