misc parser fixes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 939f999..aec5e9f 100644 (file)
@@ -21,7 +21,7 @@ import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
 import net.sourceforge.phpdt.internal.compiler.util.Util;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
 import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference;
@@ -1440,7 +1440,7 @@ public class Parser //extends PHPParserSuperclass
     if (astPtr == 0) {
       compilationUnit.types.add(methodDecl);
     } else {
-      AstNode node = astStack[astPtr];
+      ASTNode node = astStack[astPtr];
       if (node instanceof TypeDeclaration) {
         TypeDeclaration typeDecl = ((TypeDeclaration) node);
         if (typeDecl.methods == null) {
@@ -3092,16 +3092,29 @@ public class Parser //extends PHPParserSuperclass
             //            } else {
             expr();
             if (token != TokenNameRBRACKET) {
-              throwSyntaxError("']' expected after '{$'.");
+              throwSyntaxError("']' expected.");
             }
             getNextToken();
             //            }
           } else if (token == TokenNameMINUS_GREATER) {
             getNextToken();
-            if (token != TokenNameIdentifier) {
-              throwSyntaxError("String token expected.");
+            if (token != TokenNameIdentifier &&
+                token != TokenNameVariable) {
+              throwSyntaxError("String or Variable token expected.");
             }
             getNextToken();
+            if (token == TokenNameLBRACKET) {
+              getNextToken();
+              //            if (token == TokenNameRBRACKET) {
+              //              getNextToken();
+              //            } else {
+              expr();
+              if (token != TokenNameRBRACKET) {
+                throwSyntaxError("']' expected after '${'.");
+              }
+              getNextToken();
+              //            }
+            }
           }
           //          if (token != TokenNameRBRACE) {
           //            throwSyntaxError("'}' expected after '{$'.");
@@ -3544,10 +3557,10 @@ public class Parser //extends PHPParserSuperclass
   //ast stack
   final static int AstStackIncrement = 100;
   protected int astPtr;
-  protected AstNode[] astStack = new AstNode[AstStackIncrement];
+  protected ASTNode[] astStack = new ASTNode[AstStackIncrement];
   protected int astLengthPtr;
   protected int[] astLengthStack;
-  AstNode[] noAstNodes = new AstNode[AstStackIncrement];
+  ASTNode[] noAstNodes = new ASTNode[AstStackIncrement];
   public CompilationUnitDeclaration compilationUnit; /*
                                                       * the result from parse()
                                                       */
@@ -3974,7 +3987,7 @@ public class Parser //extends PHPParserSuperclass
       astLengthStack[astLengthPtr] = pos;
     }
   }
-  protected void pushOnAstStack(AstNode node) {
+  protected void pushOnAstStack(ASTNode node) {
     /*
      * add a new obj on top of the ast stack
      */
@@ -3982,8 +3995,8 @@ public class Parser //extends PHPParserSuperclass
       astStack[++astPtr] = node;
     } catch (IndexOutOfBoundsException e) {
       int oldStackLength = astStack.length;
-      AstNode[] oldStack = astStack;
-      astStack = new AstNode[oldStackLength + AstStackIncrement];
+      ASTNode[] oldStack = astStack;
+      astStack = new ASTNode[oldStackLength + AstStackIncrement];
       System.arraycopy(oldStack, 0, astStack, 0, oldStackLength);
       astPtr = oldStackLength;
       astStack[astPtr] = node;