Fix bug #1385272: Improved version for "Parsing of short open tags not fully compatib...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 2d17647..f79075c 100644 (file)
@@ -456,10 +456,10 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                                }
                                                if (token == TokenNameif || token == TokenNameswitch || token == TokenNamefor || token == TokenNamewhile
                                                                || token == TokenNamedo || token == TokenNameforeach || token == TokenNamecontinue || token == TokenNamebreak
-                                                               || token == TokenNamereturn || token == TokenNameexit || token == TokenNameecho || token == TokenNameglobal
-                                                               || token == TokenNamestatic || token == TokenNameunset || token == TokenNamefunction || token == TokenNamedeclare
-                                                               || token == TokenNametry || token == TokenNamecatch || token == TokenNamethrow || token == TokenNamefinal
-                                                               || token == TokenNameabstract || token == TokenNameclass || token == TokenNameinterface) {
+                                                               || token == TokenNamereturn || token == TokenNameexit || token == TokenNameecho || token == TokenNameECHO_INVISIBLE
+                                                               || token == TokenNameglobal || token == TokenNamestatic || token == TokenNameunset || token == TokenNamefunction
+                                                               || token == TokenNamedeclare || token == TokenNametry || token == TokenNamecatch || token == TokenNamethrow
+                                                               || token == TokenNamefinal || token == TokenNameabstract || token == TokenNameclass || token == TokenNameinterface) {
                                                        break;
                                                }
                                                // System.out.println(scanner.toStringAction(token));
@@ -751,6 +751,23 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                getNextToken();
                        }
                        return statement;
+               } else if (token == TokenNameECHO_INVISIBLE) {
+                       // 0-length token directly after PHP short tag <?=
+                       getNextToken();
+                       expressionList();
+                       if (token == TokenNameSEMICOLON) {
+                               getNextToken();
+                               if (token != TokenNameINLINE_HTML) {
+                                       // TODO should this become a configurable warning?
+                                       reportSyntaxError("Probably '?>' expected  after PHP short tag expression (only the first expression will be echoed).");
+                               }
+                       } else {
+                               if (token != TokenNameINLINE_HTML) {
+                                       throwSyntaxError("';' expected after PHP short tag '<?=' expression.");
+                               }
+                               getNextToken();
+                       }
+                       return statement;
                } else if (token == TokenNameINLINE_HTML) {
                        getNextToken();
                        return statement;
@@ -1726,7 +1743,8 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                if (token == TokenNameCOLON || token == TokenNameSEMICOLON) {
                                        getNextToken();
                                        if (token == TokenNameRBRACE) {
-                                               // empty case; assumes that the '}' token belongs to the wrapping switch statement - #1371992
+                                               // empty case; assumes that the '}' token belongs to the wrapping
+                                               // switch statement - #1371992
                                                break;
                                        }
                                        if (token == TokenNamecase || token == TokenNamedefault) {
@@ -1756,7 +1774,8 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                if (token == TokenNameCOLON || token == TokenNameSEMICOLON) {
                                        getNextToken();
                                        if (token == TokenNameRBRACE) {
-                                               // empty default case; ; assumes that the '}' token belongs to the wrapping switch statement - #1371992
+                                               // empty default case; ; assumes that the '}' token belongs to the
+                                               // wrapping switch statement - #1371992
                                                break;
                                        }
                                        if (token != TokenNamecase) {
@@ -3128,7 +3147,8 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                }
                                getNextToken();
                        } else if (token == TokenNameLBRACKET) {
-                               // To remove "ref = null;" here, is probably better than the patch commented in #1368081 - axelcl
+                               // To remove "ref = null;" here, is probably better than the patch
+                               // commented in #1368081 - axelcl
                                getNextToken();
                                if (token != TokenNameRBRACKET) {
                                        expr();