Fix bug #1385272: Parsing of short open tags not fully compatible to PHP parse
authoraxelcl <axelcl>
Mon, 19 Dec 2005 20:34:36 +0000 (20:34 +0000)
committeraxelcl <axelcl>
Mon, 19 Dec 2005 20:34:36 +0000 (20:34 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java

index 1a3da1e..3c7c661 100644 (file)
@@ -745,26 +745,14 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                        if (token == TokenNameSEMICOLON) {
                                getNextToken();
                        } else {
-                               if (token != TokenNameINLINE_HTML ) {
+                               if (token != TokenNameINLINE_HTML) {
                                        throwSyntaxError("';' expected after 'echo' statement.");
                                }
                                getNextToken();
                        }
                        return statement;
                } else if (token == TokenNameINLINE_HTML) {
-//                     if (scanner.phpExpressionTag) {
-//                             // start of <?= ... ?> block
-//                             getNextToken();
-//                             expr();
-//                             if (token == TokenNameSEMICOLON) {
-//                                     getNextToken();
-//                             }
-//                             if (token != TokenNameINLINE_HTML) {
-//                                     throwSyntaxError("Missing '?>' for open PHP expression block ('<?=').");
-//                             }
-//                     } else {
-                               getNextToken();
-//                     }
+                       getNextToken();
                        return statement;
                } else if (token == TokenNameglobal) {
                        getNextToken();
index 30e835c..a1e5351 100644 (file)
@@ -39,10 +39,13 @@ public class Scanner implements IScanner, ITerminalSymbols {
 
        public boolean phpMode = false;
 
-//     public boolean phpExpressionTag = false;
-
+       /**
+        * This token is set to TokenNameecho if a short tag block begins (i.e. &gt;?= ... )
+        * Directly after the &quot;=&quot; character the getNextToken() method returns TokenNameINLINE_HTML
+        * In the next call to the getNextToken() method the value of fFillerToken (==TokenNameecho) is returned
+        *
+        */
        int fFillerToken = TokenNameEOF;
-       // public Stack encapsedStringStack = null;
 
        public char currentCharacter;
 
@@ -1292,10 +1295,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
                if (!phpMode) {
                        return getInlinedHTMLToken(currentPosition);
                } else {
-                       if (fFillerToken!=TokenNameEOF) {
+                       if (fFillerToken != TokenNameEOF) {
                                int tempToken;
                                tempToken = fFillerToken;
-                               fFillerToken=TokenNameEOF;
+                               fFillerToken = TokenNameEOF;
                                return tempToken;
                        }
                        this.wasAcr = false;
@@ -1956,7 +1959,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
         * @throws InvalidInputException
         */
        private int getInlinedHTMLToken(int start) throws InvalidInputException {
-               boolean phpShortTag = false;  // true, if <?= detected
+               boolean phpShortTag = false; // true, if <?= detected
                if (currentPosition > source.length) {
                        currentPosition = source.length;
                        return TokenNameEOF;
@@ -3545,11 +3548,12 @@ public class Scanner implements IScanner, ITerminalSymbols {
                case 's':
                        // self static switch
                        switch (length) {
-//                     case 4:
-//                             if ((data[++index] == 'e') && (data[++index] == 'l') && (data[++index] == 'f')) {
-//                                     return TokenNameself;
-//                             }
-//                             return TokenNameIdentifier;
+                       // case 4:
+                       // if ((data[++index] == 'e') && (data[++index] == 'l') && (data[++index]
+                       // == 'f')) {
+                       // return TokenNameself;
+                       // }
+                       // return TokenNameIdentifier;
                        case 6:
                                if (data[++index] == 't')
                                        if ((data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'i') && (data[++index] == 'c')) {
@@ -3843,6 +3847,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                initialPosition = currentPosition = 0;
                containsAssertKeyword = false;
                withoutUnicodeBuffer = new char[this.source.length];
+               fFillerToken = TokenNameEOF;
                // encapsedStringStack = new Stack();
        }
 
@@ -3977,8 +3982,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        return "require_once"; //$NON-NLS-1$
                case TokenNamereturn:
                        return "return"; //$NON-NLS-1$
-//             case TokenNameself:
-//                     return "self"; //$NON-NLS-1$
+                       // case TokenNameself:
+                       // return "self"; //$NON-NLS-1$
                case TokenNamestatic:
                        return "static"; //$NON-NLS-1$
                case TokenNameswitch: