*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / PHPParser.jj
index ac77fff..cb90b27 100644 (file)
@@ -70,6 +70,8 @@ public final class PHPParser extends PHPParserSuperclass {
   private static int errorStart = -1;
   private static int errorEnd = -1;
   private static PHPDocument phpDocument;
+
+  private static final char[] SYNTAX_ERROR_CHAR = {'s','y','n','t','a','x',' ','e','r','r','o','r'};
   /**
    * The point where html starts.
    * It will be used by the token manager to create HTMLCode objects
@@ -658,7 +660,7 @@ void PhpBlock() :
     errorLevel   = ERROR;
     errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
     errorEnd   = SimpleCharStream.getPosition() + 1;
-    throw e;
+    processParseException(e);
   }
 }
 
@@ -688,41 +690,46 @@ ClassDeclaration ClassDeclaration() :
   final Token className;
   Token superclassName = null;
   final int pos;
+  char[] classNameImage = SYNTAX_ERROR_CHAR;
+  char[] superclassNameImage = null;
 }
 {
   <CLASS>
+  {pos = SimpleCharStream.getPosition();}
   try {
-    {pos = SimpleCharStream.getPosition();}
     className = <IDENTIFIER>
+    {classNameImage = className.image.toCharArray();}
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
     errorLevel   = ERROR;
     errorStart   = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
     errorEnd     = SimpleCharStream.getPosition() + 1;
-    throw e;
+    processParseException(e);
   }
   [
     <EXTENDS>
     try {
       superclassName = <IDENTIFIER>
+      {superclassNameImage = superclassName .image.toCharArray();}
     } catch (ParseException e) {
       errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
       errorLevel   = ERROR;
       errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
       errorEnd   = SimpleCharStream.getPosition() + 1;
-      throw e;
+      processParseException(e);
+      superclassNameImage = SYNTAX_ERROR_CHAR;
     }
   ]
   {
-    if (superclassName == null) {
+    if (superclassNameImage == null) {
       classDeclaration = new ClassDeclaration(currentSegment,
-                                              className.image.toCharArray(),
+                                              classNameImage,
                                               pos,
                                               0);
     } else {
       classDeclaration = new ClassDeclaration(currentSegment,
-                                              className.image.toCharArray(),
-                                              superclassName.image.toCharArray(),
+                                              classNameImage,
+                                              superclassNameImage,
                                               pos,
                                               0);
     }
@@ -1049,12 +1056,23 @@ MethodDeclaration MethodDeclarator() :
   Token reference = null;
   final Hashtable formalParameters;
   final int pos = SimpleCharStream.getPosition();
+  char[] identifierChar = SYNTAX_ERROR_CHAR;
 }
 {
-  [reference = <BIT_AND>] identifier = <IDENTIFIER>
+  [reference = <BIT_AND>]
+  try {
+    identifier = <IDENTIFIER>
+    {identifierChar = identifier.image.toCharArray();}
+  } catch (ParseException e) {
+    errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected";
+    errorLevel   = ERROR;
+    errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = SimpleCharStream.getPosition() + 1;
+    processParseException(e);
+  }
   formalParameters = FormalParameters()
   {return new MethodDeclaration(currentSegment,
-                                 identifier.image.toCharArray(),
+                                 identifierChar,
                                  formalParameters,
                                  reference != null,
                                  pos,
@@ -2417,14 +2435,14 @@ Expression Condition(final String keyword) :
   condition = Expression()
   try {
      <RPAREN>
-     {return condition;}
   } catch (ParseException e) {
     errorMessage = "')' expected after " + keyword + " keyword";
     errorLevel   = ERROR;
     errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
     errorEnd   = SimpleCharStream.getPosition() + 1;
-    throw e;
+    processParseException(e);
   }
+  {return condition;}
 }
 
 IfStatement IfStatement0(Expression condition, final int start,final int end) :