1) Fixed issue #872.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index f230cf3..56a9b14 100644 (file)
@@ -42,14 +42,14 @@ public class Scanner implements IScanner, ITerminalSymbols {
        public boolean phpMode = false;
 
        /**
-        * This token is set to TokenNameecho if a short tag block begins (i.e.
+        * This token is set to TokenName.echo if a short tag block begins (i.e.
         * >?= ... ) Directly after the "=" character the
-        * getNextToken() method returns TokenNameINLINE_HTML In the next call to
-        * the getNextToken() method the value of fFillerToken (==TokenNameecho) is
+        * getNextToken() method returns TokenName.INLINE_HTML In the next call to
+        * the getNextToken() method the value of fFillerToken (==TokenName.echo) is
         * returned
-        * 
+        *
         */
-       int fFillerToken = TokenNameEOF;
+       TokenName fFillerToken = TokenName.EOF;
 
        public char currentCharacter;
 
@@ -303,10 +303,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
        /**
         * Determines if the specified character is permissible as the first
         * character in a PHP identifier or variable
-        * 
+        *
         * The '$' character for PHP variables is regarded as a correct first
         * character !
-        * 
+        *
         */
        public static boolean isPHPIdentOrVarStart(char ch) {
                if (ch < MAX_OBVIOUS) {
@@ -322,7 +322,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
        /**
         * Determines if the specified character is permissible as the first
         * character in a PHP identifier.
-        * 
+        *
         * The '$' character for PHP variables isn't regarded as the first character !
         */
        public static boolean isPHPIdentifierStart(char ch) {
@@ -349,13 +349,13 @@ public class Scanner implements IScanner, ITerminalSymbols {
                // <= 0xFF);
        }
 
-       public static boolean isSQLIdentifierPart(char ch) {
-               if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch] == C_LETTER
-                                       || ObviousIdentCharNatures[ch] == C_DIGIT;
-               }
-               return false;
-       }
+//     public static boolean isSQLIdentifierPart(char ch) {
+//             if (ch < MAX_OBVIOUS) {
+//                     return ObviousIdentCharNatures[ch] == C_LETTER
+//                                     || ObviousIdentCharNatures[ch] == C_DIGIT;
+//             }
+//             return false;
+//     }
 
        public final boolean atEnd() {
                // This code is not relevant if source is
@@ -476,22 +476,22 @@ public class Scanner implements IScanner, ITerminalSymbols {
                return true;
        }
 
-       public final char[] getRawTokenSourceEnd() {
-               int length = this.eofPosition - this.currentPosition - 1;
-               char[] sourceEnd = new char[length];
-               System.arraycopy(this.source, this.currentPosition, sourceEnd, 0,
-                               length);
-               return sourceEnd;
-       }
+//     public final char[] getRawTokenSourceEnd() {
+//             int length = this.eofPosition - this.currentPosition - 1;
+//             char[] sourceEnd = new char[length];
+//             System.arraycopy(this.source, this.currentPosition, sourceEnd, 0,
+//                             length);
+//             return sourceEnd;
+//     }
 
        public int getCurrentTokenStartPosition() {
                return this.startPosition;
        }
 
-       public final String getCurrentStringLiteral() {
-               char[] result = getCurrentStringLiteralSource();
-               return new String(result);
-       }
+//     public final String getCurrentStringLiteral() {
+//             char[] result = getCurrentStringLiteralSource();
+//             return new String(result);
+//     }
 
        public final char[] getCurrentStringLiteralSource() {
                // Return the token REAL source (aka unicodes are precomputed)
@@ -508,24 +508,24 @@ public class Scanner implements IScanner, ITerminalSymbols {
                return result;
        }
 
-       public final char[] getCurrentStringLiteralSource(int startPos) {
-               // Return the token REAL source (aka unicodes are precomputed)
-               char[] result;
-               int length;
-               System.arraycopy(source, startPos + 1,
-                               result = new char[length = currentPosition - startPos - 2], 0,
-                               length);
-               // }
-               return result;
-       }
+//     public final char[] getCurrentStringLiteralSource(int startPos) {
+//             // Return the token REAL source (aka unicodes are precomputed)
+//             char[] result;
+//             int length;
+//             System.arraycopy(source, startPos + 1,
+//                             result = new char[length = currentPosition - startPos - 2], 0,
+//                             length);
+//             // }
+//             return result;
+//     }
 
        /*
         * Search the source position corresponding to the end of a given line
         * number
-        * 
+        *
         * Line numbers are 1-based, and relative to the scanner initialPosition.
         * Character positions are 0-based.
-        * 
+        *
         * In case the given line number is inconsistent, answers -1.
         */
        public final int getLineEnd(int lineNumber) {
@@ -544,12 +544,12 @@ public class Scanner implements IScanner, ITerminalSymbols {
        /**
         * Search the source position corresponding to the beginning of a given line
         * number
-        * 
+        *
         * Line numbers are 1-based, and relative to the scanner initialPosition.
         * Character positions are 0-based.
-        * 
+        *
         * e.g. getLineStart(1) --> 0 i.e. first line starts at character 0.
-        * 
+        *
         * In case the given line number is inconsistent, answers -1.
         */
        public final int getLineStart(int lineNumber) {
@@ -969,10 +969,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
                }
        }
 
-       public int getCastOrParen() {
+       public TokenName getCastOrParen() {
                int tempPosition = currentPosition;
                char tempCharacter = currentCharacter;
-               int tempToken = TokenNameLPAREN;
+               TokenName tempToken = TokenName.LPAREN;
                boolean found = false;
                StringBuffer buf = new StringBuffer();
                try {
@@ -994,7 +994,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                        if ((data[index] == 'i') && (data[++index] == 'n')
                                                        && (data[++index] == 't')) {
                                                found = true;
-                                               tempToken = TokenNameintCAST;
+                                               tempToken = TokenName.INTCAST;
                                        }
                                        break;
                                case 4:
@@ -1002,14 +1002,14 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                        if ((data[index] == 'b') && (data[++index] == 'o')
                                                        && (data[++index] == 'o') && (data[++index] == 'l')) {
                                                found = true;
-                                               tempToken = TokenNameboolCAST;
+                                               tempToken = TokenName.BOOLCAST;
                                        } else {
                                                index = 0;
                                                if ((data[index] == 'r') && (data[++index] == 'e')
                                                                && (data[++index] == 'a')
                                                                && (data[++index] == 'l')) {
                                                        found = true;
-                                                       tempToken = TokenNamedoubleCAST;
+                                                       tempToken = TokenName.DOUBLECAST;
                                                }
                                        }
                                        break;
@@ -1019,7 +1019,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        && (data[++index] == 'r') && (data[++index] == 'a')
                                                        && (data[++index] == 'y')) {
                                                found = true;
-                                               tempToken = TokenNamearrayCAST;
+                                               tempToken = TokenName.ARRAYCAST;
                                        } else {
                                                index = 0;
                                                if ((data[index] == 'u') && (data[++index] == 'n')
@@ -1027,7 +1027,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                && (data[++index] == 'e')
                                                                && (data[++index] == 't')) {
                                                        found = true;
-                                                       tempToken = TokenNameunsetCAST;
+                                                       tempToken = TokenName.UNSETCAST;
                                                } else {
                                                        index = 0;
                                                        if ((data[index] == 'f') && (data[++index] == 'l')
@@ -1035,7 +1035,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                        && (data[++index] == 'a')
                                                                        && (data[++index] == 't')) {
                                                                found = true;
-                                                               tempToken = TokenNamedoubleCAST;
+                                                               tempToken = TokenName.DOUBLECAST;
                                                        }
                                                }
                                        }
@@ -1046,7 +1046,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        && (data[++index] == 'j') && (data[++index] == 'e')
                                                        && (data[++index] == 'c') && (data[++index] == 't')) {
                                                found = true;
-                                               tempToken = TokenNameobjectCAST;
+                                               tempToken = TokenName.OBJECTCAST;
                                        } else {
                                                index = 0;
                                                if ((data[index] == 's') && (data[++index] == 't')
@@ -1055,7 +1055,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                && (data[++index] == 'n')
                                                                && (data[++index] == 'g')) {
                                                        found = true;
-                                                       tempToken = TokenNamestringCAST;
+                                                       tempToken = TokenName.STRINGCAST;
                                                } else {
                                                        index = 0;
                                                        if ((data[index] == 'd') && (data[++index] == 'o')
@@ -1064,7 +1064,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                        && (data[++index] == 'l')
                                                                        && (data[++index] == 'e')) {
                                                                found = true;
-                                                               tempToken = TokenNamedoubleCAST;
+                                                               tempToken = TokenName.DOUBLECAST;
                                                        }
                                                }
                                        }
@@ -1076,7 +1076,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        && (data[++index] == 'e') && (data[++index] == 'a')
                                                        && (data[++index] == 'n')) {
                                                found = true;
-                                               tempToken = TokenNameboolCAST;
+                                               tempToken = TokenName.BOOLCAST;
                                        } else {
                                                index = 0;
                                                if ((data[index] == 'i') && (data[++index] == 'n')
@@ -1086,7 +1086,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                && (data[++index] == 'e')
                                                                && (data[++index] == 'r')) {
                                                        found = true;
-                                                       tempToken = TokenNameintCAST;
+                                                       tempToken = TokenName.INTCAST;
                                                }
                                        }
                                        break;
@@ -1104,9 +1104,13 @@ public class Scanner implements IScanner, ITerminalSymbols {
                }
                currentCharacter = tempCharacter;
                currentPosition = tempPosition;
-               return TokenNameLPAREN;
+               return TokenName.LPAREN;
        }
 
+       /**
+        *
+        *
+        */
        public void consumeStringInterpolated() throws InvalidInputException {
                try {
                        // consume next character
@@ -1323,54 +1327,60 @@ public class Scanner implements IScanner, ITerminalSymbols {
                }
        }
 
+       /**
+        *
+        *
+        */
        public void consumeStringLiteral() throws InvalidInputException {
                try {
                        int openDollarBrace = 0;
-                       // consume next character
-                       unicodeAsBackSlash = false;
-                       currentCharacter = source[currentPosition++];
-                       while (currentCharacter != '"' || openDollarBrace > 0) {
-                               /** ** in PHP \r and \n are valid in string literals *** */
+
+                       unicodeAsBackSlash  = false;
+                       currentCharacter    = source[currentPosition++];                                   // consume next character
+
+                       while (currentCharacter != '"' ||                                          // As long as the ending '"' isn't found, or
+                              openDollarBrace > 0) {                                              // the last '}' isn't found
                                if (currentCharacter == '\\') {
-                                       int escapeSize = currentPosition;
+                                       int     escapeSize                 = currentPosition;
                                        boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
-                                       // scanEscapeCharacter make a side effect on this value and
-                                       // we need
+
+                                       // scanEscapeCharacter make a side effect on this value and we need
                                        // the previous value few lines down this one
-                                       scanDoubleQuotedEscapeCharacter();
+                                       scanDoubleQuotedEscapeCharacter ();
                                        escapeSize = currentPosition - escapeSize;
-                                       if (withoutUnicodePtr == 0) {
-                                               // buffer all the entries that have been left aside....
-                                               withoutUnicodePtr = currentPosition - escapeSize - 1
-                                                               - startPosition;
-                                               System.arraycopy(source, startPosition,
-                                                               withoutUnicodeBuffer, 1, withoutUnicodePtr);
+
+                                       if (withoutUnicodePtr == 0) {                                      // buffer all the entries that have been left aside....
+                                               withoutUnicodePtr = currentPosition - escapeSize - 1 - startPosition;
+                                               System.arraycopy (source, startPosition, withoutUnicodeBuffer, 1, withoutUnicodePtr);
                                                withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
-                                       } else { // overwrite the / in the buffer
+                                       }
+                                       else {                                                             // overwrite the / in the buffer
                                                withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
-                                               if (backSlashAsUnicodeInString) { // there are TWO \
-                                                                                                                       // in the stream
-                                                       // where only one is correct
+
+                                               if (backSlashAsUnicodeInString) {                              // there are TWO \ in the stream where only one is correct
                                                        withoutUnicodePtr--;
                                                }
                                        }
-                               } else if (currentCharacter == '$'
-                                               && source[currentPosition] == '{') {
+                               }
+                               else if (currentCharacter == '$' && source[currentPosition] == '{') {  // If found '${'
                                        openDollarBrace++;
-                               } else if (currentCharacter == '{'
-                                               && source[currentPosition] == '$') {
+                                       currentCharacter = source[currentPosition++];                      // consume next character, or we count one open brace to much!
+                               }
+                               else if (currentCharacter == '{' && source[currentPosition] == '$') {  // If found '{$'
                                        openDollarBrace++;
-                               } else if (currentCharacter == '}') {
+                               }
+                               else if (currentCharacter == '}') {                                    // If found '}'
                                        openDollarBrace--;
-                               } else if ((currentCharacter == '\r')
-                                               || (currentCharacter == '\n')) {
+                               }
+                               else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {   // In PHP \r and \n are valid in string literals
                                        if (recordLineSeparator) {
-                                               pushLineSeparator();
+                                               pushLineSeparator ();
                                        }
                                }
-                               // consume next character
+
                                unicodeAsBackSlash = false;
-                               currentCharacter = source[currentPosition++];
+                               currentCharacter = source[currentPosition++];                          // consume next character
+
                                if (withoutUnicodePtr != 0) {
                                        withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
                                }
@@ -1396,36 +1406,37 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        }
                        throw e; // rethrow
                }
-               if (checkNonExternalizedStringLiterals) { // check for presence of NLS
-                                                                                                       // tags
-                       // //$NON-NLS-?$ where ? is an
-                       // int.
+
+               if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
+                       // $NON-NLS-?$ where ? is an int.
                        if (currentLine == null) {
-                               currentLine = new NLSLine();
-                               lines.add(currentLine);
+                               currentLine = new NLSLine ();
+                               lines.add (currentLine);
                        }
-                       currentLine.add(new StringLiteral(getCurrentTokenSourceString(),
-                                       startPosition, currentPosition - 1));
+                       currentLine.add (new StringLiteral (getCurrentTokenSourceString (), startPosition, currentPosition - 1));
                }
        }
 
-       public int getNextToken() throws InvalidInputException {
+       /**
+        *
+        */
+       public TokenName getNextToken() throws InvalidInputException {
                if (!phpMode) {
                        return getInlinedHTMLToken(currentPosition);
                } else {
-                       if (fFillerToken != TokenNameEOF) {
-                               int tempToken;
+                       if (fFillerToken != TokenName.EOF) {
+                               TokenName tempToken;
                                startPosition = currentPosition;
                                tempToken = fFillerToken;
-                               fFillerToken = TokenNameEOF;
+                               fFillerToken = TokenName.EOF;
                                return tempToken;
                        }
                        this.wasAcr = false;
                        if (diet) {
                                jumpOverMethodBody();
                                diet = false;
-                               return currentPosition > source.length ? TokenNameEOF
-                                               : TokenNameRBRACE;
+                               return currentPosition > source.length ? TokenName.EOF
+                                               : TokenName.RBRACE;
                        }
                        try {
                                while (true) {
@@ -1436,238 +1447,263 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                        startPosition = currentPosition;
                                        currentCharacter = source[currentPosition++];
 
-                                       while ((currentCharacter == ' ')
-                                                       || Character.isWhitespace(currentCharacter)) {
-                                               startPosition = currentPosition;
-                                               currentCharacter = source[currentPosition++];
-                                               if ((currentCharacter == '\r')
-                                                               || (currentCharacter == '\n')) {
+                                       while ((currentCharacter == ' ') || Character.isWhitespace(currentCharacter)) {
+                                               if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
                                                        checkNonExternalizeString();
+
                                                        if (recordLineSeparator) {
                                                                pushLineSeparator();
                                                        } else {
                                                                currentLine = null;
                                                        }
                                                }
+                                               startPosition = currentPosition;
+                                               currentCharacter = source[currentPosition++];
                                        }
-                                       if (tokenizeWhiteSpace
-                                                       && (whiteStart != currentPosition - 1)) {
+
+                                       if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
                                                // reposition scanner in case we are interested by
                                                // spaces as tokens
                                                currentPosition--;
                                                startPosition = whiteStart;
-                                               return TokenNameWHITESPACE;
+                                               return TokenName.WHITESPACE;
                                        }
                                        // little trick to get out in the middle of a source
                                        // compuation
                                        if (currentPosition > eofPosition)
-                                               return TokenNameEOF;
+                                               return TokenName.EOF;
                                        // ---------Identify the next token-------------
                                        switch (currentCharacter) {
                                        case '(':
                                                return getCastOrParen();
                                        case ')':
-                                               return TokenNameRPAREN;
+                                               return TokenName.RPAREN;
                                        case '{':
-                                               return TokenNameLBRACE;
+                                               return TokenName.LBRACE;
                                        case '}':
-                                               return TokenNameRBRACE;
+                                               return TokenName.RBRACE;
                                        case '[':
-                                               return TokenNameLBRACKET;
+                                               return TokenName.LBRACKET;
                                        case ']':
-                                               return TokenNameRBRACKET;
+                                               return TokenName.RBRACKET;
                                        case ';':
-                                               return TokenNameSEMICOLON;
+                                               return TokenName.SEMICOLON;
                                        case ',':
-                                               return TokenNameCOMMA;
+                                               return TokenName.COMMA;
                                        case '.':
                                                if (getNextChar('='))
-                                                       return TokenNameDOT_EQUAL;
+                                                       return TokenName.DOT_EQUAL;
                                                if (getNextCharAsDigit())
                                                        return scanNumber(true);
-                                               return TokenNameDOT;
+                                               return TokenName.DOT;
+                                       case '\\':
+                                           return TokenName.BACKSLASH;
                                        case '+': {
                                                int test;
                                                if ((test = getNextChar('+', '=')) == 0)
-                                                       return TokenNamePLUS_PLUS;
+                                                       return TokenName.PLUS_PLUS;
                                                if (test > 0)
-                                                       return TokenNamePLUS_EQUAL;
-                                               return TokenNamePLUS;
+                                                       return TokenName.PLUS_EQUAL;
+                                               return TokenName.PLUS;
                                        }
                                        case '-': {
                                                int test;
                                                if ((test = getNextChar('-', '=')) == 0)
-                                                       return TokenNameMINUS_MINUS;
+                                                       return TokenName.MINUS_MINUS;
                                                if (test > 0)
-                                                       return TokenNameMINUS_EQUAL;
+                                                       return TokenName.MINUS_EQUAL;
                                                if (getNextChar('>'))
-                                                       return TokenNameMINUS_GREATER;
-                                               return TokenNameMINUS;
+                                                       return TokenName.MINUS_GREATER;
+                                               return TokenName.MINUS;
                                        }
                                        case '~':
                                                if (getNextChar('='))
-                                                       return TokenNameTWIDDLE_EQUAL;
-                                               return TokenNameTWIDDLE;
+                                                       return TokenName.TWIDDLE_EQUAL;
+                                               return TokenName.TWIDDLE;
                                        case '!':
                                                if (getNextChar('=')) {
                                                        if (getNextChar('=')) {
-                                                               return TokenNameNOT_EQUAL_EQUAL;
+                                                               return TokenName.NOT_EQUAL_EQUAL;
                                                        }
-                                                       return TokenNameNOT_EQUAL;
+                                                       return TokenName.NOT_EQUAL;
                                                }
-                                               return TokenNameNOT;
+                                               return TokenName.NOT;
                                        case '*':
                                                if (getNextChar('='))
-                                                       return TokenNameMULTIPLY_EQUAL;
-                                               return TokenNameMULTIPLY;
+                                                       return TokenName.MULTIPLY_EQUAL;
+                                               return TokenName.MULTIPLY;
                                        case '%':
                                                if (getNextChar('='))
-                                                       return TokenNameREMAINDER_EQUAL;
-                                               return TokenNameREMAINDER;
+                                                       return TokenName.REMAINDER_EQUAL;
+                                               return TokenName.REMAINDER;
+                                               
                                        case '<': {
                                                int oldPosition = currentPosition;
+                                               
                                                try {
                                                        currentCharacter = source[currentPosition++];
                                                } catch (IndexOutOfBoundsException e) {
                                                        currentPosition = oldPosition;
-                                                       return TokenNameLESS;
+                                                       return TokenName.LESS;
                                                }
+                                               
                                                switch (currentCharacter) {
-                                               case '=':
-                                                       return TokenNameLESS_EQUAL;
-                                               case '>':
-                                                       return TokenNameNOT_EQUAL;
-                                               case '<':
-                                                       if (getNextChar('='))
-                                                               return TokenNameLEFT_SHIFT_EQUAL;
-                                                       if (getNextChar('<')) {
-                                                               currentCharacter = source[currentPosition++];
-                                                               while (Character.isWhitespace(currentCharacter)) {
-                                                                       currentCharacter = source[currentPosition++];
-                                                               }
-                                                               int heredocStart = currentPosition - 1;
-                                                               int heredocLength = 0;
-                                                               if (isPHPIdentifierStart(currentCharacter)) {
-                                                                       currentCharacter = source[currentPosition++];
-                                                               } else {
-                                                                       return TokenNameERROR;
+                                                       case '=':
+                                                               return TokenName.LESS_EQUAL;
+                                                               
+                                                       case '>':
+                                                               return TokenName.NOT_EQUAL;
+                                                               
+                                                       case '<':
+                                                               if (getNextChar ('=')) {
+                                                                       return TokenName.LEFT_SHIFT_EQUAL;
                                                                }
-                                                               while (isPHPIdentifierPart(currentCharacter)) {
+                                                               
+                                                               if (getNextChar('<')) {
                                                                        currentCharacter = source[currentPosition++];
-                                                               }
-                                                               heredocLength = currentPosition - heredocStart
-                                                                               - 1;
-                                                               // heredoc end-tag determination
-                                                               boolean endTag = true;
-                                                               char ch;
-                                                               do {
-                                                                       ch = source[currentPosition++];
-                                                                       if (ch == '\r' || ch == '\n') {
-                                                                               if (recordLineSeparator) {
-                                                                                       pushLineSeparator();
-                                                                               } else {
-                                                                                       currentLine = null;
-                                                                               }
-                                                                               for (int i = 0; i < heredocLength; i++) {
-                                                                                       if (source[currentPosition + i] != source[heredocStart
-                                                                                                       + i]) {
-                                                                                               endTag = false;
-                                                                                               break;
+                                                                       
+                                                                       while (Character.isWhitespace(currentCharacter)) {
+                                                                               currentCharacter = source[currentPosition++];
+                                                                       }
+                                                                       
+                                                                       int heredocStart = currentPosition - 1;
+                                                                       int heredocLength = 0;
+                                                                       
+                                                                       if (isPHPIdentifierStart (currentCharacter)) {
+                                                                               currentCharacter = source[currentPosition++];
+                                                                       } 
+                                                                       else {
+                                                                               return TokenName.ERROR;
+                                                                       }
+                                                                       
+                                                                       while (isPHPIdentifierPart(currentCharacter)) {
+                                                                               currentCharacter = source[currentPosition++];
+                                                                       }
+                                                                       
+                                                                       heredocLength = currentPosition - heredocStart - 1;
+                                                                       
+                                                                       // heredoc end-tag determination
+                                                                       boolean endTag = true;
+                                                                       char ch;
+                                                                       do {
+                                                                               ch = source[currentPosition++];
+                                                                               
+                                                                               if (ch == '\r' || ch == '\n') {
+                                                                                       if (recordLineSeparator) {
+                                                                                               pushLineSeparator();
+                                                                                       } 
+                                                                                       else {
+                                                                                               currentLine = null;
+                                                                                       }
+                                                                                       
+                                                                                       for (int i = 0; i < heredocLength; i++) {
+                                                                                               if (source[currentPosition + i] != source[heredocStart + i]) {
+                                                                                                       endTag = false;
+                                                                                                       break;
+                                                                                               }
+                                                                                       }
+                                                                                       
+                                                                                       if (endTag) {
+                                                                                               currentPosition += heredocLength - 1;
+                                                                                               currentCharacter = source[currentPosition++];
+                                                                                               break; // do...while loop
+                                                                                       } 
+                                                                                       else {
+                                                                                               endTag = true;
                                                                                        }
                                                                                }
-                                                                               if (endTag) {
-                                                                                       currentPosition += heredocLength - 1;
-                                                                                       currentCharacter = source[currentPosition++];
-                                                                                       break; // do...while loop
-                                                                               } else {
-                                                                                       endTag = true;
-                                                                               }
-                                                                       }
-                                                               } while (true);
-                                                               return TokenNameHEREDOC;
+                                                                       } while (true);
+                                                                       
+                                                                       return TokenName.HEREDOC;
+                                                               }
+                                                               return TokenName.LEFT_SHIFT;
                                                        }
-                                                       return TokenNameLEFT_SHIFT;
+                                                       currentPosition = oldPosition;
+                                                       return TokenName.LESS;
                                                }
-                                               currentPosition = oldPosition;
-                                               return TokenNameLESS;
-                                       }
+                                       
                                        case '>': {
                                                int test;
                                                if ((test = getNextChar('=', '>')) == 0)
-                                                       return TokenNameGREATER_EQUAL;
+                                                       return TokenName.GREATER_EQUAL;
                                                if (test > 0) {
                                                        if ((test = getNextChar('=', '>')) == 0)
-                                                               return TokenNameRIGHT_SHIFT_EQUAL;
-                                                       return TokenNameRIGHT_SHIFT;
+                                                               return TokenName.RIGHT_SHIFT_EQUAL;
+                                                       return TokenName.RIGHT_SHIFT;
                                                }
-                                               return TokenNameGREATER;
+                                               return TokenName.GREATER;
                                        }
                                        case '=':
                                                if (getNextChar('=')) {
                                                        if (getNextChar('=')) {
-                                                               return TokenNameEQUAL_EQUAL_EQUAL;
+                                                               return TokenName.EQUAL_EQUAL_EQUAL;
                                                        }
-                                                       return TokenNameEQUAL_EQUAL;
+                                                       return TokenName.EQUAL_EQUAL;
                                                }
                                                if (getNextChar('>'))
-                                                       return TokenNameEQUAL_GREATER;
-                                               return TokenNameEQUAL;
+                                                       return TokenName.EQUAL_GREATER;
+                                               return TokenName.EQUAL;
                                        case '&': {
                                                int test;
                                                if ((test = getNextChar('&', '=')) == 0)
-                                                       return TokenNameAND_AND;
+                                                       return TokenName.AND_AND;
                                                if (test > 0)
-                                                       return TokenNameAND_EQUAL;
-                                               return TokenNameAND;
+                                                       return TokenName.AND_EQUAL;
+                                               return TokenName.OP_AND;
                                        }
                                        case '|': {
                                                int test;
                                                if ((test = getNextChar('|', '=')) == 0)
-                                                       return TokenNameOR_OR;
+                                                       return TokenName.OR_OR;
                                                if (test > 0)
-                                                       return TokenNameOR_EQUAL;
-                                               return TokenNameOR;
+                                                       return TokenName.OR_EQUAL;
+                                               return TokenName.OP_OR;
                                        }
                                        case '^':
                                                if (getNextChar('='))
-                                                       return TokenNameXOR_EQUAL;
-                                               return TokenNameXOR;
+                                                       return TokenName.XOR_EQUAL;
+                                               return TokenName.OP_XOR;
                                        case '?':
                                                if (getNextChar('>')) {
                                                        phpMode = false;
                                                        if (currentPosition == source.length) {
                                                                phpMode = true;
-                                                               return TokenNameINLINE_HTML;
+                                                               return TokenName.INLINE_HTML;
                                                        }
                                                        return getInlinedHTMLToken(currentPosition - 2);
                                                }
-                                               return TokenNameQUESTION;
+                                               else if (getNextChar(':')) {
+                                                       return TokenName.TERNARY_SHORT;
+                                               }
+                                               
+                                               return TokenName.QUESTION;
+                                               
                                        case ':':
                                                if (getNextChar(':'))
-                                                       return TokenNamePAAMAYIM_NEKUDOTAYIM;
-                                               return TokenNameCOLON;
+                                                       return TokenName.PAAMAYIM_NEKUDOTAYIM;
+                                               return TokenName.COLON;
                                        case '@':
-                                               return TokenNameAT;
+                                               return TokenName.OP_AT;
                                        case '\'':
                                                consumeStringConstant();
-                                               return TokenNameStringSingleQuote;
+                                               return TokenName.STRINGSINGLEQUOTE;
                                        case '"':
                                                // if (tokenizeStrings) {
                                                consumeStringLiteral();
-                                               return TokenNameStringDoubleQuote;
+                                               return TokenName.STRINGDOUBLEQUOTE;
                                                // }
-                                               // return TokenNameEncapsedString2;
+                                               // return TokenName.EncapsedString2;
                                        case '`':
                                                // if (tokenizeStrings) {
                                                consumeStringInterpolated();
-                                               return TokenNameStringInterpolated;
+                                               return TokenName.STRINGINTERPOLATED;
                                                // }
-                                               // return TokenNameEncapsedString0;
+                                               // return TokenName.EncapsedString0;
                                        case '#':
                                        case '/': {
                                                char startChar = currentCharacter;
                                                if (getNextChar('=') && startChar == '/') {
-                                                       return TokenNameDIVIDE_EQUAL;
+                                                       return TokenName.DIVIDE_EQUAL;
                                                }
                                                int test;
                                                if ((startChar == '#')
@@ -1726,7 +1762,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                                        // ?> breaks line comments
                                                                                        startPosition = currentPosition - 2;
                                                                                        phpMode = false;
-                                                                                       return TokenNameINLINE_HTML;
+                                                                                       return TokenName.INLINE_HTML;
                                                                                }
                                                                        }
                                                                        // get the next char
@@ -1783,7 +1819,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                        endPositionForLineComment = currentPosition - 1;
                                                                }
                                                                // recordComment(false);
-                                                               recordComment(TokenNameCOMMENT_LINE);
+                                                               recordComment(TokenName.COMMENT_LINE);
                                                                if (this.taskTags != null)
                                                                        checkTaskTag(this.startPosition,
                                                                                        this.currentPosition);
@@ -1805,7 +1841,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                                currentPosition = endPositionForLineComment;
                                                                                // reset one character behind
                                                                        }
-                                                                       return TokenNameCOMMENT_LINE;
+                                                                       return TokenName.COMMENT_LINE;
                                                                }
                                                        } catch (IndexOutOfBoundsException e) { // an eof
                                                                                                                                        // will them
@@ -1813,7 +1849,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                if (tokenizeComments) {
                                                                        currentPosition--;
                                                                        // reset one character behind
-                                                                       return TokenNameCOMMENT_LINE;
+                                                                       return TokenName.COMMENT_LINE;
                                                                }
                                                        }
                                                        break;
@@ -1898,15 +1934,15 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                }
                                                                // recordComment(isJavadoc);
                                                                if (isJavadoc) {
-                                                                       recordComment(TokenNameCOMMENT_PHPDOC);
+                                                                       recordComment(TokenName.COMMENT_PHPDOC);
                                                                } else {
-                                                                       recordComment(TokenNameCOMMENT_BLOCK);
+                                                                       recordComment(TokenName.COMMENT_BLOCK);
                                                                }
 
                                                                if (tokenizeComments) {
                                                                        if (isJavadoc)
-                                                                               return TokenNameCOMMENT_PHPDOC;
-                                                                       return TokenNameCOMMENT_BLOCK;
+                                                                               return TokenName.COMMENT_PHPDOC;
+                                                                       return TokenName.COMMENT_BLOCK;
                                                                }
 
                                                                if (this.taskTags != null) {
@@ -1921,11 +1957,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        }
                                                        break;
                                                }
-                                               return TokenNameDIVIDE;
+                                               return TokenName.DIVIDE;
                                        }
                                        case '\u001a':
                                                if (atEnd())
-                                                       return TokenNameEOF;
+                                                       return TokenName.EOF;
                                                // the atEnd may not be <currentPosition ==
                                                // source.length> if
                                                // source is only some part of a real (external) stream
@@ -1939,36 +1975,41 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                        return scanIdentifierOrKeyword(true);
                                                                } else {
                                                                        currentPosition = oldPosition;
-                                                                       return TokenNameDOLLAR;
+                                                                       return TokenName.DOLLAR;
                                                                }
                                                        } catch (IndexOutOfBoundsException e) {
                                                                currentPosition = oldPosition;
-                                                               return TokenNameDOLLAR;
+                                                               return TokenName.DOLLAR;
                                                        }
                                                }
-                                               if (isPHPIdentifierStart(currentCharacter))
+                                               
+                                               if (isPHPIdentifierStart(currentCharacter)) {
                                                        return scanIdentifierOrKeyword(false);
-                                               if (Character.isDigit(currentCharacter))
+                                               }
+                                               
+                                               if (Character.isDigit(currentCharacter)) {
                                                        return scanNumber(false);
-                                               return TokenNameERROR;
+                                               }
+                                               
+                                               return TokenName.ERROR;
                                        }
                                }
                        } // -----------------end switch while try--------------------
                        catch (IndexOutOfBoundsException e) {
                        }
                }
-               return TokenNameEOF;
+               return TokenName.EOF;
        }
 
        /**
         * @return
         * @throws InvalidInputException
         */
-       private int getInlinedHTMLToken(int start) throws InvalidInputException {
+       private TokenName getInlinedHTMLToken(int start) throws InvalidInputException {
                boolean phpShortTag = false; // true, if <?= detected
                if (currentPosition > source.length) {
                        currentPosition = source.length;
-                       return TokenNameEOF;
+                       return TokenName.EOF;
                }
                startPosition = start;
                try {
@@ -1987,12 +2028,12 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        }
                                                        // <?
                                                        if (ignorePHPOneLiner) { // for CodeFormatter
-                                                               if (lookAheadLinePHPTag() == TokenNameINLINE_HTML) {
+                                                               if (lookAheadLinePHPTag() == TokenName.INLINE_HTML) {
                                                                        phpMode = true;
                                                                        if (phpShortTag) {
-                                                                               fFillerToken = TokenNameECHO_INVISIBLE;
+                                                                               fFillerToken = TokenName.ECHO_INVISIBLE;
                                                                        }
-                                                                       return TokenNameINLINE_HTML;
+                                                                       return TokenName.INLINE_HTML;
                                                                }
                                                        } else {
                                                                boolean foundXML = false;
@@ -2007,22 +2048,22 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                        phpMode = true;
                                                                }
                                                                if (phpShortTag) {
-                                                                       fFillerToken = TokenNameECHO_INVISIBLE;
+                                                                       fFillerToken = TokenName.ECHO_INVISIBLE;
                                                                }
-                                                               return TokenNameINLINE_HTML;
+                                                               return TokenName.INLINE_HTML;
                                                        }
                                                } else {
                                                        if (getNextChar('H', 'h') >= 0) {
                                                                if (getNextChar('P', 'p') >= 0) {
                                                                        // <?PHP <?php
                                                                        if (ignorePHPOneLiner) {
-                                                                               if (lookAheadLinePHPTag() == TokenNameINLINE_HTML) {
+                                                                               if (lookAheadLinePHPTag() == TokenName.INLINE_HTML) {
                                                                                        phpMode = true;
-                                                                                       return TokenNameINLINE_HTML;
+                                                                                       return TokenName.INLINE_HTML;
                                                                                }
                                                                        } else {
                                                                                phpMode = true;
-                                                                               return TokenNameINLINE_HTML;
+                                                                               return TokenName.INLINE_HTML;
                                                                        }
                                                                }
                                                        }
@@ -2039,22 +2080,22 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                }
                        } // -----------------while--------------------
                        phpMode = true;
-                       return TokenNameINLINE_HTML;
+                       return TokenName.INLINE_HTML;
                } // -----------------try--------------------
                catch (IndexOutOfBoundsException e) {
                        startPosition = start;
                        currentPosition--;
                }
                phpMode = true;
-               return TokenNameINLINE_HTML;
+               return TokenName.INLINE_HTML;
        }
 
        /**
         * check if the PHP is only in this line (for CodeFormatter)
-        * 
+        *
         * @return
         */
-       private int lookAheadLinePHPTag() {
+       private TokenName lookAheadLinePHPTag() {
                int currentPositionInLine = currentPosition;
                char previousCharInLine = ' ';
                char currentCharInLine = ' ';
@@ -2072,7 +2113,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                // update the scanner's current Position in the source
                                                currentPosition = currentPositionInLine;
                                                // use as "dummy" token
-                                               return TokenNameEOF;
+                                               return TokenName.EOF;
                                        }
                                        break;
                                case '\\':
@@ -2103,33 +2144,33 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                        break;
                                case '\n':
                                        phpMode = true;
-                                       return TokenNameINLINE_HTML;
+                                       return TokenName.INLINE_HTML;
                                case '#':
                                        if (!singleQuotedStringActive && !doubleQuotedStringActive) {
                                                phpMode = true;
-                                               return TokenNameINLINE_HTML;
+                                               return TokenName.INLINE_HTML;
                                        }
                                        break;
                                case '/':
                                        if (previousCharInLine == '/' && !singleQuotedStringActive
                                                        && !doubleQuotedStringActive) {
                                                phpMode = true;
-                                               return TokenNameINLINE_HTML;
+                                               return TokenName.INLINE_HTML;
                                        }
                                        break;
                                case '*':
                                        if (previousCharInLine == '/' && !singleQuotedStringActive
                                                        && !doubleQuotedStringActive) {
                                                phpMode = true;
-                                               return TokenNameINLINE_HTML;
+                                               return TokenName.INLINE_HTML;
                                        }
                                        break;
                                }
                        }
                } catch (IndexOutOfBoundsException e) {
                        phpMode = true;
-                       currentPosition = currentPositionInLine;
-                       return TokenNameINLINE_HTML;
+                       currentPosition = currentPositionInLine - 1;
+                       return TokenName.INLINE_HTML;
                }
        }
 
@@ -2578,8 +2619,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                return this.source;
        }
 
-       public static boolean isIdentifierOrKeyword(int token) {
-               return (token == TokenNameIdentifier) || (token > TokenNameKEYWORD);
+       public static boolean isIdentifierOrKeyword (TokenName token) {
+               return (token == TokenName.IDENTIFIER) || (token.compareTo (TokenName.KEYWORD) > 0);
        }
 
        final char[] optimizedCurrentTokenSource1() {
@@ -2782,6 +2823,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                }
                // ---------other side---------
                i = -1;
+
                int max = newEntry4;
                while (++i <= max) {
                        char[] charArray = table[i];
@@ -2999,14 +3041,14 @@ public class Scanner implements IScanner, ITerminalSymbols {
                }
        }
 
-       public void recordComment(int token) {
+       public void recordComment(TokenName token) {
                // compute position
                int stopPosition = this.currentPosition;
                switch (token) {
-               case TokenNameCOMMENT_LINE:
+               case COMMENT_LINE:
                        stopPosition = -this.lastCommentLinePosition;
                        break;
-               case TokenNameCOMMENT_BLOCK:
+               case COMMENT_BLOCK:
                        stopPosition = -this.currentPosition;
                        break;
                }
@@ -3171,12 +3213,12 @@ public class Scanner implements IScanner, ITerminalSymbols {
        // public int scanIdentifierOrKeyword() throws InvalidInputException {
        // return scanIdentifierOrKeyword( false );
        // }
-       public int scanIdentifierOrKeyword(boolean isVariable)
+       public TokenName scanIdentifierOrKeyword(boolean isVariable)
                        throws InvalidInputException {
                // test keywords
                // first dispatch on the first char.
                // then the length. If there are several
-               // keywors with the same length AND the same first char, then do another
+               // keywords with the same length AND the same first char, then do another
                // disptach on the second char :-)...cool....but fast !
                useAssertAsAnIndentifier = false;
                while (getNextCharAsJavaIdentifierPart()) {
@@ -3184,9 +3226,9 @@ public class Scanner implements IScanner, ITerminalSymbols {
                ;
                if (isVariable) {
                        // if (new String(getCurrentTokenSource()).equals("$this")) {
-                       // return TokenNamethis;
+                       // return TokenName.this;
                        // }
-                       return TokenNameVariable;
+                       return TokenName.VARIABLE;
                }
                int index, length;
                char[] data;
@@ -3198,7 +3240,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                // only one char....
                // {
                if ((length = currentPosition - startPosition) == 1)
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                // data = source;
                data = new char[length];
                index = startPosition;
@@ -3208,7 +3250,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                index = 0;
                // } else {
                // if ((length = withoutUnicodePtr) == 1)
-               // return TokenNameIdentifier;
+               // return TokenName.Identifier;
                // // data = withoutUnicodeBuffer;
                // data = new char[withoutUnicodeBuffer.length];
                // for (int i = 0; i < withoutUnicodeBuffer.length; i++) {
@@ -3226,13 +3268,13 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                && (data[++index] == 'i') && (data[++index] == 'l')
                                                && (data[++index] == 'e') && (data[++index] == '_')
                                                && (data[++index] == '_'))
-                                       return TokenNameFILE;
+                                       return TokenName.FILE;
                                index = 0; // __LINE__
                                if ((data[++index] == '_') && (data[++index] == 'l')
                                                && (data[++index] == 'i') && (data[++index] == 'n')
                                                && (data[++index] == 'e') && (data[++index] == '_')
                                                && (data[++index] == '_'))
-                                       return TokenNameLINE;
+                                       return TokenName.LINE;
                                break;
                        case 9:
                                // __CLASS__
@@ -3240,7 +3282,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                && (data[++index] == 'l') && (data[++index] == 'a')
                                                && (data[++index] == 's') && (data[++index] == 's')
                                                && (data[++index] == '_') && (data[++index] == '_'))
-                                       return TokenNameCLASS_C;
+                                       return TokenName.CLASS_C;
                                break;
                        case 11:
                                // __METHOD__
@@ -3249,7 +3291,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                && (data[++index] == 'h') && (data[++index] == 'o')
                                                && (data[++index] == 'd') && (data[++index] == '_')
                                                && (data[++index] == '_'))
-                                       return TokenNameMETHOD_C;
+                                       return TokenName.METHOD_C;
                                break;
                        case 12:
                                // __FUNCTION__
@@ -3259,173 +3301,173 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                && (data[++index] == 'i') && (data[++index] == 'o')
                                                && (data[++index] == 'n') && (data[++index] == '_')
                                                && (data[++index] == '_'))
-                                       return TokenNameFUNC_C;
+                                       return TokenName.FUNC_C;
                                break;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'a':
                        // as and array abstract
                        switch (length) {
                        case 2:
                                // as
                                if ((data[++index] == 's')) {
-                                       return TokenNameas;
+                                       return TokenName.AS;
                                }
-                               return TokenNameIdentifier;
+                               return TokenName.IDENTIFIER;
                        case 3:
                                // and
                                if ((data[++index] == 'n') && (data[++index] == 'd')) {
-                                       return TokenNameand;
+                                       return TokenName.OP_AND_OLD;
                                }
-                               return TokenNameIdentifier;
+                               return TokenName.IDENTIFIER;
                        case 5:
                                // array
                                if ((data[++index] == 'r') && (data[++index] == 'r')
                                                && (data[++index] == 'a') && (data[++index] == 'y'))
-                                       return TokenNamearray;
-                               return TokenNameIdentifier;
+                                       return TokenName.ARRAY;
+                               return TokenName.IDENTIFIER;
                        case 8:
                                if ((data[++index] == 'b') && (data[++index] == 's')
                                                && (data[++index] == 't') && (data[++index] == 'r')
                                                && (data[++index] == 'a') && (data[++index] == 'c')
                                                && (data[++index] == 't'))
-                                       return TokenNameabstract;
-                               return TokenNameIdentifier;
+                                       return TokenName.ABSTRACT;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'b':
                        // break
                        switch (length) {
                        case 5:
                                if ((data[++index] == 'r') && (data[++index] == 'e')
                                                && (data[++index] == 'a') && (data[++index] == 'k'))
-                                       return TokenNamebreak;
-                               return TokenNameIdentifier;
+                                       return TokenName.BREAK;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'c':
                        // case catch class clone const continue
                        switch (length) {
                        case 4:
                                if ((data[++index] == 'a') && (data[++index] == 's')
                                                && (data[++index] == 'e'))
-                                       return TokenNamecase;
-                               return TokenNameIdentifier;
+                                       return TokenName.CASE;
+                               return TokenName.IDENTIFIER;
                        case 5:
                                if ((data[++index] == 'a') && (data[++index] == 't')
                                                && (data[++index] == 'c') && (data[++index] == 'h'))
-                                       return TokenNamecatch;
+                                       return TokenName.CATCH;
                                index = 0;
                                if ((data[++index] == 'l') && (data[++index] == 'a')
                                                && (data[++index] == 's') && (data[++index] == 's'))
-                                       return TokenNameclass;
+                                       return TokenName.CLASS;
                                index = 0;
                                if ((data[++index] == 'l') && (data[++index] == 'o')
                                                && (data[++index] == 'n') && (data[++index] == 'e'))
-                                       return TokenNameclone;
+                                       return TokenName.CLONE;
                                index = 0;
                                if ((data[++index] == 'o') && (data[++index] == 'n')
                                                && (data[++index] == 's') && (data[++index] == 't'))
-                                       return TokenNameconst;
-                               return TokenNameIdentifier;
+                                       return TokenName.CONST;
+                               return TokenName.IDENTIFIER;
                        case 8:
                                if ((data[++index] == 'o') && (data[++index] == 'n')
                                                && (data[++index] == 't') && (data[++index] == 'i')
                                                && (data[++index] == 'n') && (data[++index] == 'u')
                                                && (data[++index] == 'e'))
-                                       return TokenNamecontinue;
-                               return TokenNameIdentifier;
+                                       return TokenName.CONTINUE;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'd':
                        // declare default do die
                        // TODO delete define ==> no keyword !
                        switch (length) {
                        case 2:
                                if ((data[++index] == 'o'))
-                                       return TokenNamedo;
-                               return TokenNameIdentifier;
+                                       return TokenName.DO;
+                               return TokenName.IDENTIFIER;
                                // case 6 :
                                // if ((data[++index] == 'e')
                                // && (data[++index] == 'f')
                                // && (data[++index] == 'i')
                                // && (data[++index] == 'n')
                                // && (data[++index] == 'e'))
-                               // return TokenNamedefine;
+                               // return TokenName.define;
                                // else
-                               // return TokenNameIdentifier;
+                               // return TokenName.Identifier;
                        case 7:
                                if ((data[++index] == 'e') && (data[++index] == 'c')
                                                && (data[++index] == 'l') && (data[++index] == 'a')
                                                && (data[++index] == 'r') && (data[++index] == 'e'))
-                                       return TokenNamedeclare;
+                                       return TokenName.DECLARE;
                                index = 0;
                                if ((data[++index] == 'e') && (data[++index] == 'f')
                                                && (data[++index] == 'a') && (data[++index] == 'u')
                                                && (data[++index] == 'l') && (data[++index] == 't'))
-                                       return TokenNamedefault;
-                               return TokenNameIdentifier;
+                                       return TokenName.DEFAULT;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'e':
                        // echo else exit elseif extends eval
                        switch (length) {
                        case 4:
                                if ((data[++index] == 'c') && (data[++index] == 'h')
                                                && (data[++index] == 'o'))
-                                       return TokenNameecho;
+                                       return TokenName.ECHO;
                                else if ((data[index] == 'l') && (data[++index] == 's')
                                                && (data[++index] == 'e'))
-                                       return TokenNameelse;
+                                       return TokenName.ELSE;
                                else if ((data[index] == 'x') && (data[++index] == 'i')
                                                && (data[++index] == 't'))
-                                       return TokenNameexit;
+                                       return TokenName.EXIT;
                                else if ((data[index] == 'v') && (data[++index] == 'a')
                                                && (data[++index] == 'l'))
-                                       return TokenNameeval;
-                               return TokenNameIdentifier;
+                                       return TokenName.EVAL;
+                               return TokenName.IDENTIFIER;
                        case 5:
                                // endif empty
                                if ((data[++index] == 'n') && (data[++index] == 'd')
                                                && (data[++index] == 'i') && (data[++index] == 'f'))
-                                       return TokenNameendif;
+                                       return TokenName.ENDIF;
                                if ((data[index] == 'm') && (data[++index] == 'p')
                                                && (data[++index] == 't') && (data[++index] == 'y'))
-                                       return TokenNameempty;
-                               return TokenNameIdentifier;
+                                       return TokenName.EMPTY;
+                               return TokenName.IDENTIFIER;
                        case 6:
                                // endfor
                                if ((data[++index] == 'n') && (data[++index] == 'd')
                                                && (data[++index] == 'f') && (data[++index] == 'o')
                                                && (data[++index] == 'r'))
-                                       return TokenNameendfor;
+                                       return TokenName.ENDFOR;
                                else if ((data[index] == 'l') && (data[++index] == 's')
                                                && (data[++index] == 'e') && (data[++index] == 'i')
                                                && (data[++index] == 'f'))
-                                       return TokenNameelseif;
-                               return TokenNameIdentifier;
+                                       return TokenName.ELSEIF;
+                               return TokenName.IDENTIFIER;
                        case 7:
                                if ((data[++index] == 'x') && (data[++index] == 't')
                                                && (data[++index] == 'e') && (data[++index] == 'n')
                                                && (data[++index] == 'd') && (data[++index] == 's'))
-                                       return TokenNameextends;
-                               return TokenNameIdentifier;
+                                       return TokenName.EXTENDS;
+                               return TokenName.IDENTIFIER;
                        case 8:
                                // endwhile
                                if ((data[++index] == 'n') && (data[++index] == 'd')
                                                && (data[++index] == 'w') && (data[++index] == 'h')
                                                && (data[++index] == 'i') && (data[++index] == 'l')
                                                && (data[++index] == 'e'))
-                                       return TokenNameendwhile;
-                               return TokenNameIdentifier;
+                                       return TokenName.ENDWHILE;
+                               return TokenName.IDENTIFIER;
                        case 9:
                                // endswitch
                                if ((data[++index] == 'n') && (data[++index] == 'd')
                                                && (data[++index] == 's') && (data[++index] == 'w')
                                                && (data[++index] == 'i') && (data[++index] == 't')
                                                && (data[++index] == 'c') && (data[++index] == 'h'))
-                                       return TokenNameendswitch;
-                               return TokenNameIdentifier;
+                                       return TokenName.ENDSWITCH;
+                               return TokenName.IDENTIFIER;
                        case 10:
                                // enddeclare
                                if ((data[++index] == 'n') && (data[++index] == 'd')
@@ -3433,7 +3475,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                && (data[++index] == 'c') && (data[++index] == 'l')
                                                && (data[++index] == 'a') && (data[++index] == 'r')
                                                && (data[++index] == 'e'))
-                                       return TokenNameenddeclare;
+                                       return TokenName.ENDDECLARE;
                                index = 0;
                                if ((data[++index] == 'n') // endforeach
                                                && (data[++index] == 'd')
@@ -3443,138 +3485,153 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                && (data[++index] == 'e')
                                                && (data[++index] == 'a')
                                                && (data[++index] == 'c') && (data[++index] == 'h'))
-                                       return TokenNameendforeach;
-                               return TokenNameIdentifier;
+                                       return TokenName.ENDFOREACH;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'f':
                        // for false final function
                        switch (length) {
                        case 3:
                                if ((data[++index] == 'o') && (data[++index] == 'r'))
-                                       return TokenNamefor;
-                               return TokenNameIdentifier;
+                                       return TokenName.FOR;
+                               return TokenName.IDENTIFIER;
                        case 5:
                                // if ((data[++index] == 'a') && (data[++index] == 'l')
                                // && (data[++index] == 's') && (data[++index] == 'e'))
-                               // return TokenNamefalse;
+                               // return TokenName.false;
                                if ((data[++index] == 'i') && (data[++index] == 'n')
                                                && (data[++index] == 'a') && (data[++index] == 'l'))
-                                       return TokenNamefinal;
-                               return TokenNameIdentifier;
+                                       return TokenName.FINAL;
+                               return TokenName.IDENTIFIER;
                        case 7:
                                // foreach
                                if ((data[++index] == 'o') && (data[++index] == 'r')
                                                && (data[++index] == 'e') && (data[++index] == 'a')
                                                && (data[++index] == 'c') && (data[++index] == 'h'))
-                                       return TokenNameforeach;
-                               return TokenNameIdentifier;
+                                       return TokenName.FOREACH;
+                               return TokenName.IDENTIFIER;
                        case 8:
                                // function
                                if ((data[++index] == 'u') && (data[++index] == 'n')
                                                && (data[++index] == 'c') && (data[++index] == 't')
                                                && (data[++index] == 'i') && (data[++index] == 'o')
                                                && (data[++index] == 'n'))
-                                       return TokenNamefunction;
-                               return TokenNameIdentifier;
+                                       return TokenName.FUNCTION;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'g':
-                       // global
+                       // global 
                        if (length == 6) {
                                if ((data[++index] == 'l') && (data[++index] == 'o')
                                                && (data[++index] == 'b') && (data[++index] == 'a')
                                                && (data[++index] == 'l')) {
-                                       return TokenNameglobal;
+                                       return TokenName.GLOBAL;
                                }
+                       } 
+                       else if (length == 4) {  // goto
+                if ((data[++index] == 'o') && 
+                    (data[++index] == 't') && 
+                    (data[++index] == 'o')) {
+                    return TokenName.GOTO;
+                }
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'i':
                        // if int isset include include_once instanceof interface implements
                        switch (length) {
                        case 2:
                                if (data[++index] == 'f')
-                                       return TokenNameif;
-                               return TokenNameIdentifier;
+                                       return TokenName.IF;
+                               return TokenName.IDENTIFIER;
                                // case 3 :
                                // if ((data[++index] == 'n') && (data[++index] == 't'))
-                               // return TokenNameint;
+                               // return TokenName.int;
                                // else
-                               // return TokenNameIdentifier;
+                               // return TokenName.IDENTIFIER;
                        case 5:
                                if ((data[++index] == 's') && (data[++index] == 's')
                                                && (data[++index] == 'e') && (data[++index] == 't'))
-                                       return TokenNameisset;
-                               return TokenNameIdentifier;
+                                       return TokenName.ISSET;
+                               return TokenName.IDENTIFIER;
                        case 7:
                                if ((data[++index] == 'n') && (data[++index] == 'c')
                                                && (data[++index] == 'l') && (data[++index] == 'u')
                                                && (data[++index] == 'd') && (data[++index] == 'e'))
-                                       return TokenNameinclude;
-                               return TokenNameIdentifier;
+                                       return TokenName.INCLUDE;
+                               return TokenName.IDENTIFIER;
                        case 9:
                                // interface
                                if ((data[++index] == 'n') && (data[++index] == 't')
                                                && (data[++index] == 'e') && (data[++index] == 'r')
                                                && (data[++index] == 'f') && (data[++index] == 'a')
                                                && (data[++index] == 'c') && (data[++index] == 'e'))
-                                       return TokenNameinterface;
-                               return TokenNameIdentifier;
+                                       return TokenName.INTERFACE;
+                               return TokenName.IDENTIFIER;
                        case 10:
-                               // instanceof
+                               // instanceof implements
                                if ((data[++index] == 'n') && (data[++index] == 's')
                                                && (data[++index] == 't') && (data[++index] == 'a')
                                                && (data[++index] == 'n') && (data[++index] == 'c')
                                                && (data[++index] == 'e') && (data[++index] == 'o')
                                                && (data[++index] == 'f'))
-                                       return TokenNameinstanceof;
+                                       return TokenName.INSTANCEOF;
                                if ((data[index] == 'm') && (data[++index] == 'p')
                                                && (data[++index] == 'l') && (data[++index] == 'e')
                                                && (data[++index] == 'm') && (data[++index] == 'e')
                                                && (data[++index] == 'n') && (data[++index] == 't')
                                                && (data[++index] == 's'))
-                                       return TokenNameimplements;
-                               return TokenNameIdentifier;
-                       case 12:
+                                       return TokenName.IMPLEMENTS;
+                               return TokenName.IDENTIFIER;
+                       case 12: // include_once
                                if ((data[++index] == 'n') && (data[++index] == 'c')
                                                && (data[++index] == 'l') && (data[++index] == 'u')
                                                && (data[++index] == 'd') && (data[++index] == 'e')
                                                && (data[++index] == '_') && (data[++index] == 'o')
                                                && (data[++index] == 'n') && (data[++index] == 'c')
                                                && (data[++index] == 'e'))
-                                       return TokenNameinclude_once;
-                               return TokenNameIdentifier;
+                                       return TokenName.INCLUDE_ONCE;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'l':
                        // list
                        if (length == 4) {
                                if ((data[++index] == 'i') && (data[++index] == 's')
                                                && (data[++index] == 't')) {
-                                       return TokenNamelist;
+                                       return TokenName.LIST;
                                }
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'n':
-                       // new null
+                       // new null namespace
                        switch (length) {
                        case 3:
                                if ((data[++index] == 'e') && (data[++index] == 'w'))
-                                       return TokenNamenew;
-                               return TokenNameIdentifier;
+                                       return TokenName.NEW;
+                               return TokenName.IDENTIFIER;
                                // case 4 :
                                // if ((data[++index] == 'u') && (data[++index] == 'l')
                                // && (data[++index] == 'l'))
-                               // return TokenNamenull;
+                               // return TokenName.null;
                                // else
-                               // return TokenNameIdentifier;
+                               // return TokenName.IDENTIFIER;
+                       case 9:
+                if ((data[++index] == 'a') && (data[++index] == 'm')
+                        && (data[++index] == 'e') && (data[++index] == 's')
+                        && (data[++index] == 'p') && (data[++index] == 'a')
+                        && (data[++index] == 'c') && (data[++index] == 'e')) {
+                    return TokenName.NAMESPACE;
+                }
+                           return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'o':
                        // or old_function
                        if (length == 2) {
                                if (data[++index] == 'r') {
-                                       return TokenNameor;
+                                       return TokenName.OP_OR_OLD;
                                }
                        }
                        // if (length == 12) {
@@ -3589,56 +3646,56 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        // && (data[++index] == 'i')
                        // && (data[++index] == 'o')
                        // && (data[++index] == 'n')) {
-                       // return TokenNameold_function;
+                       // return TokenName.old_function;
                        // }
                        // }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'p':
                        // print public private protected
                        switch (length) {
                        case 5:
                                if ((data[++index] == 'r') && (data[++index] == 'i')
                                                && (data[++index] == 'n') && (data[++index] == 't')) {
-                                       return TokenNameprint;
+                                       return TokenName.PRINT;
                                }
-                               return TokenNameIdentifier;
+                               return TokenName.IDENTIFIER;
                        case 6:
                                if ((data[++index] == 'u') && (data[++index] == 'b')
                                                && (data[++index] == 'l') && (data[++index] == 'i')
                                                && (data[++index] == 'c')) {
-                                       return TokenNamepublic;
+                                       return TokenName.PUBLIC;
                                }
-                               return TokenNameIdentifier;
+                               return TokenName.IDENTIFIER;
                        case 7:
                                if ((data[++index] == 'r') && (data[++index] == 'i')
                                                && (data[++index] == 'v') && (data[++index] == 'a')
                                                && (data[++index] == 't') && (data[++index] == 'e')) {
-                                       return TokenNameprivate;
+                                       return TokenName.PRIVATE;
                                }
-                               return TokenNameIdentifier;
+                               return TokenName.IDENTIFIER;
                        case 9:
                                if ((data[++index] == 'r') && (data[++index] == 'o')
                                                && (data[++index] == 't') && (data[++index] == 'e')
                                                && (data[++index] == 'c') && (data[++index] == 't')
                                                && (data[++index] == 'e') && (data[++index] == 'd')) {
-                                       return TokenNameprotected;
+                                       return TokenName.PROTECTED;
                                }
-                               return TokenNameIdentifier;
+                               return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'r':
                        // return require require_once
                        if (length == 6) {
                                if ((data[++index] == 'e') && (data[++index] == 't')
                                                && (data[++index] == 'u') && (data[++index] == 'r')
                                                && (data[++index] == 'n')) {
-                                       return TokenNamereturn;
+                                       return TokenName.RETURN;
                                }
                        } else if (length == 7) {
                                if ((data[++index] == 'e') && (data[++index] == 'q')
                                                && (data[++index] == 'u') && (data[++index] == 'i')
                                                && (data[++index] == 'r') && (data[++index] == 'e')) {
-                                       return TokenNamerequire;
+                                       return TokenName.REQUIRE;
                                }
                        } else if (length == 12) {
                                if ((data[++index] == 'e') && (data[++index] == 'q')
@@ -3647,10 +3704,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                && (data[++index] == '_') && (data[++index] == 'o')
                                                && (data[++index] == 'n') && (data[++index] == 'c')
                                                && (data[++index] == 'e')) {
-                                       return TokenNamerequire_once;
+                                       return TokenName.REQUIRE_ONCE;
                                }
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 's':
                        // self static switch
                        switch (length) {
@@ -3658,90 +3715,92 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        // if ((data[++index] == 'e') && (data[++index] == 'l') &&
                        // (data[++index]
                        // == 'f')) {
-                       // return TokenNameself;
+                       // return TokenName.self;
                        // }
-                       // return TokenNameIdentifier;
+                       // return TokenName.IDENTIFIER;
                        case 6:
                                if (data[++index] == 't')
                                        if ((data[++index] == 'a') && (data[++index] == 't')
                                                        && (data[++index] == 'i') && (data[++index] == 'c')) {
-                                               return TokenNamestatic;
+                                               return TokenName.STATIC;
                                        } else
-                                               return TokenNameIdentifier;
+                                               return TokenName.IDENTIFIER;
                                else if ((data[index] == 'w') && (data[++index] == 'i')
                                                && (data[++index] == 't') && (data[++index] == 'c')
                                                && (data[++index] == 'h'))
-                                       return TokenNameswitch;
+                                       return TokenName.SWITCH;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 't':
                        // try true throw
                        switch (length) {
                        case 3:
                                if ((data[++index] == 'r') && (data[++index] == 'y'))
-                                       return TokenNametry;
+                                       return TokenName.TRY;
                                // case 4 :
                                // if ((data[++index] == 'r') && (data[++index] == 'u')
                                // && (data[++index] == 'e'))
-                               // return TokenNametrue;
+                               // return TokenName.true;
                                 else
-                                        return TokenNameIdentifier;
+                                        return TokenName.IDENTIFIER;
                        case 5:
                                if ((data[++index] == 'h') && (data[++index] == 'r')
                                                && (data[++index] == 'o') && (data[++index] == 'w'))
-                                       return TokenNamethrow;
+                                       return TokenName.THROW;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'u':
                        // use unset
                        switch (length) {
                        case 3:
                                if ((data[++index] == 's') && (data[++index] == 'e'))
-                                       return TokenNameuse;
+                                       return TokenName.USE;
+                               else
+                                       return TokenName.IDENTIFIER;
                        case 5:
                                if ((data[++index] == 'n') && (data[++index] == 's')
                                                && (data[++index] == 'e') && (data[++index] == 't'))
-                                       return TokenNameunset;
+                                       return TokenName.UNSET;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'v':
                        // var
                        switch (length) {
                        case 3:
                                if ((data[++index] == 'a') && (data[++index] == 'r'))
-                                       return TokenNamevar;
+                                       return TokenName.VAR;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'w':
                        // while
                        switch (length) {
                        case 5:
                                if ((data[++index] == 'h') && (data[++index] == 'i')
                                                && (data[++index] == 'l') && (data[++index] == 'e'))
-                                       return TokenNamewhile;
+                                       return TokenName.WHILE;
                                // case 6:if ( (data[++index] =='i') && (data[++index]=='d') &&
                                // (data[++index]=='e') && (data[++index]=='f')&&
                                // (data[++index]=='p'))
-                               // return TokenNamewidefp ;
+                               // return TokenName.widefp ;
                                // else
-                               // return TokenNameIdentifier;
+                               // return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                case 'x':
                        // xor
                        switch (length) {
                        case 3:
                                if ((data[++index] == 'o') && (data[++index] == 'r'))
-                                       return TokenNamexor;
+                                       return TokenName.OP_XOR_OLD;
                                else
-                                       return TokenNameIdentifier;
+                                       return TokenName.IDENTIFIER;
                        }
-                       return TokenNameIdentifier;
+                       return TokenName.IDENTIFIER;
                }
-               return TokenNameIdentifier;
+               return TokenName.IDENTIFIER;
        }
 
-       public int scanNumber(boolean dotPrefix) throws InvalidInputException {
+       public TokenName scanNumber(boolean dotPrefix) throws InvalidInputException {
                // when entering this method the currentCharacter is the firt
                // digit of the number , i.e. it may be preceeded by a . when
                // dotPrefix is true
@@ -3767,9 +3826,9 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                }
                                ;
                                // if (getNextChar('l', 'L') >= 0)
-                               // return TokenNameLongLiteral;
+                               // return TokenName.LongLiteral;
                                // else
-                               return TokenNameIntegerLiteral;
+                               return TokenName.INTEGERLITERAL;
                        }
                        // there is x or X in the number
                        // potential octal ! ... some one may write 000099.0 ! thus 00100 <
@@ -3780,14 +3839,14 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                }
                                ;
                                // if (getNextChar('l', 'L') >= 0) {
-                               // return TokenNameLongLiteral;
+                               // return TokenName.LongLiteral;
                                // }
                                //
                                // if (getNextChar('f', 'F') >= 0) {
-                               // return TokenNameFloatingPointLiteral;
+                               // return TokenName.FloatingPointLiteral;
                                // }
                                if (getNextChar('d', 'D') >= 0) {
-                                       return TokenNameDoubleLiteral;
+                                       return TokenName.DOUBLELITERAL;
                                } else { // make the distinction between octal and float ....
                                        if (getNextChar('.')) { // bingo ! ....
                                                while (getNextCharAsDigit()) {
@@ -3830,11 +3889,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        ;
                                                }
                                                // if (getNextChar('f', 'F') >= 0)
-                                               // return TokenNameFloatingPointLiteral;
+                                               // return TokenName.FloatingPointLiteral;
                                                getNextChar('d', 'D'); // jump over potential d or D
-                                               return TokenNameDoubleLiteral;
+                                               return TokenName.DOUBLELITERAL;
                                        } else {
-                                               return TokenNameIntegerLiteral;
+                                               return TokenName.INTEGERLITERAL;
                                        }
                                }
                        } else {
@@ -3845,7 +3904,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                }
                ;
                // if ((!dotPrefix) && (getNextChar('l', 'L') >= 0))
-               // return TokenNameLongLiteral;
+               // return TokenName.LongLiteral;
                if ((!dotPrefix) && (getNextChar('.'))) { // decimal part that can be
                                                                                                        // empty
                        while (getNextCharAsDigit()) {
@@ -3888,16 +3947,16 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        ;
                }
                if (getNextChar('d', 'D') >= 0)
-                       return TokenNameDoubleLiteral;
+                       return TokenName.DOUBLELITERAL;
                // if (getNextChar('f', 'F') >= 0)
-               // return TokenNameFloatingPointLiteral;
+               // return TokenName.FloatingPointLiteral;
                // the long flag has been tested before
-               return floating ? TokenNameDoubleLiteral : TokenNameIntegerLiteral;
+               return floating ? TokenName.DOUBLELITERAL : TokenName.INTEGERLITERAL;
        }
 
        /**
         * Search the line number corresponding to a specific position
-        * 
+        *
         */
        public final int getLineNumber(int position) {
                if (lineEnds == null)
@@ -3943,7 +4002,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                initialPosition = currentPosition = 0;
                containsAssertKeyword = false;
                withoutUnicodeBuffer = new char[this.source.length];
-               fFillerToken = TokenNameEOF;
+               fFillerToken = TokenName.EOF;
                // encapsedStringStack = new Stack();
        }
 
@@ -3972,300 +4031,302 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                + new String(end);
        }
 
-       public final String toStringAction(int act) {
+       public final String toStringAction(TokenName act) {
                switch (act) {
-               case TokenNameERROR:
+               case ERROR:
                        return "ScannerError"; // + new String(getCurrentTokenSource()) +
                                                                        // ")";
                        // //$NON-NLS-1$
-               case TokenNameINLINE_HTML:
+               case INLINE_HTML:
                        return "Inline-HTML(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameECHO_INVISIBLE:
+               case ECHO_INVISIBLE:
                        // 0-length token
                        return "";
-               case TokenNameIdentifier:
+               case IDENTIFIER:
                        return "Identifier(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameVariable:
+               case VARIABLE:
                        return "Variable(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameabstract:
+               case ABSTRACT:
                        return "abstract"; //$NON-NLS-1$
-               case TokenNameand:
+               case OP_AND_OLD:
                        return "AND"; //$NON-NLS-1$
-               case TokenNamearray:
+               case ARRAY:
                        return "array"; //$NON-NLS-1$
-               case TokenNameas:
+               case AS:
                        return "as"; //$NON-NLS-1$
-               case TokenNamebreak:
+               case BREAK:
                        return "break"; //$NON-NLS-1$
-               case TokenNamecase:
+               case CASE:
                        return "case"; //$NON-NLS-1$
-               case TokenNameclass:
+               case CLASS:
                        return "class"; //$NON-NLS-1$
-               case TokenNamecatch:
+               case CATCH:
                        return "catch"; //$NON-NLS-1$
-               case TokenNameclone:
+               case CLONE:
                        //$NON-NLS-1$
                        return "clone";
-               case TokenNameconst:
+               case CONST:
                        //$NON-NLS-1$
                        return "const";
-               case TokenNamecontinue:
+               case CONTINUE:
                        return "continue"; //$NON-NLS-1$
-               case TokenNamedefault:
+               case DEFAULT:
                        return "default"; //$NON-NLS-1$
-                       // case TokenNamedefine :
+                       // case define :
                        // return "define"; //$NON-NLS-1$
-               case TokenNamedo:
+               case DO:
                        return "do"; //$NON-NLS-1$
-               case TokenNameecho:
+               case ECHO:
                        return "echo"; //$NON-NLS-1$
-               case TokenNameelse:
+               case ELSE:
                        return "else"; //$NON-NLS-1$
-               case TokenNameelseif:
+               case ELSEIF:
                        return "elseif"; //$NON-NLS-1$
-               case TokenNameendfor:
+               case ENDFOR:
                        return "endfor"; //$NON-NLS-1$
-               case TokenNameendforeach:
+               case ENDFOREACH:
                        return "endforeach"; //$NON-NLS-1$
-               case TokenNameendif:
+               case ENDIF:
                        return "endif"; //$NON-NLS-1$
-               case TokenNameendswitch:
+               case ENDSWITCH:
                        return "endswitch"; //$NON-NLS-1$
-               case TokenNameendwhile:
+               case ENDWHILE:
                        return "endwhile"; //$NON-NLS-1$
-               case TokenNameexit:
+               case EXIT:
                        return "exit";
-               case TokenNameextends:
+               case EXTENDS:
                        return "extends"; //$NON-NLS-1$
-                       // case TokenNamefalse :
+                       // case false :
                        // return "false"; //$NON-NLS-1$
-               case TokenNamefinal:
+               case FINAL:
                        return "final"; //$NON-NLS-1$
-               case TokenNamefor:
+               case FOR:
                        return "for"; //$NON-NLS-1$
-               case TokenNameforeach:
+               case FOREACH:
                        return "foreach"; //$NON-NLS-1$
-               case TokenNamefunction:
+               case FUNCTION:
                        return "function"; //$NON-NLS-1$
-               case TokenNameglobal:
+               case GLOBAL:
                        return "global"; //$NON-NLS-1$
-               case TokenNameif:
+               case IF:
                        return "if"; //$NON-NLS-1$
-               case TokenNameimplements:
+               case IMPLEMENTS:
                        return "implements"; //$NON-NLS-1$
-               case TokenNameinclude:
+               case INCLUDE:
                        return "include"; //$NON-NLS-1$
-               case TokenNameinclude_once:
+               case INCLUDE_ONCE:
                        return "include_once"; //$NON-NLS-1$
-               case TokenNameinstanceof:
+               case INSTANCEOF:
                        return "instanceof"; //$NON-NLS-1$
-               case TokenNameinterface:
+               case INTERFACE:
                        return "interface"; //$NON-NLS-1$
-               case TokenNameisset:
+               case ISSET:
                        return "isset"; //$NON-NLS-1$
-               case TokenNamelist:
+               case LIST:
                        return "list"; //$NON-NLS-1$
-               case TokenNamenew:
+               case NEW:
                        return "new"; //$NON-NLS-1$
-                       // case TokenNamenull :
+                       // case null :
                        // return "null"; //$NON-NLS-1$
-               case TokenNameor:
+               case OP_OR_OLD:
                        return "OR"; //$NON-NLS-1$
-               case TokenNameprint:
+               case PRINT:
                        return "print"; //$NON-NLS-1$
-               case TokenNameprivate:
+               case PRIVATE:
                        return "private"; //$NON-NLS-1$
-               case TokenNameprotected:
+               case PROTECTED:
                        return "protected"; //$NON-NLS-1$
-               case TokenNamepublic:
+               case PUBLIC:
                        return "public"; //$NON-NLS-1$
-               case TokenNamerequire:
+               case REQUIRE:
                        return "require"; //$NON-NLS-1$
-               case TokenNamerequire_once:
+               case REQUIRE_ONCE:
                        return "require_once"; //$NON-NLS-1$
-               case TokenNamereturn:
+               case RETURN:
                        return "return"; //$NON-NLS-1$
-                       // case TokenNameself:
+                       // case self:
                        // return "self"; //$NON-NLS-1$
-               case TokenNamestatic:
+               case STATIC:
                        return "static"; //$NON-NLS-1$
-               case TokenNameswitch:
+               case SWITCH:
                        return "switch"; //$NON-NLS-1$
-                       // case TokenNametrue :
+                       // case true :
                        // return "true"; //$NON-NLS-1$
-               case TokenNameunset:
+               case UNSET:
                        return "unset"; //$NON-NLS-1$
-               case TokenNamevar:
+               case VAR:
                        return "var"; //$NON-NLS-1$
-               case TokenNamewhile:
+               case WHILE:
                        return "while"; //$NON-NLS-1$
-               case TokenNamexor:
+               case OP_XOR_OLD:
                        return "XOR"; //$NON-NLS-1$
-                       // case TokenNamethis :
+                       // case this :
                        // return "$this"; //$NON-NLS-1$
-               case TokenNameIntegerLiteral:
+               case INTEGERLITERAL:
                        return "Integer(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameDoubleLiteral:
+               case DOUBLELITERAL:
                        return "Double(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameStringDoubleQuote:
+               case STRINGDOUBLEQUOTE:
                        return "StringLiteral(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameStringSingleQuote:
+               case STRINGSINGLEQUOTE:
                        return "StringConstant(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameStringInterpolated:
+               case STRINGINTERPOLATED:
                        return "StringInterpolated(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameEncapsedString0:
+               case ENCAPSEDSTRING0:
                        return "`"; //$NON-NLS-1$
-                       // case TokenNameEncapsedString1:
+                       // case EncapsedString1:
                        // return "\'"; //$NON-NLS-1$
-                       // case TokenNameEncapsedString2:
+                       // case EncapsedString2:
                        // return "\""; //$NON-NLS-1$
-               case TokenNameSTRING:
+               case STRING:
                        return "STRING_DQ(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-               case TokenNameHEREDOC:
+               case HEREDOC:
                        return "HEREDOC(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
-               case TokenNamePLUS_PLUS:
+               case PLUS_PLUS:
                        return "++"; //$NON-NLS-1$
-               case TokenNameMINUS_MINUS:
+               case MINUS_MINUS:
                        return "--"; //$NON-NLS-1$
-               case TokenNameEQUAL_EQUAL:
+               case EQUAL_EQUAL:
                        return "=="; //$NON-NLS-1$
-               case TokenNameEQUAL_EQUAL_EQUAL:
+               case EQUAL_EQUAL_EQUAL:
                        return "==="; //$NON-NLS-1$
-               case TokenNameEQUAL_GREATER:
+               case EQUAL_GREATER:
                        return "=>"; //$NON-NLS-1$
-               case TokenNameLESS_EQUAL:
+               case LESS_EQUAL:
                        return "<="; //$NON-NLS-1$
-               case TokenNameGREATER_EQUAL:
+               case GREATER_EQUAL:
                        return ">="; //$NON-NLS-1$
-               case TokenNameNOT_EQUAL:
+               case NOT_EQUAL:
                        return "!="; //$NON-NLS-1$
-               case TokenNameNOT_EQUAL_EQUAL:
+               case NOT_EQUAL_EQUAL:
                        return "!=="; //$NON-NLS-1$
-               case TokenNameLEFT_SHIFT:
+               case LEFT_SHIFT:
                        return "<<"; //$NON-NLS-1$
-               case TokenNameRIGHT_SHIFT:
+               case RIGHT_SHIFT:
                        return ">>"; //$NON-NLS-1$
-               case TokenNamePLUS_EQUAL:
+               case PLUS_EQUAL:
                        return "+="; //$NON-NLS-1$
-               case TokenNameMINUS_EQUAL:
+               case MINUS_EQUAL:
                        return "-="; //$NON-NLS-1$
-               case TokenNameMULTIPLY_EQUAL:
+               case MULTIPLY_EQUAL:
                        return "*="; //$NON-NLS-1$
-               case TokenNameDIVIDE_EQUAL:
+               case DIVIDE_EQUAL:
                        return "/="; //$NON-NLS-1$
-               case TokenNameAND_EQUAL:
+               case AND_EQUAL:
                        return "&="; //$NON-NLS-1$
-               case TokenNameOR_EQUAL:
+               case OR_EQUAL:
                        return "|="; //$NON-NLS-1$
-               case TokenNameXOR_EQUAL:
+               case XOR_EQUAL:
                        return "^="; //$NON-NLS-1$
-               case TokenNameREMAINDER_EQUAL:
+               case REMAINDER_EQUAL:
                        return "%="; //$NON-NLS-1$
-               case TokenNameDOT_EQUAL:
+               case DOT_EQUAL:
                        return ".="; //$NON-NLS-1$
-               case TokenNameLEFT_SHIFT_EQUAL:
+               case LEFT_SHIFT_EQUAL:
                        return "<<="; //$NON-NLS-1$
-               case TokenNameRIGHT_SHIFT_EQUAL:
+               case RIGHT_SHIFT_EQUAL:
                        return ">>="; //$NON-NLS-1$
-               case TokenNameOR_OR:
+               case OR_OR:
                        return "||"; //$NON-NLS-1$
-               case TokenNameAND_AND:
+               case AND_AND:
                        return "&&"; //$NON-NLS-1$
-               case TokenNamePLUS:
+               case PLUS:
                        return "+"; //$NON-NLS-1$
-               case TokenNameMINUS:
+               case MINUS:
                        return "-"; //$NON-NLS-1$
-               case TokenNameMINUS_GREATER:
+               case MINUS_GREATER:
                        return "->";
-               case TokenNameNOT:
+               case NOT:
                        return "!"; //$NON-NLS-1$
-               case TokenNameREMAINDER:
+               case REMAINDER:
                        return "%"; //$NON-NLS-1$
-               case TokenNameXOR:
+               case OP_XOR:
                        return "^"; //$NON-NLS-1$
-               case TokenNameAND:
+               case OP_AND:
                        return "&"; //$NON-NLS-1$
-               case TokenNameMULTIPLY:
+               case MULTIPLY:
                        return "*"; //$NON-NLS-1$
-               case TokenNameOR:
+               case OP_OR:
                        return "|"; //$NON-NLS-1$
-               case TokenNameTWIDDLE:
+               case TWIDDLE:
                        return "~"; //$NON-NLS-1$
-               case TokenNameTWIDDLE_EQUAL:
+               case TWIDDLE_EQUAL:
                        return "~="; //$NON-NLS-1$
-               case TokenNameDIVIDE:
+               case DIVIDE:
                        return "/"; //$NON-NLS-1$
-               case TokenNameGREATER:
+               case GREATER:
                        return ">"; //$NON-NLS-1$
-               case TokenNameLESS:
+               case LESS:
                        return "<"; //$NON-NLS-1$
-               case TokenNameLPAREN:
+               case LPAREN:
                        return "("; //$NON-NLS-1$
-               case TokenNameRPAREN:
+               case RPAREN:
                        return ")"; //$NON-NLS-1$
-               case TokenNameLBRACE:
+               case LBRACE:
                        return "{"; //$NON-NLS-1$
-               case TokenNameRBRACE:
+               case RBRACE:
                        return "}"; //$NON-NLS-1$
-               case TokenNameLBRACKET:
+               case LBRACKET:
                        return "["; //$NON-NLS-1$
-               case TokenNameRBRACKET:
+               case RBRACKET:
                        return "]"; //$NON-NLS-1$
-               case TokenNameSEMICOLON:
+               case SEMICOLON:
                        return ";"; //$NON-NLS-1$
-               case TokenNameQUESTION:
+               case QUESTION:
                        return "?"; //$NON-NLS-1$
-               case TokenNameCOLON:
+               case COLON:
                        return ":"; //$NON-NLS-1$
-               case TokenNameCOMMA:
+               case COMMA:
                        return ","; //$NON-NLS-1$
-               case TokenNameDOT:
+               case DOT:
                        return "."; //$NON-NLS-1$
-               case TokenNameEQUAL:
+               case EQUAL:
                        return "="; //$NON-NLS-1$
-               case TokenNameAT:
+               case OP_AT:
                        return "@";
-               case TokenNameDOLLAR:
+               case DOLLAR:
                        return "$";
-               case TokenNameDOLLAR_LBRACE:
+               case DOLLAR_LBRACE:
                        return "${";
-               case TokenNameLBRACE_DOLLAR:
+               case LBRACE_DOLLAR:
                        return "{$";
-               case TokenNameEOF:
+               case EOF:
                        return "EOF"; //$NON-NLS-1$
-               case TokenNameWHITESPACE:
+               case WHITESPACE:
                        return "WHITESPACE(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
-               case TokenNameCOMMENT_LINE:
+               case COMMENT_LINE:
                        return "COMMENT_LINE(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
-               case TokenNameCOMMENT_BLOCK:
+               case COMMENT_BLOCK:
                        return "COMMENT_BLOCK(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
-               case TokenNameCOMMENT_PHPDOC:
+               case COMMENT_PHPDOC:
                        return "COMMENT_PHPDOC(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
-                       // case TokenNameHTML :
+                       // case HTML :
                        // return "HTML(" + new String(getCurrentTokenSource()) + ")";
                        // //$NON-NLS-1$
-               case TokenNameFILE:
+               case FILE:
                        return "__FILE__"; //$NON-NLS-1$
-               case TokenNameLINE:
+               case LINE:
                        return "__LINE__"; //$NON-NLS-1$
-               case TokenNameCLASS_C:
+               case CLASS_C:
                        return "__CLASS__"; //$NON-NLS-1$
-               case TokenNameMETHOD_C:
+               case METHOD_C:
                        return "__METHOD__"; //$NON-NLS-1$
-               case TokenNameFUNC_C:
+               case FUNC_C:
                        return "__FUNCTION__"; //$NON-NLS-1
-               case TokenNameboolCAST:
+               case BOOLCAST:
                        return "( bool )"; //$NON-NLS-1$
-               case TokenNameintCAST:
+               case INTCAST:
                        return "( int )"; //$NON-NLS-1$
-               case TokenNamedoubleCAST:
+               case DOUBLECAST:
                        return "( double )"; //$NON-NLS-1$
-               case TokenNameobjectCAST:
+               case OBJECTCAST:
                        return "( object )"; //$NON-NLS-1$
-               case TokenNamestringCAST:
+               case STRINGCAST:
                        return "( string )"; //$NON-NLS-1$
+        case NAMESPACE:
+            return "( namespace )"; //$NON-NLS-1$
                default:
-                       return "not-a-token(" + (new Integer(act)) + ") " + new String(getCurrentTokenSource()); //$NON-NLS-1$
+                       return "token not handled (" + (act.toString ()) + ") " + new String(getCurrentTokenSource()); //$NON-NLS-1$
                }
        }
 
@@ -4695,4 +4756,5 @@ public class Scanner implements IScanner, ITerminalSymbols {
        // this.foundTaskMessages[i] = message;
        // }
        // }
-}
\ No newline at end of file
+}
+