*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / PHPParser.jj
index abf9f51..e411485 100644 (file)
@@ -37,6 +37,7 @@ import java.text.MessageFormat;
 import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpdt.internal.compiler.parser.*;
+import net.sourceforge.phpdt.internal.compiler.ast.*;
 
 /**
  * A new php parser.
@@ -68,6 +69,13 @@ public final class PHPParser extends PHPParserSuperclass {
   private static int errorStart = -1;
   private static int errorEnd = -1;
 
+       //ast stack
+       private final static int AstStackIncrement = 100;
+       /** The stack of node. */
+  private static AstNode[] astStack;
+  /** The cursor in expression stack. */
+       private static int expressionPtr;
+
   public final void setFileToParse(final IFile fileToParse) {
     this.fileToParse = fileToParse;
   }
@@ -87,6 +95,7 @@ public final class PHPParser extends PHPParserSuperclass {
       jj_input_stream = new SimpleCharStream(stream, 1, 1);
     }
     ReInit(new StringReader(strEval));
+    astStack = new AstNode[AstStackIncrement];
     phpTest();
   }
 
@@ -97,6 +106,7 @@ public final class PHPParser extends PHPParserSuperclass {
         jj_input_stream = new SimpleCharStream(stream, 1, 1);
       }
       ReInit(stream);
+      astStack = new AstNode[AstStackIncrement];
       phpFile();
     } catch (FileNotFoundException e) {
       e.printStackTrace();  //To change body of catch statement use Options | File Templates.
@@ -109,6 +119,7 @@ public final class PHPParser extends PHPParserSuperclass {
       jj_input_stream = new SimpleCharStream(stream, 1, 1);
     }
     ReInit(stream);
+    astStack = new AstNode[AstStackIncrement];
     phpFile();
   }
 
@@ -120,6 +131,7 @@ public final class PHPParser extends PHPParserSuperclass {
       jj_input_stream = new SimpleCharStream(stream, 1, 1);
     }
     ReInit(stream);
+    astStack = new AstNode[AstStackIncrement];
     try {
       parse();
     } catch (ParseException e) {
@@ -244,6 +256,7 @@ public final class PHPParser extends PHPParserSuperclass {
       jj_input_stream = new SimpleCharStream(stream, 1, 1);
     }
     ReInit(stream);
+    astStack = new AstNode[AstStackIncrement];
     try {
       parse();
     } catch (ParseException e) {
@@ -273,7 +286,7 @@ public final class PHPParser extends PHPParserSuperclass {
     }
   }
 
-  public static final void parse() throws ParseException {
+  private static final void parse() throws ParseException {
          phpFile();
   }
 }
@@ -2080,7 +2093,18 @@ void SwitchStatement() :
     errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
-  Expression()
+  try {
+    Expression()
+  } catch (ParseException e) {
+    if (errorMessage != null) {
+      throw e;
+    }
+    errorMessage = "expression expected";
+    errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
+    throw e;
+  }
   try {
     <RPAREN>
   } catch (ParseException e) {