Fix bug #1385272: Parsing of short open tags not fully compatible to PHP parse
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 1f05db8..3c7c661 100644 (file)
@@ -422,6 +422,9 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                        try {
                                statement = statement();
                                blockStatements.add(statement);
+                               if (token == TokenNameEOF) {
+                                       return null;
+                               }
                                if (branchStatement && statement != null) {
                                        // reportSyntaxError("Unreachable code", statement.sourceStart,
                                        // statement.sourceEnd);
@@ -749,32 +752,8 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                        }
                        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 == TokenNameprint) {
-                       // getNextToken();
-                       // expression();
-                       // if (token == TokenNameSEMICOLON) {
-                       // getNextToken();
-                       // } else {
-                       // if (token != TokenNameStopPHP) {
-                       // throwSyntaxError("';' expected after 'print' statement.");
-                       // }
-                       // getNextToken();
-                       // }
-                       // return;
                } else if (token == TokenNameglobal) {
                        getNextToken();
                        global_var_list();
@@ -2784,7 +2763,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                if (Scanner.TRACE) {
                        System.out.println("TRACE: dynamic_class_name_reference()");
                }
-               base_variable();
+               base_variable(true);
                if (token == TokenNameMINUS_GREATER) {
                        getNextToken();
                        object_property();
@@ -3010,26 +2989,24 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                        }
                                }
                        }
-                       // TODO is this ok ?
-                       return ref;
-                       // throwSyntaxError("'(' expected in function call.");
-               }
-               getNextToken();
-               if (token == TokenNameRPAREN) {
+               } else {
                        getNextToken();
-                       return ref;
-               }
-               non_empty_function_call_parameter_list();
-               if (token != TokenNameRPAREN) {
-                       String functionName;
-                       if (ident == null) {
-                               functionName = new String(" ");
-                       } else {
-                               functionName = new String(ident);
+                       if (token == TokenNameRPAREN) {
+                               getNextToken();
+                               return ref;
+                       }
+                       non_empty_function_call_parameter_list();
+                       if (token != TokenNameRPAREN) {
+                               String functionName;
+                               if (ident == null) {
+                                       functionName = new String(" ");
+                               } else {
+                                       functionName = new String(ident);
+                               }
+                               throwSyntaxError("')' expected in function call (" + functionName + ").");
                        }
-                       throwSyntaxError("')' expected in function call (" + functionName + ").");
+                       getNextToken();
                }
-               getNextToken();
                return ref;
        }
 
@@ -3102,7 +3079,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                return function_call(lefthandside, ignoreVar);
        }
 
-       private Expression base_variable() {
+       private Expression base_variable(boolean lefthandside) {
                // base_variable:
                // reference_variable
                // | simple_indirect_reference reference_variable
@@ -3117,7 +3094,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                        while (token == TokenNameDOLLAR) {
                                getNextToken();
                        }
-                       reference_variable(false, false);
+                       reference_variable(lefthandside, false);
                }
                return ref;
        }
@@ -3422,26 +3399,28 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                }
                        }
                        // TODO is this ok ?
-                       return ref;
+                       // return ref;
                        // throwSyntaxError("'(' expected in function call.");
-               }
-               getNextToken();
-               if (token == TokenNameRPAREN) {
+               } else {
                        getNextToken();
-                       return ref;
-               }
-               non_empty_function_call_parameter_list();
-               if (token != TokenNameRPAREN) {
-                       String functionName;
-                       if (ident == null) {
-                               functionName = new String(" ");
+
+                       if (token == TokenNameRPAREN) {
+                               getNextToken();
+                               ref = null;
                        } else {
-                               functionName = new String(ident);
+                               non_empty_function_call_parameter_list();
+                               if (token != TokenNameRPAREN) {
+                                       String functionName;
+                                       if (ident == null) {
+                                               functionName = new String(" ");
+                                       } else {
+                                               functionName = new String(ident);
+                                       }
+                                       throwSyntaxError("')' expected in function call (" + functionName + ").");
+                               }
+                               getNextToken();
                        }
-                       throwSyntaxError("')' expected in function call (" + functionName + ").");
                }
-               getNextToken();
-
                if (token == TokenNameMINUS_GREATER) {
                        ref = null;
                        getNextToken();