*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / PHPParser.jj
index 1e7e5a2..530693d 100644 (file)
@@ -40,6 +40,7 @@ import net.sourceforge.phpdt.internal.compiler.ast.*;
 import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren;
 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
 import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo;
+import junit.framework.Assert;
 
 /**
  * A new php parser.
@@ -151,7 +152,7 @@ public final class PHPParser extends PHPParserSuperclass {
   private static void processParseException(final ParseException e) {
     if (PARSER_DEBUG) {
       e.printStackTrace();
-      return;
+      Assert.assertTrue(false);
     }
     if (errorMessage == null) {
       PHPeclipsePlugin.log(e);
@@ -233,7 +234,7 @@ public final class PHPParser extends PHPParserSuperclass {
     }
   }
 
-  public final void parse(final String s) throws CoreException {
+  public final void parse(final String s) {
     final StringReader stream = new StringReader(s);
     if (jj_input_stream == null) {
       jj_input_stream = new SimpleCharStream(stream, 1, 1);
@@ -791,6 +792,7 @@ FieldDeclaration FieldDeclaration() :
 
 /**
  * a strict variable declarator : there cannot be a suffix here.
+ * It will be used by fields and formal parameters
  */
 VariableDeclaration VariableDeclaratorNoSuffix() :
 {
@@ -827,6 +829,9 @@ VariableDeclaration VariableDeclaratorNoSuffix() :
   }
 }
 
+/**
+ * this will be used by static statement
+ */
 VariableDeclaration VariableDeclarator() :
 {
   final String varName;
@@ -1192,7 +1197,7 @@ Expression Expression() :
   [
     assignOperator = AssignmentOperator()
     try {
-      initializer = ConditionalExpression()
+      initializer = Expression()
     } catch (ParseException e) {
       if (errorMessage != null) {
         throw e;
@@ -1234,10 +1239,7 @@ Expression ExpressionWBang() :
 
 Expression ExpressionNoBang() :
 {
-  Expression expr = null;
-  int assignOperator = -1;
-  String var;
-  final int pos = SimpleCharStream.getPosition();
+  Expression expr;
 }
 {
   expr = PrintExpression()   {return expr;}
@@ -1492,19 +1494,27 @@ Expression UnaryExpression() :
   <BIT_AND> expr = UnaryExpressionNoPrefix()
   {return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);}
 |
-  expr = AtUnaryExpression() {return expr;}
+  expr = AtNotUnaryExpression() {return expr;}
 }
 
-Expression AtUnaryExpression() :
+/**
+ * An expression prefixed (or not) by one or more @ and !.
+ * @return the expression
+ */
+Expression AtNotUnaryExpression() :
 {
   final Expression expr;
   final int pos = SimpleCharStream.getPosition();
 }
 {
   <AT>
-  expr = AtUnaryExpression()
+  expr = AtNotUnaryExpression()
   {return new PrefixedUnaryExpression(expr,OperatorIds.AT,pos);}
 |
+  <BANG>
+  expr = AtNotUnaryExpression()
+  {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
+|
   expr = UnaryExpressionNoPrefix()
   {return expr;}
 }
@@ -1530,6 +1540,9 @@ Expression UnaryExpressionNoPrefix() :
 |
   expr = UnaryExpressionNotPlusMinus()
   {return expr;}
+/*|
+  LOOKAHEAD(2)
+  expr = PrintExpression()   {return expr;}*/
 }
 
 
@@ -2269,6 +2282,9 @@ Statement BlockStatementNoBreak() :
                                    return statement;}
 }
 
+/**
+ * used only by ForInit()
+ */
 VariableDeclaration[] LocalVariableDeclaration() :
 {
   final ArrayList list = new ArrayList();
@@ -2284,6 +2300,9 @@ VariableDeclaration[] LocalVariableDeclaration() :
   return vars;}
 }
 
+/**
+ * used only by LocalVariableDeclaration().
+ */
 VariableDeclaration LocalVariableDeclarator() :
 {
   final String varName;
@@ -2317,6 +2336,9 @@ EmptyStatement EmptyStatement() :
    return new EmptyStatement(pos-1,pos);}
 }
 
+/**
+ * used only by StatementExpressionList() which is used only by ForInit() and ForStatement()
+ */
 Expression StatementExpression() :
 {
   final Expression expr,expr2;