fix for http://sourceforge.net/tracker/index.php?func=detail&aid=1413064&group_id...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index 803f878..9782a3e 100644 (file)
@@ -1216,11 +1216,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
 
        public void consumeStringLiteral() throws InvalidInputException {
                try {
-                       boolean openDollarBrace = false;
+                       int openDollarBrace = 0;
                        // consume next character
                        unicodeAsBackSlash = false;
                        currentCharacter = source[currentPosition++];
-                       while (currentCharacter != '"' || openDollarBrace) {
+                       while (currentCharacter != '"' || openDollarBrace>0) {
                                /** ** in PHP \r and \n are valid in string literals *** */
                                if (currentCharacter == '\\') {
                                        int escapeSize = currentPosition;
@@ -1242,11 +1242,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                }
                                        }
                                } else if (currentCharacter == '$' && source[currentPosition] == '{') {
-                                       openDollarBrace = true;
+                                       openDollarBrace++;
                                } else if (currentCharacter == '{' && source[currentPosition] == '$') {
-                                       openDollarBrace = true;
+                                       openDollarBrace++;
                                } else if (currentCharacter == '}') {
-                                       openDollarBrace = false;
+                                       openDollarBrace--;
                                } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
                                        if (recordLineSeparator) {
                                                pushLineSeparator();
@@ -1846,17 +1846,25 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                                        return TokenNameINLINE_HTML;
                                                                }
                                                        } else {
-                                                               phpMode = true;
+                                                               boolean foundXML=false;
+                                                               if (getNextChar('X','x')>=0) {
+                                                                       if (getNextChar('M','m')>=0) {
+                                                                               if (getNextChar('L','l')>=0) {
+                                                                                       foundXML=true;
+                                                                               }
+                                                                       }
+                                                               }
+                                                               if (!foundXML) {
+                                                                       phpMode = true;
+                                                               }
                                                                if (phpShortTag) {
                                                                        fFillerToken = TokenNameECHO_INVISIBLE;
                                                                }
                                                                return TokenNameINLINE_HTML;
                                                        }
                                                } else {
-                                                       int test = getNextChar('H', 'h');
-                                                       if (test >= 0) {
-                                                               test = getNextChar('P', 'p');
-                                                               if (test >= 0) {
+                                                       if (getNextChar('H', 'h') >= 0) {
+                                                               if (getNextChar('P', 'p') >= 0) {
                                                                        // <?PHP <?php
                                                                        if (ignorePHPOneLiner) {
                                                                                if (lookAheadLinePHPTag() == TokenNameINLINE_HTML) {