3 CHOICE_AMBIGUITY_CHECK = 2;
4 OTHER_AMBIGUITY_CHECK = 1;
7 DEBUG_LOOKAHEAD = false;
8 DEBUG_TOKEN_MANAGER = false;
9 OPTIMIZE_TOKEN_MANAGER = false;
10 ERROR_REPORTING = true;
11 JAVA_UNICODE_ESCAPE = false;
12 UNICODE_INPUT = false;
14 USER_TOKEN_MANAGER = false;
15 USER_CHAR_STREAM = false;
17 BUILD_TOKEN_MANAGER = true;
19 FORCE_LA_CHECK = false;
22 PARSER_BEGIN(PHPParser)
25 import org.eclipse.core.resources.IFile;
26 import org.eclipse.core.resources.IMarker;
27 import org.eclipse.core.runtime.CoreException;
28 import org.eclipse.ui.texteditor.MarkerUtilities;
29 import org.eclipse.jface.preference.IPreferenceStore;
31 import java.util.Hashtable;
32 import java.util.Enumeration;
33 import java.util.ArrayList;
34 import java.io.StringReader;
36 import java.text.MessageFormat;
38 import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
39 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
40 import net.sourceforge.phpdt.internal.compiler.ast.*;
41 import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren;
42 import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo;
46 * This php parser is inspired by the Java 1.2 grammar example
47 * given with JavaCC. You can get JavaCC at http://www.webgain.com
48 * You can test the parser with the PHPParserTestCase2.java
49 * @author Matthieu Casanova
51 public final class PHPParser extends PHPParserSuperclass {
53 /** The file that is parsed. */
54 private static IFile fileToParse;
56 /** The current segment. */
57 private static OutlineableWithChildren currentSegment;
59 private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$
60 private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$
61 static PHPOutlineInfo outlineInfo;
63 public static MethodDeclaration currentFunction;
64 private static boolean assigning;
66 /** The error level of the current ParseException. */
67 private static int errorLevel = ERROR;
68 /** The message of the current ParseException. If it's null it's because the parse exception wasn't handled */
69 private static String errorMessage;
71 private static int errorStart = -1;
72 private static int errorEnd = -1;
73 private static PHPDocument phpDocument;
75 * The point where html starts.
76 * It will be used by the token manager to create HTMLCode objects
78 public static int htmlStart;
81 private final static int AstStackIncrement = 100;
82 /** The stack of node. */
83 private static AstNode[] nodes;
84 /** The cursor in expression stack. */
85 private static int nodePtr;
86 private static VariableDeclaration[] variableDeclarationStack;
87 private static int variableDeclarationPtr;
88 private static Statement[] statementStack;
89 private static int statementPtr;
90 private static ElseIf[] elseIfStack;
91 private static int elseIfPtr;
93 public final void setFileToParse(final IFile fileToParse) {
94 this.fileToParse = fileToParse;
100 public PHPParser(final IFile fileToParse) {
101 this(new StringReader(""));
102 this.fileToParse = fileToParse;
106 * Reinitialize the parser.
108 private static final void init() {
109 nodes = new AstNode[AstStackIncrement];
110 statementStack = new Statement[AstStackIncrement];
111 elseIfStack = new ElseIf[AstStackIncrement];
119 * Add an php node on the stack.
120 * @param node the node that will be added to the stack
122 private static final void pushOnAstNodes(AstNode node) {
124 nodes[++nodePtr] = node;
125 } catch (IndexOutOfBoundsException e) {
126 int oldStackLength = nodes.length;
127 AstNode[] oldStack = nodes;
128 nodes = new AstNode[oldStackLength + AstStackIncrement];
129 System.arraycopy(oldStack, 0, nodes, 0, oldStackLength);
130 nodePtr = oldStackLength;
131 nodes[nodePtr] = node;
135 private static final void pushOnVariableDeclarationStack(VariableDeclaration var) {
137 variableDeclarationStack[++variableDeclarationPtr] = var;
138 } catch (IndexOutOfBoundsException e) {
139 int oldStackLength = variableDeclarationStack.length;
140 VariableDeclaration[] oldStack = variableDeclarationStack;
141 variableDeclarationStack = new VariableDeclaration[oldStackLength + AstStackIncrement];
142 System.arraycopy(oldStack, 0, variableDeclarationStack, 0, oldStackLength);
143 variableDeclarationPtr = oldStackLength;
144 variableDeclarationStack[variableDeclarationPtr] = var;
148 private static final void pushOnStatementStack(Statement statement) {
150 statementStack[++statementPtr] = statement;
151 } catch (IndexOutOfBoundsException e) {
152 int oldStackLength = statementStack.length;
153 Statement[] oldStack = statementStack;
154 statementStack = new Statement[oldStackLength + AstStackIncrement];
155 System.arraycopy(oldStack, 0, statementStack, 0, oldStackLength);
156 statementPtr = oldStackLength;
157 statementStack[statementPtr] = statement;
161 private static final void pushOnElseIfStack(ElseIf elseIf) {
163 elseIfStack[++elseIfPtr] = elseIf;
164 } catch (IndexOutOfBoundsException e) {
165 int oldStackLength = elseIfStack.length;
166 ElseIf[] oldStack = elseIfStack;
167 elseIfStack = new ElseIf[oldStackLength + AstStackIncrement];
168 System.arraycopy(oldStack, 0, elseIfStack, 0, oldStackLength);
169 elseIfPtr = oldStackLength;
170 elseIfStack[elseIfPtr] = elseIf;
174 public static final void phpParserTester(final String strEval) throws CoreException, ParseException {
175 PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING);
176 final StringReader stream = new StringReader(strEval);
177 if (jj_input_stream == null) {
178 jj_input_stream = new SimpleCharStream(stream, 1, 1);
180 ReInit(new StringReader(strEval));
185 public static final void htmlParserTester(final File fileName) throws CoreException, ParseException {
187 final Reader stream = new FileReader(fileName);
188 if (jj_input_stream == null) {
189 jj_input_stream = new SimpleCharStream(stream, 1, 1);
194 } catch (FileNotFoundException e) {
195 e.printStackTrace(); //To change body of catch statement use Options | File Templates.
199 public static final void htmlParserTester(final String strEval) throws CoreException, ParseException {
200 final StringReader stream = new StringReader(strEval);
201 if (jj_input_stream == null) {
202 jj_input_stream = new SimpleCharStream(stream, 1, 1);
209 public final PHPOutlineInfo parseInfo(final Object parent, final String s) {
210 currentSegment = new PHPDocument(parent);
211 outlineInfo = new PHPOutlineInfo(parent);
212 final StringReader stream = new StringReader(s);
213 if (jj_input_stream == null) {
214 jj_input_stream = new SimpleCharStream(stream, 1, 1);
220 phpDocument = new PHPDocument(null);
221 phpDocument.nodes = nodes;
222 PHPeclipsePlugin.log(1,phpDocument.toString());
223 } catch (ParseException e) {
224 processParseException(e);
230 * This method will process the parse exception.
231 * If the error message is null, the parse exception wasn't catched and a trace is written in the log
232 * @param e the ParseException
234 private static void processParseException(final ParseException e) {
235 if (errorMessage == null) {
236 PHPeclipsePlugin.log(e);
237 errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it";
238 errorStart = jj_input_stream.getPosition();
239 errorEnd = errorStart + 1;
246 * Create marker for the parse error
247 * @param e the ParseException
249 private static void setMarker(final ParseException e) {
251 if (errorStart == -1) {
252 setMarker(fileToParse,
254 jj_input_stream.tokenBegin,
255 jj_input_stream.tokenBegin + e.currentToken.image.length(),
257 "Line " + e.currentToken.beginLine);
259 setMarker(fileToParse,
264 "Line " + e.currentToken.beginLine);
268 } catch (CoreException e2) {
269 PHPeclipsePlugin.log(e2);
274 * Create markers according to the external parser output
276 private static void createMarkers(final String output, final IFile file) throws CoreException {
277 // delete all markers
278 file.deleteMarkers(IMarker.PROBLEM, false, 0);
283 while ((brIndx = output.indexOf("<br />", indx)) != -1) {
284 // newer php error output (tested with 4.2.3)
285 scanLine(output, file, indx, brIndx);
290 while ((brIndx = output.indexOf("<br>", indx)) != -1) {
291 // older php error output (tested with 4.2.3)
292 scanLine(output, file, indx, brIndx);
298 private static void scanLine(final String output,
301 final int brIndx) throws CoreException {
303 StringBuffer lineNumberBuffer = new StringBuffer(10);
305 current = output.substring(indx, brIndx);
307 if (current.indexOf(PARSE_WARNING_STRING) != -1 || current.indexOf(PARSE_ERROR_STRING) != -1) {
308 int onLine = current.indexOf("on line <b>");
310 lineNumberBuffer.delete(0, lineNumberBuffer.length());
311 for (int i = onLine; i < current.length(); i++) {
312 ch = current.charAt(i);
313 if ('0' <= ch && '9' >= ch) {
314 lineNumberBuffer.append(ch);
318 int lineNumber = Integer.parseInt(lineNumberBuffer.toString());
320 Hashtable attributes = new Hashtable();
322 current = current.replaceAll("\n", "");
323 current = current.replaceAll("<b>", "");
324 current = current.replaceAll("</b>", "");
325 MarkerUtilities.setMessage(attributes, current);
327 if (current.indexOf(PARSE_ERROR_STRING) != -1)
328 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
329 else if (current.indexOf(PARSE_WARNING_STRING) != -1)
330 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
332 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
333 MarkerUtilities.setLineNumber(attributes, lineNumber);
334 MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);
339 public final void parse(final String s) throws CoreException {
340 final StringReader stream = new StringReader(s);
341 if (jj_input_stream == null) {
342 jj_input_stream = new SimpleCharStream(stream, 1, 1);
348 } catch (ParseException e) {
349 processParseException(e);
354 * Call the php parse command ( php -l -f <filename> )
355 * and create markers according to the external parser output
357 public static void phpExternalParse(final IFile file) {
358 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
359 final String filename = file.getLocation().toString();
361 final String[] arguments = { filename };
362 final MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF));
363 final String command = form.format(arguments);
365 final String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: ");
368 // parse the buffer to find the errors and warnings
369 createMarkers(parserResult, file);
370 } catch (CoreException e) {
371 PHPeclipsePlugin.log(e);
376 * Put a new html block in the stack.
378 public static final void createNewHTMLCode() {
379 final int currentPosition = SimpleCharStream.getPosition();
380 if (currentPosition == htmlStart) {
383 final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,currentPosition).toCharArray();
384 pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition));
387 private static final void parse() throws ParseException {
392 PARSER_END(PHPParser)
396 <PHPSTARTSHORT : "<?"> {PHPParser.createNewHTMLCode();} : PHPPARSING
397 | <PHPSTARTLONG : "<?php"> {PHPParser.createNewHTMLCode();} : PHPPARSING
398 | <PHPECHOSTART : "<?="> {PHPParser.createNewHTMLCode();} : PHPPARSING
403 <PHPEND :"?>"> {PHPParser.htmlStart = SimpleCharStream.getPosition();} : DEFAULT
406 /* Skip any character if we are not in php mode */
424 <PHPPARSING> SPECIAL_TOKEN :
426 "//" : IN_SINGLE_LINE_COMMENT
428 "#" : IN_SINGLE_LINE_COMMENT
430 <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
432 "/*" : IN_MULTI_LINE_COMMENT
435 <IN_SINGLE_LINE_COMMENT> SPECIAL_TOKEN :
437 <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : PHPPARSING
440 <IN_SINGLE_LINE_COMMENT> SPECIAL_TOKEN :
442 <SINGLE_LINE_COMMENT_PHPEND : "?>" > : DEFAULT
448 <FORMAL_COMMENT: "*/" > : PHPPARSING
451 <IN_MULTI_LINE_COMMENT>
454 <MULTI_LINE_COMMENT: "*/" > : PHPPARSING
457 <IN_SINGLE_LINE_COMMENT,IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
467 | <FUNCTION : "function">
470 | <ELSEIF : "elseif">
477 /* LANGUAGE CONSTRUCT */
482 | <INCLUDE : "include">
483 | <REQUIRE : "require">
484 | <INCLUDE_ONCE : "include_once">
485 | <REQUIRE_ONCE : "require_once">
486 | <GLOBAL : "global">
487 | <STATIC : "static">
488 | <CLASSACCESS : "->">
489 | <STATICCLASSACCESS : "::">
490 | <ARRAYASSIGN : "=>">
493 /* RESERVED WORDS AND LITERALS */
499 | <CONTINUE : "continue">
500 | <_DEFAULT : "default">
502 | <EXTENDS : "extends">
507 | <RETURN : "return">
509 | <SWITCH : "switch">
514 | <ENDWHILE : "endwhile">
515 | <ENDSWITCH: "endswitch">
517 | <ENDFOR : "endfor">
518 | <FOREACH : "foreach">
526 | <OBJECT : "object">
528 | <BOOLEAN : "boolean">
530 | <DOUBLE : "double">
533 | <INTEGER : "integer">
563 | <RSIGNEDSHIFT : ">>">
564 | <RUNSIGNEDSHIFT : ">>>">
573 <DECIMAL_LITERAL> (["l","L"])?
574 | <HEX_LITERAL> (["l","L"])?
575 | <OCTAL_LITERAL> (["l","L"])?
578 <#DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
580 <#HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
582 <#OCTAL_LITERAL: "0" (["0"-"7"])* >
584 <FLOATING_POINT_LITERAL:
585 (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
586 | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
587 | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
588 | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
591 <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
593 <STRING_LITERAL: (<STRING_1> | <STRING_2> | <STRING_3>)>
627 < IDENTIFIER: (<LETTER>|<SPECIAL>) (<LETTER>|<DIGIT>|<SPECIAL>)* >
630 ["a"-"z"] | ["A"-"Z"]
638 "_" | ["\u007f"-"\u00ff"]
663 | <EQUAL_EQUAL : "==">
668 | <BANGDOUBLEEQUAL : "!==">
669 | <TRIPLEEQUAL : "===">
676 | <PLUSASSIGN : "+=">
677 | <MINUSASSIGN : "-=">
678 | <STARASSIGN : "*=">
679 | <SLASHASSIGN : "/=">
685 | <TILDEEQUAL : "~=">
686 | <LSHIFTASSIGN : "<<=">
687 | <RSIGNEDSHIFTASSIGN : ">>=">
692 < DOLLAR_ID: <DOLLAR> <IDENTIFIER> >
700 {PHPParser.createNewHTMLCode();}
709 } catch (TokenMgrError e) {
710 PHPeclipsePlugin.log(e);
711 errorStart = SimpleCharStream.getPosition();
712 errorEnd = errorStart + 1;
713 errorMessage = e.getMessage();
715 throw generateParseException();
720 * A php block is a <?= expression [;]?>
721 * or <?php somephpcode ?>
722 * or <? somephpcode ?>
726 final int start = jj_input_stream.getPosition();
734 setMarker(fileToParse,
735 "You should use '<?php' instead of '<?' it will avoid some problems with XML",
737 jj_input_stream.getPosition(),
739 "Line " + token.beginLine);
740 } catch (CoreException e) {
741 PHPeclipsePlugin.log(e);
747 } catch (ParseException e) {
748 errorMessage = "'?>' expected";
750 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
751 errorEnd = jj_input_stream.getPosition() + 1;
756 PHPEchoBlock phpEchoBlock() :
758 final Expression expr;
759 final int pos = SimpleCharStream.getPosition();
760 PHPEchoBlock echoBlock;
763 <PHPECHOSTART> expr = Expression() [ <SEMICOLON> ] <PHPEND>
765 echoBlock = new PHPEchoBlock(expr,pos,SimpleCharStream.getPosition());
766 pushOnAstNodes(echoBlock);
776 ClassDeclaration ClassDeclaration() :
778 final ClassDeclaration classDeclaration;
779 final Token className;
780 Token superclassName = null;
786 {pos = jj_input_stream.getPosition();}
787 className = <IDENTIFIER>
788 } catch (ParseException e) {
789 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
791 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
792 errorEnd = jj_input_stream.getPosition() + 1;
798 superclassName = <IDENTIFIER>
799 } catch (ParseException e) {
800 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
802 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
803 errorEnd = jj_input_stream.getPosition() + 1;
808 if (superclassName == null) {
809 classDeclaration = new ClassDeclaration(currentSegment,
810 className.image.toCharArray(),
814 classDeclaration = new ClassDeclaration(currentSegment,
815 className.image.toCharArray(),
816 superclassName.image.toCharArray(),
820 currentSegment.add(classDeclaration);
821 currentSegment = classDeclaration;
823 ClassBody(classDeclaration)
824 {currentSegment = (OutlineableWithChildren) currentSegment.getParent();
825 classDeclaration.sourceEnd = SimpleCharStream.getPosition();
826 pushOnAstNodes(classDeclaration);
827 return classDeclaration;}
830 void ClassBody(ClassDeclaration classDeclaration) :
835 } catch (ParseException e) {
836 errorMessage = "unexpected token : '"+ e.currentToken.next.image + "', '{' expected";
838 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
839 errorEnd = jj_input_stream.getPosition() + 1;
842 ( ClassBodyDeclaration(classDeclaration) )*
845 } catch (ParseException e) {
846 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', 'var', 'function' or '}' expected";
848 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
849 errorEnd = jj_input_stream.getPosition() + 1;
855 * A class can contain only methods and fields.
857 void ClassBodyDeclaration(ClassDeclaration classDeclaration) :
859 MethodDeclaration method;
860 FieldDeclaration field;
863 method = MethodDeclaration() {classDeclaration.addMethod(method);}
864 | field = FieldDeclaration() {classDeclaration.addVariable(field);}
868 * A class field declaration : it's var VariableDeclarator() (, VariableDeclarator())*;.
870 FieldDeclaration FieldDeclaration() :
872 VariableDeclaration variableDeclaration;
873 VariableDeclaration[] list;
874 final ArrayList arrayList = new ArrayList();
875 final int pos = SimpleCharStream.getPosition();
878 <VAR> variableDeclaration = VariableDeclarator()
879 {arrayList.add(variableDeclaration);
880 outlineInfo.addVariable(new String(variableDeclaration.name));
881 currentSegment.add(variableDeclaration);}
882 ( <COMMA> variableDeclaration = VariableDeclarator()
883 {arrayList.add(variableDeclaration);
884 outlineInfo.addVariable(new String(variableDeclaration.name));
885 currentSegment.add(variableDeclaration);}
889 } catch (ParseException e) {
890 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected after variable declaration";
892 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
893 errorEnd = jj_input_stream.getPosition() + 1;
897 {list = new VariableDeclaration[arrayList.size()];
898 arrayList.toArray(list);
899 return new FieldDeclaration(list,
901 SimpleCharStream.getPosition());}
904 VariableDeclaration VariableDeclarator() :
906 final String varName, varValue;
907 Expression initializer = null;
908 final int pos = jj_input_stream.getPosition();
911 varName = VariableDeclaratorId()
915 initializer = VariableInitializer()
916 } catch (ParseException e) {
917 errorMessage = "Literal expression expected in variable initializer";
919 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
920 errorEnd = jj_input_stream.getPosition() + 1;
925 if (initializer == null) {
926 return new VariableDeclaration(currentSegment,
927 varName.toCharArray(),
929 jj_input_stream.getPosition());
931 return new VariableDeclaration(currentSegment,
932 varName.toCharArray(),
940 * @return the variable name (with suffix)
942 String VariableDeclaratorId() :
945 Expression expression;
946 final StringBuffer buff = new StringBuffer();
947 final int pos = SimpleCharStream.getPosition();
948 ConstantIdentifier ex;
952 expr = Variable() {buff.append(expr);}
954 {ex = new ConstantIdentifier(expr.toCharArray(),
956 SimpleCharStream.getPosition());}
957 expression = VariableSuffix(ex)
958 {buff.append(expression.toStringExpression());}
960 {return buff.toString();}
961 } catch (ParseException e) {
962 errorMessage = "'$' expected for variable identifier";
964 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
965 errorEnd = jj_input_stream.getPosition() + 1;
972 final StringBuffer buff;
973 Expression expression = null;
978 token = <DOLLAR_ID> [<LBRACE> expression = Expression() <RBRACE>]
980 if (expression == null && !assigning) {
981 return token.image.substring(1);
983 buff = new StringBuffer(token.image);
985 buff.append(expression.toStringExpression());
987 return buff.toString();
990 <DOLLAR> expr = VariableName()
994 String VariableName():
996 final StringBuffer buff;
998 Expression expression = null;
1002 <LBRACE> expression = Expression() <RBRACE>
1003 {buff = new StringBuffer('{');
1004 buff.append(expression.toStringExpression());
1006 return buff.toString();}
1008 token = <IDENTIFIER> [<LBRACE> expression = Expression() <RBRACE>]
1010 if (expression == null) {
1013 buff = new StringBuffer(token.image);
1015 buff.append(expression.toStringExpression());
1017 return buff.toString();
1020 <DOLLAR> expr = VariableName()
1022 buff = new StringBuffer('$');
1024 return buff.toString();
1027 token = <DOLLAR_ID> {return token.image;}
1030 Expression VariableInitializer() :
1032 final Expression expr;
1034 final int pos = SimpleCharStream.getPosition();
1040 <MINUS> (token = <INTEGER_LITERAL> | token = <FLOATING_POINT_LITERAL>)
1041 {return new PrefixedUnaryExpression(new NumberLiteral(token.image.toCharArray(),
1043 SimpleCharStream.getPosition()),
1047 <PLUS> (token = <INTEGER_LITERAL> | token = <FLOATING_POINT_LITERAL>)
1048 {return new PrefixedUnaryExpression(new NumberLiteral(token.image.toCharArray(),
1050 SimpleCharStream.getPosition()),
1054 expr = ArrayDeclarator()
1057 token = <IDENTIFIER>
1058 {return new ConstantIdentifier(token.image.toCharArray(),pos,SimpleCharStream.getPosition());}
1061 ArrayVariableDeclaration ArrayVariable() :
1063 Expression expr,expr2;
1067 [<ARRAYASSIGN> expr2 = Expression()
1068 {return new ArrayVariableDeclaration(expr,expr2);}
1070 {return new ArrayVariableDeclaration(expr,SimpleCharStream.getPosition());}
1073 ArrayVariableDeclaration[] ArrayInitializer() :
1075 ArrayVariableDeclaration expr;
1076 final ArrayList list = new ArrayList();
1079 <LPAREN> [ expr = ArrayVariable()
1081 ( LOOKAHEAD(2) <COMMA> expr = ArrayVariable()
1085 [<COMMA> {list.add(null);}]
1088 ArrayVariableDeclaration[] vars = new ArrayVariableDeclaration[list.size()];
1094 * A Method Declaration.
1095 * <b>function</b> MetodDeclarator() Block()
1097 MethodDeclaration MethodDeclaration() :
1099 final MethodDeclaration functionDeclaration;
1100 Token functionToken;
1104 functionToken = <FUNCTION>
1106 functionDeclaration = MethodDeclarator()
1107 {outlineInfo.addVariable(new String(functionDeclaration.name));}
1108 } catch (ParseException e) {
1109 if (errorMessage != null) throw e;
1110 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected";
1112 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1113 errorEnd = jj_input_stream.getPosition() + 1;
1117 if (currentSegment != null) {
1118 currentSegment.add(functionDeclaration);
1119 currentSegment = functionDeclaration;
1121 currentFunction = functionDeclaration;
1125 functionDeclaration.statements = block.statements;
1126 currentFunction = null;
1127 if (currentSegment != null) {
1128 currentSegment = (OutlineableWithChildren) currentSegment.getParent();
1130 return functionDeclaration;
1135 * A MethodDeclarator.
1136 * [&] IDENTIFIER(parameters ...).
1137 * @return a function description for the outline
1139 MethodDeclaration MethodDeclarator() :
1141 final Token identifier;
1142 Token reference = null;
1143 final Hashtable formalParameters;
1144 final int pos = SimpleCharStream.getPosition();
1147 [reference = <BIT_AND>] identifier = <IDENTIFIER>
1148 formalParameters = FormalParameters()
1149 {return new MethodDeclaration(currentSegment,
1150 identifier.image.toCharArray(),
1154 SimpleCharStream.getPosition());}
1158 * FormalParameters follows method identifier.
1159 * (FormalParameter())
1161 Hashtable FormalParameters() :
1164 final StringBuffer buff = new StringBuffer("(");
1165 VariableDeclaration var;
1166 final Hashtable parameters = new Hashtable();
1171 } catch (ParseException e) {
1172 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier";
1174 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1175 errorEnd = jj_input_stream.getPosition() + 1;
1178 [ var = FormalParameter()
1179 {parameters.put(new String(var.name),var);}
1181 <COMMA> var = FormalParameter()
1182 {parameters.put(new String(var.name),var);}
1187 } catch (ParseException e) {
1188 errorMessage = "')' expected";
1190 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1191 errorEnd = jj_input_stream.getPosition() + 1;
1194 {return parameters;}
1198 * A formal parameter.
1199 * $varname[=value] (,$varname[=value])
1201 VariableDeclaration FormalParameter() :
1203 final VariableDeclaration variableDeclaration;
1207 [token = <BIT_AND>] variableDeclaration = VariableDeclarator()
1209 if (token != null) {
1210 variableDeclaration.setReference(true);
1212 return variableDeclaration;}
1215 ConstantIdentifier Type() :
1218 <STRING> {pos = SimpleCharStream.getPosition();
1219 return new ConstantIdentifier(Types.STRING,
1221 | <BOOL> {pos = SimpleCharStream.getPosition();
1222 return new ConstantIdentifier(Types.BOOL,
1224 | <BOOLEAN> {pos = SimpleCharStream.getPosition();
1225 return new ConstantIdentifier(Types.BOOLEAN,
1227 | <REAL> {pos = SimpleCharStream.getPosition();
1228 return new ConstantIdentifier(Types.REAL,
1230 | <DOUBLE> {pos = SimpleCharStream.getPosition();
1231 return new ConstantIdentifier(Types.DOUBLE,
1233 | <FLOAT> {pos = SimpleCharStream.getPosition();
1234 return new ConstantIdentifier(Types.FLOAT,
1236 | <INT> {pos = SimpleCharStream.getPosition();
1237 return new ConstantIdentifier(Types.INT,
1239 | <INTEGER> {pos = SimpleCharStream.getPosition();
1240 return new ConstantIdentifier(Types.INTEGER,
1242 | <OBJECT> {pos = SimpleCharStream.getPosition();
1243 return new ConstantIdentifier(Types.OBJECT,
1247 Expression Expression() :
1249 final Expression expr;
1252 expr = PrintExpression() {return expr;}
1253 | expr = ListExpression() {return expr;}
1254 | LOOKAHEAD(varAssignation())
1255 expr = varAssignation() {return expr;}
1256 | expr = ConditionalExpression() {return expr;}
1260 * A Variable assignation.
1261 * varName (an assign operator) any expression
1263 VarAssignation varAssignation() :
1266 final Expression expression;
1267 final int assignOperator;
1268 final int pos = SimpleCharStream.getPosition();
1271 varName = VariableDeclaratorId()
1272 assignOperator = AssignmentOperator()
1274 expression = Expression()
1275 } catch (ParseException e) {
1276 if (errorMessage != null) {
1279 errorMessage = "expression expected";
1281 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1282 errorEnd = jj_input_stream.getPosition() + 1;
1285 {return new VarAssignation(varName.toCharArray(),
1289 SimpleCharStream.getPosition());}
1292 int AssignmentOperator() :
1295 <ASSIGN> {return VarAssignation.EQUAL;}
1296 | <STARASSIGN> {return VarAssignation.STAR_EQUAL;}
1297 | <SLASHASSIGN> {return VarAssignation.SLASH_EQUAL;}
1298 | <REMASSIGN> {return VarAssignation.REM_EQUAL;}
1299 | <PLUSASSIGN> {return VarAssignation.PLUS_EQUAL;}
1300 | <MINUSASSIGN> {return VarAssignation.MINUS_EQUAL;}
1301 | <LSHIFTASSIGN> {return VarAssignation.LSHIFT_EQUAL;}
1302 | <RSIGNEDSHIFTASSIGN> {return VarAssignation.RSIGNEDSHIFT_EQUAL;}
1303 | <ANDASSIGN> {return VarAssignation.AND_EQUAL;}
1304 | <XORASSIGN> {return VarAssignation.XOR_EQUAL;}
1305 | <ORASSIGN> {return VarAssignation.OR_EQUAL;}
1306 | <DOTASSIGN> {return VarAssignation.DOT_EQUAL;}
1307 | <TILDEEQUAL> {return VarAssignation.TILDE_EQUAL;}
1310 Expression ConditionalExpression() :
1312 final Expression expr;
1313 Expression expr2 = null;
1314 Expression expr3 = null;
1317 expr = ConditionalOrExpression() [ <HOOK> expr2 = Expression() <COLON> expr3 = ConditionalExpression() ]
1319 if (expr3 == null) {
1322 return new ConditionalExpression(expr,expr2,expr3);
1326 Expression ConditionalOrExpression() :
1328 Expression expr,expr2;
1332 expr = ConditionalAndExpression()
1335 <OR_OR> {operator = OperatorIds.OR_OR;}
1336 | <_ORL> {operator = OperatorIds.ORL;}
1337 ) expr2 = ConditionalAndExpression()
1339 expr = new BinaryExpression(expr,expr2,operator);
1345 Expression ConditionalAndExpression() :
1347 Expression expr,expr2;
1351 expr = ConcatExpression()
1353 ( <AND_AND> {operator = OperatorIds.AND_AND;}
1354 | <_ANDL> {operator = OperatorIds.ANDL;})
1355 expr2 = ConcatExpression() {expr = new BinaryExpression(expr,expr2,operator);}
1360 Expression ConcatExpression() :
1362 Expression expr,expr2;
1365 expr = InclusiveOrExpression()
1367 <DOT> expr2 = InclusiveOrExpression()
1368 {expr = new BinaryExpression(expr,expr2,OperatorIds.DOT);}
1373 Expression InclusiveOrExpression() :
1375 Expression expr,expr2;
1378 expr = ExclusiveOrExpression()
1379 (<BIT_OR> expr2 = ExclusiveOrExpression()
1380 {expr = new BinaryExpression(expr,expr2,OperatorIds.OR);}
1385 Expression ExclusiveOrExpression() :
1387 Expression expr,expr2;
1390 expr = AndExpression()
1392 <XOR> expr2 = AndExpression()
1393 {expr = new BinaryExpression(expr,expr2,OperatorIds.XOR);}
1398 Expression AndExpression() :
1400 Expression expr,expr2;
1403 expr = EqualityExpression()
1405 <BIT_AND> expr2 = EqualityExpression()
1406 {expr = new BinaryExpression(expr,expr2,OperatorIds.AND);}
1411 Expression EqualityExpression() :
1413 Expression expr,expr2;
1417 expr = RelationalExpression()
1419 ( <EQUAL_EQUAL> {operator = OperatorIds.EQUAL_EQUAL;}
1420 | <DIF> {operator = OperatorIds.DIF;}
1421 | <NOT_EQUAL> {operator = OperatorIds.DIF;}
1422 | <BANGDOUBLEEQUAL> {operator = OperatorIds.BANG_EQUAL_EQUAL;}
1423 | <TRIPLEEQUAL> {operator = OperatorIds.EQUAL_EQUAL_EQUAL;}
1426 expr2 = RelationalExpression()
1427 } catch (ParseException e) {
1428 if (errorMessage != null) {
1431 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected";
1433 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1434 errorEnd = jj_input_stream.getPosition() + 1;
1438 expr = new BinaryExpression(expr,expr2,operator);
1444 Expression RelationalExpression() :
1446 Expression expr,expr2;
1450 expr = ShiftExpression()
1452 ( <LT> {operator = OperatorIds.LESS;}
1453 | <GT> {operator = OperatorIds.GREATER;}
1454 | <LE> {operator = OperatorIds.LESS_EQUAL;}
1455 | <GE> {operator = OperatorIds.GREATER_EQUAL;})
1456 expr2 = ShiftExpression()
1457 {expr = new BinaryExpression(expr,expr2,operator);}
1462 Expression ShiftExpression() :
1464 Expression expr,expr2;
1468 expr = AdditiveExpression()
1470 ( <LSHIFT> {operator = OperatorIds.LEFT_SHIFT;}
1471 | <RSIGNEDSHIFT> {operator = OperatorIds.RIGHT_SHIFT;}
1472 | <RUNSIGNEDSHIFT> {operator = OperatorIds.UNSIGNED_RIGHT_SHIFT;})
1473 expr2 = AdditiveExpression()
1474 {expr = new BinaryExpression(expr,expr2,operator);}
1479 Expression AdditiveExpression() :
1481 Expression expr,expr2;
1485 expr = MultiplicativeExpression()
1487 ( <PLUS> {operator = OperatorIds.PLUS;}
1488 | <MINUS> {operator = OperatorIds.MINUS;} )
1489 expr2 = MultiplicativeExpression()
1490 {expr = new BinaryExpression(expr,expr2,operator);}
1495 Expression MultiplicativeExpression() :
1497 Expression expr,expr2;
1502 expr = UnaryExpression()
1503 } catch (ParseException e) {
1504 if (errorMessage != null) throw e;
1505 errorMessage = "unexpected token '"+e.currentToken.next.image+"'";
1507 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1508 errorEnd = jj_input_stream.getPosition() + 1;
1512 ( <STAR> {operator = OperatorIds.MULTIPLY;}
1513 | <SLASH> {operator = OperatorIds.DIVIDE;}
1514 | <REMAINDER> {operator = OperatorIds.REMAINDER;})
1515 expr2 = UnaryExpression()
1516 {expr = new BinaryExpression(expr,expr2,operator);}
1522 * An unary expression starting with @, & or nothing
1524 Expression UnaryExpression() :
1527 final int pos = SimpleCharStream.getPosition();
1530 <BIT_AND> expr = UnaryExpressionNoPrefix()
1531 {return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);}
1533 expr = AtUnaryExpression() {return expr;}
1536 Expression AtUnaryExpression() :
1539 final int pos = SimpleCharStream.getPosition();
1543 expr = AtUnaryExpression()
1544 {return new PrefixedUnaryExpression(expr,OperatorIds.AT,pos);}
1546 expr = UnaryExpressionNoPrefix()
1551 Expression UnaryExpressionNoPrefix() :
1555 final int pos = SimpleCharStream.getPosition();
1558 ( <PLUS> {operator = OperatorIds.PLUS;}
1559 | <MINUS> {operator = OperatorIds.MINUS;})
1560 expr = UnaryExpression()
1561 {return new PrefixedUnaryExpression(expr,operator,pos);}
1563 expr = PreIncDecExpression()
1566 expr = UnaryExpressionNotPlusMinus()
1571 Expression PreIncDecExpression() :
1573 final Expression expr;
1575 final int pos = SimpleCharStream.getPosition();
1578 ( <INCR> {operator = OperatorIds.PLUS_PLUS;}
1579 | <DECR> {operator = OperatorIds.MINUS_MINUS;})
1580 expr = PrimaryExpression()
1581 {return new PrefixedUnaryExpression(expr,operator,pos);}
1584 Expression UnaryExpressionNotPlusMinus() :
1587 final int pos = SimpleCharStream.getPosition();
1590 <BANG> expr = UnaryExpression() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
1591 | LOOKAHEAD( <LPAREN> (Type() | <ARRAY>) <RPAREN> )
1592 expr = CastExpression() {return expr;}
1593 | expr = PostfixExpression() {return expr;}
1594 | expr = Literal() {return expr;}
1595 | <LPAREN> expr = Expression()
1598 } catch (ParseException e) {
1599 errorMessage = "')' expected";
1601 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1602 errorEnd = jj_input_stream.getPosition() + 1;
1608 CastExpression CastExpression() :
1610 final ConstantIdentifier type;
1611 final Expression expr;
1612 final int pos = SimpleCharStream.getPosition();
1617 | <ARRAY> {type = new ConstantIdentifier(Types.ARRAY,pos,SimpleCharStream.getPosition());})
1618 <RPAREN> expr = UnaryExpression()
1619 {return new CastExpression(type,expr,pos,SimpleCharStream.getPosition());}
1622 Expression PostfixExpression() :
1626 final int pos = SimpleCharStream.getPosition();
1629 expr = PrimaryExpression()
1630 [ <INCR> {operator = OperatorIds.PLUS_PLUS;}
1631 | <DECR> {operator = OperatorIds.MINUS_MINUS;}]
1633 if (operator == -1) {
1636 return new PostfixedUnaryExpression(expr,operator,pos);
1640 Expression PrimaryExpression() :
1642 final Token identifier;
1644 final StringBuffer buff = new StringBuffer();
1645 final int pos = SimpleCharStream.getPosition();
1649 identifier = <IDENTIFIER> <STATICCLASSACCESS> expr = ClassIdentifier()
1650 {expr = new ClassAccess(new ConstantIdentifier(identifier.image.toCharArray(),
1652 SimpleCharStream.getPosition()),
1654 ClassAccess.STATIC);}
1655 (expr = PrimarySuffix(expr))*
1658 expr = PrimaryPrefix()
1659 (expr = PrimarySuffix(expr))*
1662 expr = ArrayDeclarator()
1666 ArrayInitializer ArrayDeclarator() :
1668 final ArrayVariableDeclaration[] vars;
1669 final int pos = SimpleCharStream.getPosition();
1672 <ARRAY> vars = ArrayInitializer()
1673 {return new ArrayInitializer(vars,pos,SimpleCharStream.getPosition());}
1676 Expression PrimaryPrefix() :
1678 final Expression expr;
1681 final int pos = SimpleCharStream.getPosition();
1684 token = <IDENTIFIER> {return new ConstantIdentifier(token.image.toCharArray(),
1686 SimpleCharStream.getPosition());}
1687 | <NEW> expr = ClassIdentifier() {return new PrefixedUnaryExpression(expr,
1690 | var = VariableDeclaratorId() {return new ConstantIdentifier(var.toCharArray(),
1692 SimpleCharStream.getPosition());}
1695 PrefixedUnaryExpression classInstantiation() :
1698 final StringBuffer buff;
1699 final int pos = SimpleCharStream.getPosition();
1702 <NEW> expr = ClassIdentifier()
1704 {buff = new StringBuffer(expr.toStringExpression());}
1705 expr = PrimaryExpression()
1706 {buff.append(expr.toStringExpression());
1707 expr = new ConstantIdentifier(buff.toString().toCharArray(),
1709 SimpleCharStream.getPosition());}
1711 {return new PrefixedUnaryExpression(expr,
1716 ConstantIdentifier ClassIdentifier():
1720 final int pos = SimpleCharStream.getPosition();
1723 token = <IDENTIFIER> {return new ConstantIdentifier(token.image.toCharArray(),
1725 SimpleCharStream.getPosition());}
1726 | expr = VariableDeclaratorId() {return new ConstantIdentifier(expr.toCharArray(),
1728 SimpleCharStream.getPosition());}
1731 AbstractSuffixExpression PrimarySuffix(Expression prefix) :
1733 final AbstractSuffixExpression expr;
1736 expr = Arguments(prefix) {return expr;}
1737 | expr = VariableSuffix(prefix) {return expr;}
1740 AbstractSuffixExpression VariableSuffix(Expression prefix) :
1743 final int pos = SimpleCharStream.getPosition();
1744 Expression expression = null;
1749 expr = VariableName()
1750 } catch (ParseException e) {
1751 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected";
1753 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1754 errorEnd = jj_input_stream.getPosition() + 1;
1757 {return new ClassAccess(prefix,
1758 new ConstantIdentifier(expr.toCharArray(),pos,SimpleCharStream.getPosition()),
1759 ClassAccess.NORMAL);}
1761 <LBRACKET> [ expression = Expression() | expression = Type() ] //Not good
1764 } catch (ParseException e) {
1765 errorMessage = "']' expected";
1767 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1768 errorEnd = jj_input_stream.getPosition() + 1;
1771 {return new ArrayDeclarator(prefix,expression,SimpleCharStream.getPosition());}
1780 token = <INTEGER_LITERAL> {pos = SimpleCharStream.getPosition();
1781 return new NumberLiteral(token.image.toCharArray(),pos-token.image.length(),pos);}
1782 | token = <FLOATING_POINT_LITERAL> {pos = SimpleCharStream.getPosition();
1783 return new NumberLiteral(token.image.toCharArray(),pos-token.image.length(),pos);}
1784 | token = <STRING_LITERAL> {pos = SimpleCharStream.getPosition();
1785 return new StringLiteral(token.image.toCharArray(),pos-token.image.length());}
1786 | <TRUE> {pos = SimpleCharStream.getPosition();
1787 return new TrueLiteral(pos-4,pos);}
1788 | <FALSE> {pos = SimpleCharStream.getPosition();
1789 return new FalseLiteral(pos-4,pos);}
1790 | <NULL> {pos = SimpleCharStream.getPosition();
1791 return new NullLiteral(pos-4,pos);}
1794 FunctionCall Arguments(Expression func) :
1796 Expression[] args = null;
1799 <LPAREN> [ args = ArgumentList() ]
1802 } catch (ParseException e) {
1803 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list";
1805 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1806 errorEnd = jj_input_stream.getPosition() + 1;
1809 {return new FunctionCall(func,args,SimpleCharStream.getPosition());}
1813 * An argument list is a list of arguments separated by comma :
1814 * argumentDeclaration() (, argumentDeclaration)*
1815 * @return an array of arguments
1817 Expression[] ArgumentList() :
1820 final ArrayList list = new ArrayList();
1829 } catch (ParseException e) {
1830 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list";
1832 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1833 errorEnd = jj_input_stream.getPosition() + 1;
1838 Expression[] arguments = new Expression[list.size()];
1839 list.toArray(arguments);
1844 * A Statement without break.
1846 Statement StatementNoBreak() :
1848 final Statement statement;
1853 statement = Expression()
1856 } catch (ParseException e) {
1857 if (e.currentToken.next.kind != 4) {
1858 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1860 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1861 errorEnd = jj_input_stream.getPosition() + 1;
1867 statement = LabeledStatement() {return statement;}
1868 | statement = Block() {return statement;}
1869 | statement = EmptyStatement() {return statement;}
1870 | statement = StatementExpression()
1873 } catch (ParseException e) {
1874 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1876 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1877 errorEnd = jj_input_stream.getPosition() + 1;
1881 | statement = SwitchStatement() {return statement;}
1882 | statement = IfStatement() {return statement;}
1883 | statement = WhileStatement() {return statement;}
1884 | statement = DoStatement() {return statement;}
1885 | statement = ForStatement() {return statement;}
1886 | statement = ForeachStatement() {return statement;}
1887 | statement = ContinueStatement() {return statement;}
1888 | statement = ReturnStatement() {return statement;}
1889 | statement = EchoStatement() {return statement;}
1890 | [token=<AT>] statement = IncludeStatement()
1891 {if (token != null) {
1892 ((InclusionStatement)statement).silent = true;
1895 | statement = StaticStatement() {return statement;}
1896 | statement = GlobalStatement() {return statement;}
1900 * A Normal statement.
1902 Statement Statement() :
1904 final Statement statement;
1907 statement = StatementNoBreak() {return statement;}
1908 | statement = BreakStatement() {return statement;}
1912 * An html block inside a php syntax.
1914 HTMLBlock htmlBlock() :
1916 final int startIndex = nodePtr;
1917 AstNode[] blockNodes;
1921 <PHPEND> (phpEchoBlock())*
1923 (<PHPSTARTLONG> | <PHPSTARTSHORT>)
1924 } catch (ParseException e) {
1925 errorMessage = "End of file unexpected, '<?php' expected";
1927 errorStart = jj_input_stream.getPosition();
1928 errorEnd = jj_input_stream.getPosition();
1932 nbNodes = nodePtr-startIndex - 1;
1933 blockNodes = new AstNode[nbNodes];
1934 System.arraycopy(nodes,startIndex,blockNodes,0,nbNodes);
1935 return new HTMLBlock(nodes);}
1939 * An include statement. It's "include" an expression;
1941 InclusionStatement IncludeStatement() :
1943 final Expression expr;
1946 final int pos = jj_input_stream.getPosition();
1947 final InclusionStatement inclusionStatement;
1950 ( <REQUIRE> {keyword = InclusionStatement.REQUIRE;}
1951 | <REQUIRE_ONCE> {keyword = InclusionStatement.REQUIRE_ONCE;}
1952 | <INCLUDE> {keyword = InclusionStatement.INCLUDE;}
1953 | <INCLUDE_ONCE> {keyword = InclusionStatement.INCLUDE_ONCE;})
1956 } catch (ParseException e) {
1957 if (errorMessage != null) {
1960 errorMessage = "unexpected token '"+ e.currentToken.next.image+"', expression expected";
1962 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1963 errorEnd = jj_input_stream.getPosition() + 1;
1966 {inclusionStatement = new InclusionStatement(currentSegment,
1970 currentSegment.add(inclusionStatement);
1974 } catch (ParseException e) {
1975 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1977 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1978 errorEnd = jj_input_stream.getPosition() + 1;
1981 {return inclusionStatement;}
1984 PrintExpression PrintExpression() :
1986 final Expression expr;
1987 final int pos = SimpleCharStream.getPosition();
1990 <PRINT> expr = Expression() {return new PrintExpression(expr,pos,SimpleCharStream.getPosition());}
1993 ListExpression ListExpression() :
1996 Expression expression = null;
1997 ArrayList list = new ArrayList();
1998 final int pos = SimpleCharStream.getPosition();
2004 } catch (ParseException e) {
2005 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected";
2007 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2008 errorEnd = jj_input_stream.getPosition() + 1;
2012 expr = VariableDeclaratorId()
2015 {if (expr == null) list.add(null);}
2019 } catch (ParseException e) {
2020 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected";
2022 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2023 errorEnd = jj_input_stream.getPosition() + 1;
2026 expr = VariableDeclaratorId()
2031 } catch (ParseException e) {
2032 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected";
2034 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2035 errorEnd = jj_input_stream.getPosition() + 1;
2038 [ <ASSIGN> expression = Expression()
2040 String[] strings = new String[list.size()];
2041 list.toArray(strings);
2042 return new ListExpression(strings,
2045 SimpleCharStream.getPosition());}
2048 String[] strings = new String[list.size()];
2049 list.toArray(strings);
2050 return new ListExpression(strings,pos,SimpleCharStream.getPosition());}
2054 * An echo statement.
2055 * echo anyexpression (, otherexpression)*
2057 EchoStatement EchoStatement() :
2059 final ArrayList expressions = new ArrayList();
2061 final int pos = SimpleCharStream.getPosition();
2064 <ECHO> expr = Expression()
2065 {expressions.add(expr);}
2067 <COMMA> expr = Expression()
2068 {expressions.add(expr);}
2073 Expression[] exprs = new Expression[expressions.size()];
2074 expressions.toArray(exprs);
2075 return new EchoStatement(exprs,pos);}
2076 } catch (ParseException e) {
2077 if (e.currentToken.next.kind != 4) {
2078 errorMessage = "';' expected after 'echo' statement";
2080 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2081 errorEnd = jj_input_stream.getPosition() + 1;
2087 GlobalStatement GlobalStatement() :
2089 final int pos = jj_input_stream.getPosition();
2091 ArrayList vars = new ArrayList();
2092 GlobalStatement global;
2096 expr = VariableDeclaratorId()
2099 expr = VariableDeclaratorId()
2105 String[] strings = new String[vars.size()];
2106 vars.toArray(strings);
2107 global = new GlobalStatement(currentSegment,
2110 SimpleCharStream.getPosition());
2111 currentSegment.add(global);
2113 } catch (ParseException e) {
2114 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected";
2116 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2117 errorEnd = jj_input_stream.getPosition() + 1;
2122 StaticStatement StaticStatement() :
2124 final int pos = SimpleCharStream.getPosition();
2125 final ArrayList vars = new ArrayList();
2126 VariableDeclaration expr;
2129 <STATIC> expr = VariableDeclarator() {vars.add(new String(expr.name));}
2130 (<COMMA> expr = VariableDeclarator() {vars.add(new String(expr.name));})*
2134 String[] strings = new String[vars.size()];
2135 vars.toArray(strings);
2136 return new StaticStatement(strings,
2138 SimpleCharStream.getPosition());}
2139 } catch (ParseException e) {
2140 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected";
2142 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2143 errorEnd = jj_input_stream.getPosition() + 1;
2148 LabeledStatement LabeledStatement() :
2150 final int pos = SimpleCharStream.getPosition();
2152 final Statement statement;
2155 label = <IDENTIFIER> <COLON> statement = Statement()
2156 {return new LabeledStatement(label.image.toCharArray(),statement,pos,SimpleCharStream.getPosition());}
2168 final int pos = SimpleCharStream.getPosition();
2169 final ArrayList list = new ArrayList();
2170 Statement statement;
2175 } catch (ParseException e) {
2176 errorMessage = "'{' expected";
2178 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2179 errorEnd = jj_input_stream.getPosition() + 1;
2182 ( statement = BlockStatement() {list.add(statement);}
2183 | statement = htmlBlock() {list.add(statement);})*
2186 } catch (ParseException e) {
2187 errorMessage = "unexpected token : '"+ e.currentToken.image +"', '}' expected";
2189 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2190 errorEnd = jj_input_stream.getPosition() + 1;
2194 Statement[] statements = new Statement[list.size()];
2195 list.toArray(statements);
2196 return new Block(statements,pos,SimpleCharStream.getPosition());}
2199 Statement BlockStatement() :
2201 final Statement statement;
2204 statement = Statement() {return statement;}
2205 | statement = ClassDeclaration() {return statement;}
2206 | statement = MethodDeclaration() {return statement;}
2210 * A Block statement that will not contain any 'break'
2212 Statement BlockStatementNoBreak() :
2214 final Statement statement;
2217 statement = StatementNoBreak() {return statement;}
2218 | statement = ClassDeclaration() {return statement;}
2219 | statement = MethodDeclaration() {return statement;}
2222 VariableDeclaration[] LocalVariableDeclaration() :
2224 final ArrayList list = new ArrayList();
2225 VariableDeclaration var;
2228 var = LocalVariableDeclarator()
2230 ( <COMMA> var = LocalVariableDeclarator() {list.add(var);})*
2232 VariableDeclaration[] vars = new VariableDeclaration[list.size()];
2237 VariableDeclaration LocalVariableDeclarator() :
2239 final String varName;
2240 Expression initializer = null;
2241 final int pos = SimpleCharStream.getPosition();
2244 varName = VariableDeclaratorId() [ <ASSIGN> initializer = Expression() ]
2246 if (initializer == null) {
2247 return new VariableDeclaration(currentSegment,
2248 varName.toCharArray(),
2250 jj_input_stream.getPosition());
2252 return new VariableDeclaration(currentSegment,
2253 varName.toCharArray(),
2259 EmptyStatement EmptyStatement() :
2265 {pos = SimpleCharStream.getPosition();
2266 return new EmptyStatement(pos-1,pos);}
2269 Statement StatementExpression() :
2271 Expression expr,expr2;
2275 expr = PreIncDecExpression() {return expr;}
2277 expr = PrimaryExpression()
2278 [ <INCR> {return new PostfixedUnaryExpression(expr,
2279 OperatorIds.PLUS_PLUS,
2280 SimpleCharStream.getPosition());}
2281 | <DECR> {return new PostfixedUnaryExpression(expr,
2282 OperatorIds.MINUS_MINUS,
2283 SimpleCharStream.getPosition());}
2284 | operator = AssignmentOperator() expr2 = Expression()
2285 {return new BinaryExpression(expr,expr2,operator);}
2290 SwitchStatement SwitchStatement() :
2292 final Expression variable;
2293 final AbstractCase[] cases;
2294 final int pos = SimpleCharStream.getPosition();
2300 } catch (ParseException e) {
2301 errorMessage = "'(' expected after 'switch'";
2303 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2304 errorEnd = jj_input_stream.getPosition() + 1;
2308 variable = Expression()
2309 } catch (ParseException e) {
2310 if (errorMessage != null) {
2313 errorMessage = "expression expected";
2315 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2316 errorEnd = jj_input_stream.getPosition() + 1;
2321 } catch (ParseException e) {
2322 errorMessage = "')' expected";
2324 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2325 errorEnd = jj_input_stream.getPosition() + 1;
2328 (cases = switchStatementBrace() | cases = switchStatementColon(pos, pos + 6))
2329 {return new SwitchStatement(variable,cases,pos,SimpleCharStream.getPosition());}
2332 AbstractCase[] switchStatementBrace() :
2335 final ArrayList cases = new ArrayList();
2339 ( cas = switchLabel0() {cases.add(cas);})*
2343 AbstractCase[] abcase = new AbstractCase[cases.size()];
2344 cases.toArray(abcase);
2346 } catch (ParseException e) {
2347 errorMessage = "'}' expected";
2349 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2350 errorEnd = jj_input_stream.getPosition() + 1;
2355 * A Switch statement with : ... endswitch;
2356 * @param start the begin offset of the switch
2357 * @param end the end offset of the switch
2359 AbstractCase[] switchStatementColon(final int start, final int end) :
2362 final ArrayList cases = new ArrayList();
2367 setMarker(fileToParse,
2368 "Ugly syntax detected, you should switch () {...} instead of switch (): ... enswitch;",
2372 "Line " + token.beginLine);
2373 } catch (CoreException e) {
2374 PHPeclipsePlugin.log(e);
2376 ( cas = switchLabel0() {cases.add(cas);})*
2379 } catch (ParseException e) {
2380 errorMessage = "'endswitch' expected";
2382 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2383 errorEnd = jj_input_stream.getPosition() + 1;
2389 AbstractCase[] abcase = new AbstractCase[cases.size()];
2390 cases.toArray(abcase);
2392 } catch (ParseException e) {
2393 errorMessage = "';' expected after 'endswitch' keyword";
2395 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2396 errorEnd = jj_input_stream.getPosition() + 1;
2401 AbstractCase switchLabel0() :
2403 final Expression expr;
2404 Statement statement;
2405 final ArrayList stmts = new ArrayList();
2406 final int pos = SimpleCharStream.getPosition();
2409 expr = SwitchLabel()
2410 ( statement = BlockStatementNoBreak() {stmts.add(statement);}
2411 | statement = htmlBlock() {stmts.add(statement);})*
2412 [ statement = BreakStatement() {stmts.add(statement);}]
2414 Statement[] stmtsArray = new Statement[stmts.size()];
2415 stmts.toArray(stmtsArray);
2416 if (expr == null) {//it's a default
2417 return new DefaultCase(stmtsArray,pos,SimpleCharStream.getPosition());
2419 return new Case(expr,stmtsArray,pos,SimpleCharStream.getPosition());}
2424 * case Expression() :
2426 * @return the if it was a case and null if not
2428 Expression SwitchLabel() :
2431 final Expression expr;
2437 } catch (ParseException e) {
2438 if (errorMessage != null) throw e;
2439 errorMessage = "expression expected after 'case' keyword";
2441 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2442 errorEnd = jj_input_stream.getPosition() + 1;
2448 } catch (ParseException e) {
2449 errorMessage = "':' expected after case expression";
2451 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2452 errorEnd = jj_input_stream.getPosition() + 1;
2460 } catch (ParseException e) {
2461 errorMessage = "':' expected after 'default' keyword";
2463 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2464 errorEnd = jj_input_stream.getPosition() + 1;
2469 Break BreakStatement() :
2471 Expression expression = null;
2472 final int start = SimpleCharStream.getPosition();
2475 <BREAK> [ expression = Expression() ]
2478 } catch (ParseException e) {
2479 errorMessage = "';' expected after 'break' keyword";
2481 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2482 errorEnd = jj_input_stream.getPosition() + 1;
2485 {return new Break(expression, start, SimpleCharStream.getPosition());}
2488 IfStatement IfStatement() :
2490 final int pos = jj_input_stream.getPosition();
2491 Expression condition;
2492 IfStatement ifStatement;
2495 <IF> condition = Condition("if") ifStatement = IfStatement0(condition, pos,pos+2)
2496 {return ifStatement;}
2500 Expression Condition(final String keyword) :
2502 final Expression condition;
2507 } catch (ParseException e) {
2508 errorMessage = "'(' expected after " + keyword + " keyword";
2510 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length();
2511 errorEnd = errorStart +1;
2512 processParseException(e);
2514 condition = Expression()
2518 } catch (ParseException e) {
2519 errorMessage = "')' expected after " + keyword + " keyword";
2521 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2522 errorEnd = jj_input_stream.getPosition() + 1;
2527 IfStatement IfStatement0(Expression condition, final int start,final int end) :
2529 Statement statement;
2531 final Statement[] statementsArray;
2532 ElseIf elseifStatement;
2533 Else elseStatement = null;
2535 final ArrayList elseIfList = new ArrayList();
2537 int pos = SimpleCharStream.getPosition();
2542 {stmts = new ArrayList();}
2543 ( statement = Statement() {stmts.add(statement);}
2544 | statement = htmlBlock() {stmts.add(statement);})*
2545 {endStatements = SimpleCharStream.getPosition();}
2546 (elseifStatement = ElseIfStatementColon() {elseIfList.add(elseifStatement);})*
2547 [elseStatement = ElseStatementColon()]
2550 setMarker(fileToParse,
2551 "Ugly syntax detected, you should if () {...} instead of if (): ... endif;",
2555 "Line " + token.beginLine);
2556 } catch (CoreException e) {
2557 PHPeclipsePlugin.log(e);
2561 } catch (ParseException e) {
2562 errorMessage = "'endif' expected";
2564 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2565 errorEnd = jj_input_stream.getPosition() + 1;
2570 } catch (ParseException e) {
2571 errorMessage = "';' expected after 'endif' keyword";
2573 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2574 errorEnd = jj_input_stream.getPosition() + 1;
2578 elseIfs = new ElseIf[elseIfList.size()];
2579 elseIfList.toArray(elseIfs);
2580 if (stmts.size() == 1) {
2581 return new IfStatement(condition,
2582 (Statement) stmts.get(0),
2586 SimpleCharStream.getPosition());
2588 statementsArray = new Statement[stmts.size()];
2589 stmts.toArray(statementsArray);
2590 return new IfStatement(condition,
2591 new Block(statementsArray,pos,endStatements),
2595 SimpleCharStream.getPosition());
2600 (stmt = Statement() | stmt = htmlBlock())
2601 ( LOOKAHEAD(1) elseifStatement = ElseIfStatement() {elseIfList.add(elseifStatement);})*
2605 {pos = SimpleCharStream.getPosition();}
2606 statement = Statement()
2607 {elseStatement = new Else(statement,pos,SimpleCharStream.getPosition());}
2608 } catch (ParseException e) {
2609 if (errorMessage != null) {
2612 errorMessage = "unexpected token '"+e.currentToken.next.image+"', a statement was expected";
2614 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2615 errorEnd = jj_input_stream.getPosition() + 1;
2620 elseIfs = new ElseIf[elseIfList.size()];
2621 elseIfList.toArray(elseIfs);
2622 return new IfStatement(condition,
2627 SimpleCharStream.getPosition());}
2630 ElseIf ElseIfStatementColon() :
2632 Expression condition;
2633 Statement statement;
2634 final ArrayList list = new ArrayList();
2635 final int pos = SimpleCharStream.getPosition();
2638 <ELSEIF> condition = Condition("elseif")
2639 <COLON> ( statement = Statement() {list.add(statement);}
2640 | statement = htmlBlock() {list.add(statement);})*
2642 Statement[] stmtsArray = new Statement[list.size()];
2643 list.toArray(stmtsArray);
2644 return new ElseIf(condition,stmtsArray ,pos,SimpleCharStream.getPosition());}
2647 Else ElseStatementColon() :
2649 Statement statement;
2650 final ArrayList list = new ArrayList();
2651 final int pos = SimpleCharStream.getPosition();
2654 <ELSE> <COLON> ( statement = Statement() {list.add(statement);}
2655 | statement = htmlBlock() {list.add(statement);})*
2657 Statement[] stmtsArray = new Statement[list.size()];
2658 list.toArray(stmtsArray);
2659 return new Else(stmtsArray,pos,SimpleCharStream.getPosition());}
2662 ElseIf ElseIfStatement() :
2664 Expression condition;
2665 Statement statement;
2666 final ArrayList list = new ArrayList();
2667 final int pos = SimpleCharStream.getPosition();
2670 <ELSEIF> condition = Condition("elseif") statement = Statement() {list.add(statement);/*todo:do better*/}
2672 Statement[] stmtsArray = new Statement[list.size()];
2673 list.toArray(stmtsArray);
2674 return new ElseIf(condition,stmtsArray,pos,SimpleCharStream.getPosition());}
2677 WhileStatement WhileStatement() :
2679 final Expression condition;
2680 final Statement action;
2681 final int pos = SimpleCharStream.getPosition();
2685 condition = Condition("while")
2686 action = WhileStatement0(pos,pos + 5)
2687 {return new WhileStatement(condition,action,pos,SimpleCharStream.getPosition());}
2690 Statement WhileStatement0(final int start, final int end) :
2692 Statement statement;
2693 final ArrayList stmts = new ArrayList();
2694 final int pos = SimpleCharStream.getPosition();
2697 <COLON> (statement = Statement() {stmts.add(statement);})*
2699 setMarker(fileToParse,
2700 "Ugly syntax detected, you should while () {...} instead of while (): ... endwhile;",
2704 "Line " + token.beginLine);
2705 } catch (CoreException e) {
2706 PHPeclipsePlugin.log(e);
2710 } catch (ParseException e) {
2711 errorMessage = "'endwhile' expected";
2713 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2714 errorEnd = jj_input_stream.getPosition() + 1;
2720 Statement[] stmtsArray = new Statement[stmts.size()];
2721 stmts.toArray(stmtsArray);
2722 return new Block(stmtsArray,pos,SimpleCharStream.getPosition());}
2723 } catch (ParseException e) {
2724 errorMessage = "';' expected after 'endwhile' keyword";
2726 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2727 errorEnd = jj_input_stream.getPosition() + 1;
2731 statement = Statement()
2735 DoStatement DoStatement() :
2737 final Statement action;
2738 final Expression condition;
2739 final int pos = SimpleCharStream.getPosition();
2742 <DO> action = Statement() <WHILE> condition = Condition("while")
2745 {return new DoStatement(condition,action,pos,SimpleCharStream.getPosition());}
2746 } catch (ParseException e) {
2747 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
2749 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2750 errorEnd = jj_input_stream.getPosition() + 1;
2755 ForeachStatement ForeachStatement() :
2757 Statement statement;
2758 Expression expression;
2759 final StringBuffer buff = new StringBuffer();
2760 final int pos = SimpleCharStream.getPosition();
2761 ArrayVariableDeclaration variable;
2767 } catch (ParseException e) {
2768 errorMessage = "'(' expected after 'foreach' keyword";
2770 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2771 errorEnd = jj_input_stream.getPosition() + 1;
2775 expression = Expression()
2776 } catch (ParseException e) {
2777 errorMessage = "variable expected";
2779 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2780 errorEnd = jj_input_stream.getPosition() + 1;
2785 } catch (ParseException e) {
2786 errorMessage = "'as' expected";
2788 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2789 errorEnd = jj_input_stream.getPosition() + 1;
2793 variable = ArrayVariable()
2794 } catch (ParseException e) {
2795 errorMessage = "variable expected";
2797 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2798 errorEnd = jj_input_stream.getPosition() + 1;
2803 } catch (ParseException e) {
2804 errorMessage = "')' expected after 'foreach' keyword";
2806 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2807 errorEnd = jj_input_stream.getPosition() + 1;
2811 statement = Statement()
2812 } catch (ParseException e) {
2813 if (errorMessage != null) throw e;
2814 errorMessage = "statement expected";
2816 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2817 errorEnd = jj_input_stream.getPosition() + 1;
2820 {return new ForeachStatement(expression,
2824 SimpleCharStream.getPosition());}
2828 ForStatement ForStatement() :
2831 final int pos = SimpleCharStream.getPosition();
2832 Statement[] initializations = null;
2833 Expression condition = null;
2834 Statement[] increments = null;
2836 final ArrayList list = new ArrayList();
2837 final int startBlock, endBlock;
2843 } catch (ParseException e) {
2844 errorMessage = "'(' expected after 'for' keyword";
2846 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2847 errorEnd = jj_input_stream.getPosition() + 1;
2850 [ initializations = ForInit() ] <SEMICOLON>
2851 [ condition = Expression() ] <SEMICOLON>
2852 [ increments = StatementExpressionList() ] <RPAREN>
2854 action = Statement()
2855 {return new ForStatement(initializations,condition,increments,action,pos,SimpleCharStream.getPosition());}
2858 {startBlock = SimpleCharStream.getPosition();}
2859 (action = Statement() {list.add(action);})*
2862 setMarker(fileToParse,
2863 "Ugly syntax detected, you should for () {...} instead of for (): ... endfor;",
2865 pos+token.image.length(),
2867 "Line " + token.beginLine);
2868 } catch (CoreException e) {
2869 PHPeclipsePlugin.log(e);
2872 {endBlock = SimpleCharStream.getPosition();}
2875 } catch (ParseException e) {
2876 errorMessage = "'endfor' expected";
2878 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2879 errorEnd = jj_input_stream.getPosition() + 1;
2885 Statement[] stmtsArray = new Statement[list.size()];
2886 list.toArray(stmtsArray);
2887 return new ForStatement(initializations,condition,increments,new Block(stmtsArray,startBlock,endBlock),pos,SimpleCharStream.getPosition());}
2888 } catch (ParseException e) {
2889 errorMessage = "';' expected after 'endfor' keyword";
2891 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2892 errorEnd = jj_input_stream.getPosition() + 1;
2898 Statement[] ForInit() :
2900 Statement[] statements;
2903 LOOKAHEAD(LocalVariableDeclaration())
2904 statements = LocalVariableDeclaration()
2905 {return statements;}
2907 statements = StatementExpressionList()
2908 {return statements;}
2911 Statement[] StatementExpressionList() :
2913 final ArrayList list = new ArrayList();
2917 expr = StatementExpression() {list.add(expr);}
2918 (<COMMA> StatementExpression() {list.add(expr);})*
2920 Statement[] stmtsArray = new Statement[list.size()];
2921 list.toArray(stmtsArray);
2925 Continue ContinueStatement() :
2927 Expression expr = null;
2928 final int pos = SimpleCharStream.getPosition();
2931 <CONTINUE> [ expr = Expression() ]
2934 {return new Continue(expr,pos,SimpleCharStream.getPosition());}
2935 } catch (ParseException e) {
2936 errorMessage = "';' expected after 'continue' statement";
2938 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2939 errorEnd = jj_input_stream.getPosition() + 1;
2944 ReturnStatement ReturnStatement() :
2946 Expression expr = null;
2947 final int pos = SimpleCharStream.getPosition();
2950 <RETURN> [ expr = Expression() ]
2953 {return new ReturnStatement(expr,pos,SimpleCharStream.getPosition());}
2954 } catch (ParseException e) {
2955 errorMessage = "';' expected after 'return' statement";
2957 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2958 errorEnd = jj_input_stream.getPosition() + 1;