*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / PHPParser.jj
index b49b15a..bb3d533 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
 
 import java.util.Hashtable;
 import java.io.StringReader;
+import java.io.*;
 import java.text.MessageFormat;
 
 import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
@@ -90,6 +91,21 @@ public final class PHPParser extends PHPParserSuperclass {
     phpTest();
   }
 
+  public static final void htmlParserTester(final File fileName) throws CoreException, ParseException {
+    try {
+      final Reader stream = new FileReader(fileName);
+      if (jj_input_stream == null) {
+        jj_input_stream = new SimpleCharStream(stream, 1, 1);
+      }
+      ReInit(stream);
+      phpFile();
+    } catch (FileNotFoundException e) {
+      e.printStackTrace();  //To change body of catch statement use Options | File Templates.
+    } catch (ParseException e) {
+      e.printStackTrace();  //To change body of catch statement use Options | File Templates.
+    }
+  }
+
   public static final void htmlParserTester(final String strEval) throws CoreException, ParseException {
     final StringReader stream = new StringReader(strEval);
     if (jj_input_stream == null) {
@@ -124,6 +140,8 @@ public final class PHPParser extends PHPParserSuperclass {
     if (errorMessage == null) {
       PHPeclipsePlugin.log(e);
       errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it";
+      errorStart = jj_input_stream.getPosition();
+      errorEnd   = errorStart + 1;
     }
     setMarker(e);
     errorMessage = null;
@@ -592,7 +610,7 @@ void phpFile() :
 
 void PhpBlock() :
 {
-  final int start = jj_input_stream.bufpos;
+  final int start = jj_input_stream.getPosition();
 }
 {
   <PHPECHOSTART> Expression() [ <SEMICOLON> ] <PHPEND>
@@ -603,7 +621,7 @@ void PhpBlock() :
       setMarker(fileToParse,
                 "You should use '<?php' instead of '<?' it will avoid some problems with XML",
                 start,
-                jj_input_stream.bufpos,
+                jj_input_stream.getPosition(),
                 INFO,
                 "Line " + token.beginLine);
     } catch (CoreException e) {
@@ -616,6 +634,8 @@ void PhpBlock() :
   } catch (ParseException e) {
     errorMessage = "'?>' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -635,11 +655,13 @@ void ClassDeclaration() :
 {
   <CLASS>
   try {
-    {pos = jj_input_stream.bufpos;}
+    {pos = jj_input_stream.getPosition();}
     className = <IDENTIFIER>
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   [
@@ -649,6 +671,8 @@ void ClassDeclaration() :
     } catch (ParseException e) {
       errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
       errorLevel   = ERROR;
+      errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+      errorEnd   = jj_input_stream.getPosition() + 1;
       throw e;
     }
   ]
@@ -673,16 +697,20 @@ void ClassBody() :
   try {
     <LBRACE>
   } catch (ParseException e) {
-    errorMessage = "'{' expected";
+    errorMessage = "unexpected token : '"+ e.currentToken.next.image + "', '{' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   ( ClassBodyDeclaration() )*
   try {
     <RBRACE>
   } catch (ParseException e) {
-    errorMessage = "'var', 'function' or '}' expected";
+    errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', 'var', 'function' or '}' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -719,6 +747,8 @@ void FieldDeclaration() :
   } catch (ParseException e) {
     errorMessage = "';' expected after variable declaration";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -726,8 +756,8 @@ void FieldDeclaration() :
 PHPVarDeclaration VariableDeclarator() :
 {
   final String varName;
-  String varValue;
-  final int pos = jj_input_stream.bufpos;
+  final String varValue;
+  final int pos = jj_input_stream.getPosition();
 }
 {
   varName = VariableDeclaratorId()
@@ -739,6 +769,8 @@ PHPVarDeclaration VariableDeclarator() :
     } catch (ParseException e) {
       errorMessage = "Literal expression expected in variable initializer";
       errorLevel   = ERROR;
+      errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+      errorEnd   = jj_input_stream.getPosition() + 1;
       throw e;
     }
   ]
@@ -761,6 +793,8 @@ String VariableDeclaratorId() :
   } catch (ParseException e) {
     errorMessage = "'$' expected for variable identifier";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -803,13 +837,16 @@ final Token token;
   <DOLLAR> expr = VariableName()
   {return "$" + expr;}
 |
+  token = <DOLLAR_ID>
+  {return token.image + expr;}
+/*|      pas besoin ?
   token = <DOLLAR_ID> [expr = VariableName()]
   {
   if (expr == null) {
     return token.image;
   }
   return token.image + expr;
-  }
+  }*/
 }
 
 String VariableInitializer() :
@@ -879,6 +916,8 @@ void MethodDeclaration() :
     }
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {
@@ -895,12 +934,16 @@ void MethodDeclaration() :
   }
 }
 
+/**
+ * A MethodDeclarator contains [&] IDENTIFIER(parameters ...).
+ * @return a function description for the outline
+ */
 PHPFunctionDeclaration MethodDeclarator() :
 {
   final Token identifier;
   final StringBuffer methodDeclaration = new StringBuffer();
   final String formalParameters;
-  final int pos = jj_input_stream.bufpos;
+  final int pos = jj_input_stream.getPosition();
 }
 {
   [ <BIT_AND> {methodDeclaration.append("&");} ]
@@ -924,7 +967,9 @@ String FormalParameters() :
   } catch (ParseException e) {
     errorMessage = "Formal parameter expected after function identifier";
     errorLevel   = ERROR;
-    jj_consume_token(token.kind);
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
+    throw e;
   }
             [ expr = FormalParameter()
               {buff.append(expr);}
@@ -938,6 +983,8 @@ String FormalParameters() :
   } catch (ParseException e) {
     errorMessage = "')' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
  {
@@ -1012,6 +1059,8 @@ String Expression() :
     } catch (ParseException 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;
     }
   ]
@@ -1198,6 +1247,8 @@ String EqualityExpression() :
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected after '"+operator.image+"'";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {
@@ -1268,7 +1319,15 @@ String MultiplicativeExpression() :
   Token operator;
   final StringBuffer buff = new StringBuffer();}
 {
-  expr = UnaryExpression()
+  try {
+    expr = UnaryExpression()
+  } catch (ParseException e) {
+    errorMessage = "unexpected token '"+e.currentToken.next.image+"'";
+    errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
+    throw e;
+  }
   {buff.append(expr);}
   (
   ( operator = <STAR> | operator = <SLASH> | operator = <REM> ) expr = UnaryExpression()
@@ -1366,6 +1425,8 @@ String UnaryExpressionNotPlusMinus() :
   } catch (ParseException e) {
     errorMessage = "')' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {return "("+expr+")";}
@@ -1441,11 +1502,26 @@ String PrimaryPrefix() :
   {
     return "new " + expr;
   }
-|  
+|
   expr = VariableDeclaratorId()
   {return expr;}
 }
 
+String classInstantiation() :
+{
+  String expr;
+  final StringBuffer buff = new StringBuffer("new ");
+}
+{
+  <NEW> expr = ClassIdentifier()
+  {buff.append(expr);}
+  [
+    expr = PrimaryExpression()
+    {buff.append(expr);}
+  ]
+  {return buff.toString();}
+}
+
 String ClassIdentifier():
 {
   final String expr;
@@ -1482,6 +1558,8 @@ String VariableSuffix() :
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {return "->" + expr;}
@@ -1492,6 +1570,8 @@ String VariableSuffix() :
   } catch (ParseException e) {
     errorMessage = "']' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {
@@ -1552,6 +1632,8 @@ String expr = null;
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {
@@ -1576,6 +1658,8 @@ final StringBuffer buff = new StringBuffer();
       } catch (ParseException e) {
         errorMessage = "expression expected after a comma in argument list";
         errorLevel   = ERROR;
+        errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+        errorEnd   = jj_input_stream.getPosition() + 1;
         throw e;
       }
     {
@@ -1598,6 +1682,8 @@ void StatementNoBreak() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 |
@@ -1614,6 +1700,8 @@ void StatementNoBreak() :
   } catch (ParseException e) {
     errorMessage = "';' expected after expression";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 |
@@ -1656,7 +1744,7 @@ void Statement() :
 void IncludeStatement() :
 {
   final String expr;
-  final int pos = jj_input_stream.bufpos;
+  final int pos = jj_input_stream.getPosition();
 }
 {
   <REQUIRE>
@@ -1671,6 +1759,8 @@ void IncludeStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 |
@@ -1686,6 +1776,8 @@ void IncludeStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 |
@@ -1701,6 +1793,8 @@ void IncludeStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 |
@@ -1716,6 +1810,8 @@ void IncludeStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -1745,6 +1841,8 @@ String ListExpression() :
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   [
@@ -1757,6 +1855,8 @@ String ListExpression() :
     } catch (ParseException e) {
       errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected";
       errorLevel   = ERROR;
+      errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+      errorEnd   = jj_input_stream.getPosition() + 1;
       throw e;
     }
     expr = VariableDeclaratorId()
@@ -1768,6 +1868,8 @@ String ListExpression() :
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   [ <ASSIGN> expr = Expression() {buff.append("(").append(expr);}]
@@ -1783,6 +1885,8 @@ void EchoStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected after 'echo' statement";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -1796,6 +1900,8 @@ void GlobalStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -1809,6 +1915,8 @@ void StaticStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -1827,6 +1935,8 @@ void Block() :
   } catch (ParseException e) {
     errorMessage = "'{' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   ( BlockStatement() )*
@@ -1835,6 +1945,8 @@ void Block() :
   } catch (ParseException e) {
     errorMessage = "unexpected token : '"+ e.currentToken.image +"', '}' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -1909,6 +2021,8 @@ void SwitchStatement() :
   } catch (ParseException e) {
     errorMessage = "'(' expected after 'switch'";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   Expression()
@@ -1917,6 +2031,8 @@ void SwitchStatement() :
   } catch (ParseException e) {
     errorMessage = "')' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   try {
@@ -1924,6 +2040,8 @@ void SwitchStatement() :
   } catch (ParseException e) {
     errorMessage = "'{' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
     (
@@ -1949,6 +2067,8 @@ void SwitchStatement() :
   } catch (ParseException e) {
     errorMessage = "'}' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -1964,6 +2084,8 @@ Token BreakStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected after 'break' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {return token;}
@@ -1981,6 +2103,8 @@ int SwitchLabel() :
     if (errorMessage != null) throw e;
     errorMessage = "expression expected after 'case' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   try {
@@ -1988,6 +2112,8 @@ int SwitchLabel() :
   } catch (ParseException e) {
     errorMessage = "':' expected after case expression";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {return token.beginLine;}
@@ -1998,6 +2124,8 @@ int SwitchLabel() :
   } catch (ParseException e) {
     errorMessage = "':' expected after 'default' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   {return token.beginLine;}
@@ -2006,7 +2134,7 @@ int SwitchLabel() :
 void IfStatement() :
 {
   final Token token;
-  final int pos = jj_input_stream.bufpos;
+  final int pos = jj_input_stream.getPosition();
 }
 {
   token = <IF> Condition("if") IfStatement0(pos,pos+token.image.length())
@@ -2020,7 +2148,9 @@ void Condition(final String keyword) :
   } catch (ParseException e) {
     errorMessage = "'(' expected after " + keyword + " keyword";
     errorLevel   = ERROR;
-    throw e;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length();
+    errorEnd   = errorStart +1;
+    processParseException(e);
   }
   Expression()
   try {
@@ -2028,6 +2158,8 @@ void Condition(final String keyword) :
   } catch (ParseException e) {
     errorMessage = "')' expected after " + keyword + " keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -2052,6 +2184,8 @@ void IfStatement0(final int start,final int end) :
   } catch (ParseException e) {
     errorMessage = "'endif' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   try {
@@ -2059,6 +2193,8 @@ void IfStatement0(final int start,final int end) :
   } catch (ParseException e) {
     errorMessage = "';' expected after 'endif' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 |
@@ -2086,7 +2222,7 @@ void ElseIfStatement() :
 void WhileStatement() :
 {
   final Token token;
-  final int pos = jj_input_stream.bufpos;
+  final int pos = jj_input_stream.getPosition();
 }
 {
   token = <WHILE> Condition("while") WhileStatement0(pos,pos + token.image.length())
@@ -2111,6 +2247,8 @@ void WhileStatement0(final int start, final int end) :
   } catch (ParseException e) {
     errorMessage = "'endwhile' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   try {
@@ -2118,6 +2256,8 @@ void WhileStatement0(final int start, final int end) :
   } catch (ParseException e) {
     errorMessage = "';' expected after 'endwhile' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 |
@@ -2133,6 +2273,8 @@ void DoStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -2146,6 +2288,8 @@ void ForeachStatement() :
   } catch (ParseException e) {
     errorMessage = "'(' expected after 'foreach' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   try {
@@ -2153,6 +2297,8 @@ void ForeachStatement() :
   } catch (ParseException e) {
     errorMessage = "variable expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   [ VariableSuffix() ]
@@ -2161,6 +2307,8 @@ void ForeachStatement() :
   } catch (ParseException e) {
     errorMessage = "'as' expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   try {
@@ -2168,6 +2316,8 @@ void ForeachStatement() :
   } catch (ParseException e) {
     errorMessage = "variable expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   [ <ARRAYASSIGN> Expression() ]
@@ -2176,6 +2326,8 @@ void ForeachStatement() :
   } catch (ParseException e) {
     errorMessage = "')' expected after 'foreach' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
   try {
@@ -2184,6 +2336,8 @@ void ForeachStatement() :
     if (errorMessage != null) throw e;
     errorMessage = "statement expected";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -2191,7 +2345,7 @@ void ForeachStatement() :
 void ForStatement() :
 {
 final Token token;
-final int pos = jj_input_stream.bufpos;
+final int pos = jj_input_stream.getPosition();
 }
 {
   token = <FOR>
@@ -2200,6 +2354,8 @@ final int pos = jj_input_stream.bufpos;
   } catch (ParseException e) {
     errorMessage = "'(' expected after 'for' keyword";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
      [ ForInit() ] <SEMICOLON> [ Expression() ] <SEMICOLON> [ StatementExpressionList() ] <RPAREN>
@@ -2224,6 +2380,8 @@ final int pos = jj_input_stream.bufpos;
       } catch (ParseException e) {
         errorMessage = "'endfor' expected";
         errorLevel   = ERROR;
+        errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+        errorEnd   = jj_input_stream.getPosition() + 1;
         throw e;
       }
       try {
@@ -2231,6 +2389,8 @@ final int pos = jj_input_stream.bufpos;
       } catch (ParseException e) {
         errorMessage = "';' expected after 'endfor' keyword";
         errorLevel   = ERROR;
+        errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+        errorEnd   = jj_input_stream.getPosition() + 1;
         throw e;
       }
     )
@@ -2260,6 +2420,8 @@ void ContinueStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected after 'continue' statement";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
@@ -2273,6 +2435,8 @@ void ReturnStatement() :
   } catch (ParseException e) {
     errorMessage = "';' expected after 'return' statement";
     errorLevel   = ERROR;
+    errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
+    errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
 }
\ No newline at end of file