Avoid "uninitialized variable" message after new keyword
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 1f05db8..4dcd0f8 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);
@@ -2784,7 +2787,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 +3013,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 +3103,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 +3118,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                        while (token == TokenNameDOLLAR) {
                                getNextToken();
                        }
-                       reference_variable(false, false);
+                       reference_variable(lefthandside, false);
                }
                return ref;
        }
@@ -3422,26 +3423,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();