1) Fixed issue #347: Syntax highlight doesn't like apostrophe in heredoc.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index 20039eb..56a9b14 100644 (file)
@@ -1536,73 +1536,92 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                if (getNextChar('='))
                                                        return TokenName.REMAINDER_EQUAL;
                                                return TokenName.REMAINDER;
+                                               
                                        case '<': {
                                                int oldPosition = currentPosition;
+                                               
                                                try {
                                                        currentCharacter = source[currentPosition++];
                                                } catch (IndexOutOfBoundsException e) {
                                                        currentPosition = oldPosition;
                                                        return TokenName.LESS;
                                                }
+                                               
                                                switch (currentCharacter) {
-                                               case '=':
-                                                       return TokenName.LESS_EQUAL;
-                                               case '>':
-                                                       return TokenName.NOT_EQUAL;
-                                               case '<':
-                                                       if (getNextChar('='))
-                                                               return TokenName.LEFT_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 TokenName.ERROR;
+                                                       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 TokenName.HEREDOC;
+                                                                       } while (true);
+                                                                       
+                                                                       return TokenName.HEREDOC;
+                                                               }
+                                                               return TokenName.LEFT_SHIFT;
                                                        }
-                                                       return TokenName.LEFT_SHIFT;
+                                                       currentPosition = oldPosition;
+                                                       return TokenName.LESS;
                                                }
-                                               currentPosition = oldPosition;
-                                               return TokenName.LESS;
-                                       }
+                                       
                                        case '>': {
                                                int test;
                                                if ((test = getNextChar('=', '>')) == 0)