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 variableDeclarationPtr = 0;
874 variableDeclarationStack = new VariableDeclaration[AstStackIncrement];
875 VariableDeclaration[] list;
876 final int pos = SimpleCharStream.getPosition();
879 <VAR> variableDeclaration = VariableDeclarator()
881 pushOnVariableDeclarationStack(variableDeclaration);
882 outlineInfo.addVariable(new String(variableDeclaration.name));
883 currentSegment.add(variableDeclaration);
886 variableDeclaration = VariableDeclarator()
887 {pushOnVariableDeclarationStack(variableDeclaration);
888 outlineInfo.addVariable(new String(variableDeclaration.name));
889 currentSegment.add(variableDeclaration);}
893 } catch (ParseException e) {
894 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected after variable declaration";
896 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
897 errorEnd = jj_input_stream.getPosition() + 1;
901 {list = new VariableDeclaration[variableDeclarationPtr];
902 System.arraycopy(variableDeclarationStack,0,list,0,variableDeclarationPtr);
903 return new FieldDeclaration(list,
905 SimpleCharStream.getPosition());}
908 VariableDeclaration VariableDeclarator() :
910 final String varName, varValue;
911 Expression initializer = null;
912 final int pos = jj_input_stream.getPosition();
915 varName = VariableDeclaratorId()
919 initializer = VariableInitializer()
920 } catch (ParseException e) {
921 errorMessage = "Literal expression expected in variable initializer";
923 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
924 errorEnd = jj_input_stream.getPosition() + 1;
929 if (initializer == null) {
930 return new VariableDeclaration(currentSegment,
931 varName.toCharArray(),
933 jj_input_stream.getPosition());
935 return new VariableDeclaration(currentSegment,
936 varName.toCharArray(),
944 * @return the variable name (with suffix)
946 String VariableDeclaratorId() :
949 Expression expression;
950 final StringBuffer buff = new StringBuffer();
951 final int pos = SimpleCharStream.getPosition();
952 ConstantIdentifier ex;
956 expr = Variable() {buff.append(expr);}
958 {ex = new ConstantIdentifier(expr.toCharArray(),
960 SimpleCharStream.getPosition());}
961 expression = VariableSuffix(ex)
962 {buff.append(expression.toStringExpression());}
964 {return buff.toString();}
965 } catch (ParseException e) {
966 errorMessage = "'$' expected for variable identifier";
968 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
969 errorEnd = jj_input_stream.getPosition() + 1;
976 final StringBuffer buff;
977 Expression expression = null;
982 token = <DOLLAR_ID> [<LBRACE> expression = Expression() <RBRACE>]
984 if (expression == null && !assigning) {
985 return token.image.substring(1);
987 buff = new StringBuffer(token.image);
989 buff.append(expression.toStringExpression());
991 return buff.toString();
994 <DOLLAR> expr = VariableName()
998 String VariableName():
1000 final StringBuffer buff;
1002 Expression expression = null;
1006 <LBRACE> expression = Expression() <RBRACE>
1007 {buff = new StringBuffer('{');
1008 buff.append(expression.toStringExpression());
1010 return buff.toString();}
1012 token = <IDENTIFIER> [<LBRACE> expression = Expression() <RBRACE>]
1014 if (expression == null) {
1017 buff = new StringBuffer(token.image);
1019 buff.append(expression.toStringExpression());
1021 return buff.toString();
1024 <DOLLAR> expr = VariableName()
1026 buff = new StringBuffer('$');
1028 return buff.toString();
1031 token = <DOLLAR_ID> {return token.image;}
1034 Expression VariableInitializer() :
1036 final Expression expr;
1038 final int pos = SimpleCharStream.getPosition();
1044 <MINUS> (token = <INTEGER_LITERAL> | token = <FLOATING_POINT_LITERAL>)
1045 {return new PrefixedUnaryExpression(new NumberLiteral(token.image.toCharArray(),
1047 SimpleCharStream.getPosition()),
1051 <PLUS> (token = <INTEGER_LITERAL> | token = <FLOATING_POINT_LITERAL>)
1052 {return new PrefixedUnaryExpression(new NumberLiteral(token.image.toCharArray(),
1054 SimpleCharStream.getPosition()),
1058 expr = ArrayDeclarator()
1061 token = <IDENTIFIER>
1062 {return new ConstantIdentifier(token.image.toCharArray(),pos,SimpleCharStream.getPosition());}
1065 ArrayVariableDeclaration ArrayVariable() :
1068 Expression expr2 = null;
1071 expr = Expression() [<ARRAYASSIGN> expr2 = Expression()]
1072 {return new ArrayVariableDeclaration(expr,expr2);}
1075 ArrayVariableDeclaration[] ArrayInitializer() :
1077 ArrayVariableDeclaration expr;
1078 final ArrayList list = new ArrayList();
1081 <LPAREN> [ expr = ArrayVariable()
1083 ( LOOKAHEAD(2) <COMMA> expr = ArrayVariable()
1087 [<COMMA> {list.add(null);}]
1090 ArrayVariableDeclaration[] vars = new ArrayVariableDeclaration[list.size()];
1096 * A Method Declaration.
1097 * <b>function</b> MetodDeclarator() Block()
1099 MethodDeclaration MethodDeclaration() :
1101 final MethodDeclaration functionDeclaration;
1102 Token functionToken;
1106 functionToken = <FUNCTION>
1108 functionDeclaration = MethodDeclarator()
1109 {outlineInfo.addVariable(new String(functionDeclaration.name));}
1110 } catch (ParseException e) {
1111 if (errorMessage != null) {
1114 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected";
1116 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1117 errorEnd = jj_input_stream.getPosition() + 1;
1121 if (currentSegment != null) {
1122 currentSegment.add(functionDeclaration);
1123 currentSegment = functionDeclaration;
1125 currentFunction = functionDeclaration;
1129 functionDeclaration.statements = block.statements;
1130 currentFunction = null;
1131 if (currentSegment != null) {
1132 currentSegment = (OutlineableWithChildren) currentSegment.getParent();
1134 return functionDeclaration;
1139 * A MethodDeclarator.
1140 * [&] IDENTIFIER(parameters ...).
1141 * @return a function description for the outline
1143 MethodDeclaration MethodDeclarator() :
1145 final Token identifier;
1146 Token reference = null;
1147 final Hashtable formalParameters;
1148 final int pos = SimpleCharStream.getPosition();
1151 [ reference = <BIT_AND> ]
1152 identifier = <IDENTIFIER>
1153 formalParameters = FormalParameters()
1154 {return new MethodDeclaration(currentSegment,
1155 identifier.image.toCharArray(),
1159 SimpleCharStream.getPosition());}
1163 * FormalParameters follows method identifier.
1164 * (FormalParameter())
1166 Hashtable FormalParameters() :
1169 final StringBuffer buff = new StringBuffer("(");
1170 VariableDeclaration var;
1171 final Hashtable parameters = new Hashtable();
1176 } catch (ParseException e) {
1177 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier";
1179 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1180 errorEnd = jj_input_stream.getPosition() + 1;
1183 [ var = FormalParameter()
1184 {parameters.put(new String(var.name),var);}
1186 <COMMA> var = FormalParameter()
1187 {parameters.put(new String(var.name),var);}
1192 } catch (ParseException e) {
1193 errorMessage = "')' expected";
1195 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1196 errorEnd = jj_input_stream.getPosition() + 1;
1199 {return parameters;}
1203 * A formal parameter.
1204 * $varname[=value] (,$varname[=value])
1206 VariableDeclaration FormalParameter() :
1208 final VariableDeclaration variableDeclaration;
1212 [token = <BIT_AND>] variableDeclaration = VariableDeclarator()
1214 if (token != null) {
1215 variableDeclaration.setReference(true);
1217 return variableDeclaration;}
1220 ConstantIdentifier Type() :
1223 <STRING> {pos = SimpleCharStream.getPosition();
1224 return new ConstantIdentifier(Types.STRING,
1226 | <BOOL> {pos = SimpleCharStream.getPosition();
1227 return new ConstantIdentifier(Types.BOOL,
1229 | <BOOLEAN> {pos = SimpleCharStream.getPosition();
1230 return new ConstantIdentifier(Types.BOOLEAN,
1232 | <REAL> {pos = SimpleCharStream.getPosition();
1233 return new ConstantIdentifier(Types.REAL,
1235 | <DOUBLE> {pos = SimpleCharStream.getPosition();
1236 return new ConstantIdentifier(Types.DOUBLE,
1238 | <FLOAT> {pos = SimpleCharStream.getPosition();
1239 return new ConstantIdentifier(Types.FLOAT,
1241 | <INT> {pos = SimpleCharStream.getPosition();
1242 return new ConstantIdentifier(Types.INT,
1244 | <INTEGER> {pos = SimpleCharStream.getPosition();
1245 return new ConstantIdentifier(Types.INTEGER,
1247 | <OBJECT> {pos = SimpleCharStream.getPosition();
1248 return new ConstantIdentifier(Types.OBJECT,
1252 Expression Expression() :
1254 final Expression expr;
1257 expr = PrintExpression() {return expr;}
1258 | expr = ListExpression() {return expr;}
1259 | LOOKAHEAD(varAssignation())
1260 expr = varAssignation() {return expr;}
1261 | expr = ConditionalExpression() {return expr;}
1265 * A Variable assignation.
1266 * varName (an assign operator) any expression
1268 VarAssignation varAssignation() :
1271 final Expression expression;
1272 final int assignOperator;
1273 final int pos = SimpleCharStream.getPosition();
1276 varName = VariableDeclaratorId()
1277 assignOperator = AssignmentOperator()
1279 expression = Expression()
1280 } catch (ParseException e) {
1281 if (errorMessage != null) {
1284 errorMessage = "expression expected";
1286 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1287 errorEnd = jj_input_stream.getPosition() + 1;
1290 {return new VarAssignation(varName.toCharArray(),
1294 SimpleCharStream.getPosition());}
1297 int AssignmentOperator() :
1300 <ASSIGN> {return VarAssignation.EQUAL;}
1301 | <STARASSIGN> {return VarAssignation.STAR_EQUAL;}
1302 | <SLASHASSIGN> {return VarAssignation.SLASH_EQUAL;}
1303 | <REMASSIGN> {return VarAssignation.REM_EQUAL;}
1304 | <PLUSASSIGN> {return VarAssignation.PLUS_EQUAL;}
1305 | <MINUSASSIGN> {return VarAssignation.MINUS_EQUAL;}
1306 | <LSHIFTASSIGN> {return VarAssignation.LSHIFT_EQUAL;}
1307 | <RSIGNEDSHIFTASSIGN> {return VarAssignation.RSIGNEDSHIFT_EQUAL;}
1308 | <ANDASSIGN> {return VarAssignation.AND_EQUAL;}
1309 | <XORASSIGN> {return VarAssignation.XOR_EQUAL;}
1310 | <ORASSIGN> {return VarAssignation.OR_EQUAL;}
1311 | <DOTASSIGN> {return VarAssignation.DOT_EQUAL;}
1312 | <TILDEEQUAL> {return VarAssignation.TILDE_EQUAL;}
1315 Expression ConditionalExpression() :
1317 final Expression expr;
1318 Expression expr2 = null;
1319 Expression expr3 = null;
1322 expr = ConditionalOrExpression() [ <HOOK> expr2 = Expression() <COLON> expr3 = ConditionalExpression() ]
1324 if (expr3 == null) {
1327 return new ConditionalExpression(expr,expr2,expr3);
1331 Expression ConditionalOrExpression() :
1333 Expression expr,expr2;
1337 expr = ConditionalAndExpression()
1340 <OR_OR> {operator = OperatorIds.OR_OR;}
1341 | <_ORL> {operator = OperatorIds.ORL;}
1342 ) expr2 = ConditionalAndExpression()
1344 expr = new BinaryExpression(expr,expr2,operator);
1350 Expression ConditionalAndExpression() :
1352 Expression expr,expr2;
1356 expr = ConcatExpression()
1358 ( <AND_AND> {operator = OperatorIds.AND_AND;}
1359 | <_ANDL> {operator = OperatorIds.ANDL;})
1360 expr2 = ConcatExpression() {expr = new BinaryExpression(expr,expr2,operator);}
1365 Expression ConcatExpression() :
1367 Expression expr,expr2;
1370 expr = InclusiveOrExpression()
1372 <DOT> expr2 = InclusiveOrExpression()
1373 {expr = new BinaryExpression(expr,expr2,OperatorIds.DOT);}
1378 Expression InclusiveOrExpression() :
1380 Expression expr,expr2;
1383 expr = ExclusiveOrExpression()
1384 (<BIT_OR> expr2 = ExclusiveOrExpression()
1385 {expr = new BinaryExpression(expr,expr2,OperatorIds.OR);}
1390 Expression ExclusiveOrExpression() :
1392 Expression expr,expr2;
1395 expr = AndExpression()
1397 <XOR> expr2 = AndExpression()
1398 {expr = new BinaryExpression(expr,expr2,OperatorIds.XOR);}
1403 Expression AndExpression() :
1405 Expression expr,expr2;
1408 expr = EqualityExpression()
1410 <BIT_AND> expr2 = EqualityExpression()
1411 {expr = new BinaryExpression(expr,expr2,OperatorIds.AND);}
1416 Expression EqualityExpression() :
1418 Expression expr,expr2;
1422 expr = RelationalExpression()
1424 ( <EQUAL_EQUAL> {operator = OperatorIds.EQUAL_EQUAL;}
1425 | <DIF> {operator = OperatorIds.DIF;}
1426 | <NOT_EQUAL> {operator = OperatorIds.DIF;}
1427 | <BANGDOUBLEEQUAL> {operator = OperatorIds.BANG_EQUAL_EQUAL;}
1428 | <TRIPLEEQUAL> {operator = OperatorIds.EQUAL_EQUAL_EQUAL;}
1431 expr2 = RelationalExpression()
1432 } catch (ParseException e) {
1433 if (errorMessage != null) {
1436 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected";
1438 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1439 errorEnd = jj_input_stream.getPosition() + 1;
1443 expr = new BinaryExpression(expr,expr2,operator);
1449 Expression RelationalExpression() :
1451 Expression expr,expr2;
1455 expr = ShiftExpression()
1457 ( <LT> {operator = OperatorIds.LESS;}
1458 | <GT> {operator = OperatorIds.GREATER;}
1459 | <LE> {operator = OperatorIds.LESS_EQUAL;}
1460 | <GE> {operator = OperatorIds.GREATER_EQUAL;})
1461 expr2 = ShiftExpression()
1462 {expr = new BinaryExpression(expr,expr2,operator);}
1467 Expression ShiftExpression() :
1469 Expression expr,expr2;
1473 expr = AdditiveExpression()
1475 ( <LSHIFT> {operator = OperatorIds.LEFT_SHIFT;}
1476 | <RSIGNEDSHIFT> {operator = OperatorIds.RIGHT_SHIFT;}
1477 | <RUNSIGNEDSHIFT> {operator = OperatorIds.UNSIGNED_RIGHT_SHIFT;})
1478 expr2 = AdditiveExpression()
1479 {expr = new BinaryExpression(expr,expr2,operator);}
1484 Expression AdditiveExpression() :
1486 Expression expr,expr2;
1490 expr = MultiplicativeExpression()
1492 ( <PLUS> {operator = OperatorIds.PLUS;}
1493 | <MINUS> {operator = OperatorIds.MINUS;} )
1494 expr2 = MultiplicativeExpression()
1495 {expr = new BinaryExpression(expr,expr2,operator);}
1500 Expression MultiplicativeExpression() :
1502 Expression expr,expr2;
1507 expr = UnaryExpression()
1508 } catch (ParseException e) {
1509 if (errorMessage != null) {
1512 errorMessage = "unexpected token '"+e.currentToken.next.image+"'";
1514 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1515 errorEnd = jj_input_stream.getPosition() + 1;
1519 ( <STAR> {operator = OperatorIds.MULTIPLY;}
1520 | <SLASH> {operator = OperatorIds.DIVIDE;}
1521 | <REMAINDER> {operator = OperatorIds.REMAINDER;})
1522 expr2 = UnaryExpression()
1523 {expr = new BinaryExpression(expr,expr2,operator);}
1529 * An unary expression starting with @, & or nothing
1531 Expression UnaryExpression() :
1534 final int pos = SimpleCharStream.getPosition();
1537 <BIT_AND> expr = UnaryExpressionNoPrefix()
1538 {return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);}
1540 expr = AtUnaryExpression()
1544 Expression AtUnaryExpression() :
1547 final int pos = SimpleCharStream.getPosition();
1551 expr = AtUnaryExpression()
1552 {return new PrefixedUnaryExpression(expr,OperatorIds.AT,pos);}
1554 expr = UnaryExpressionNoPrefix()
1559 Expression UnaryExpressionNoPrefix() :
1563 final int pos = SimpleCharStream.getPosition();
1566 ( <PLUS> {operator = OperatorIds.PLUS;}
1567 | <MINUS> {operator = OperatorIds.MINUS;})
1568 expr = UnaryExpression()
1569 {return new PrefixedUnaryExpression(expr,operator,pos);}
1571 expr = PreIncDecExpression()
1574 expr = UnaryExpressionNotPlusMinus()
1579 Expression PreIncDecExpression() :
1581 final Expression expr;
1583 final int pos = SimpleCharStream.getPosition();
1586 ( <INCR> {operator = OperatorIds.PLUS_PLUS;}
1587 | <DECR> {operator = OperatorIds.MINUS_MINUS;})
1588 expr = PrimaryExpression()
1589 {return new PrefixedUnaryExpression(expr,operator,pos);}
1592 Expression UnaryExpressionNotPlusMinus() :
1595 final int pos = SimpleCharStream.getPosition();
1598 <BANG> expr = UnaryExpression() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
1599 | LOOKAHEAD( <LPAREN> (Type() | <ARRAY>) <RPAREN> )
1600 expr = CastExpression() {return expr;}
1601 | expr = PostfixExpression() {return expr;}
1602 | expr = Literal() {return expr;}
1603 | <LPAREN> expr = Expression()
1606 } catch (ParseException e) {
1607 errorMessage = "')' expected";
1609 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1610 errorEnd = jj_input_stream.getPosition() + 1;
1616 CastExpression CastExpression() :
1618 final ConstantIdentifier type;
1619 final Expression expr;
1620 final int pos = SimpleCharStream.getPosition();
1625 | <ARRAY> {type = new ConstantIdentifier(Types.ARRAY,pos,SimpleCharStream.getPosition());})
1626 <RPAREN> expr = UnaryExpression()
1627 {return new CastExpression(type,expr,pos,SimpleCharStream.getPosition());}
1630 Expression PostfixExpression() :
1634 final int pos = SimpleCharStream.getPosition();
1637 expr = PrimaryExpression()
1638 [ <INCR> {operator = OperatorIds.PLUS_PLUS;}
1639 | <DECR> {operator = OperatorIds.MINUS_MINUS;}]
1641 if (operator == -1) {
1644 return new PostfixedUnaryExpression(expr,operator,pos);
1648 Expression PrimaryExpression() :
1650 final Token identifier;
1652 final StringBuffer buff = new StringBuffer();
1653 final int pos = SimpleCharStream.getPosition();
1657 identifier = <IDENTIFIER> <STATICCLASSACCESS> expr = ClassIdentifier()
1658 {expr = new ClassAccess(new ConstantIdentifier(identifier.image.toCharArray(),
1660 SimpleCharStream.getPosition()),
1662 ClassAccess.STATIC);}
1663 (expr = PrimarySuffix(expr))*
1666 expr = PrimaryPrefix()
1667 (expr = PrimarySuffix(expr))*
1670 expr = ArrayDeclarator()
1674 ArrayInitializer ArrayDeclarator() :
1676 final ArrayVariableDeclaration[] vars;
1677 final int pos = SimpleCharStream.getPosition();
1680 <ARRAY> vars = ArrayInitializer()
1681 {return new ArrayInitializer(vars,pos,SimpleCharStream.getPosition());}
1684 Expression PrimaryPrefix() :
1686 final Expression expr;
1689 final int pos = SimpleCharStream.getPosition();
1692 token = <IDENTIFIER> {return new ConstantIdentifier(token.image.toCharArray(),
1694 SimpleCharStream.getPosition());}
1695 | <NEW> expr = ClassIdentifier() {return new PrefixedUnaryExpression(expr,
1698 | var = VariableDeclaratorId() {return new ConstantIdentifier(var.toCharArray(),
1700 SimpleCharStream.getPosition());}
1703 PrefixedUnaryExpression classInstantiation() :
1706 final StringBuffer buff;
1707 final int pos = SimpleCharStream.getPosition();
1710 <NEW> expr = ClassIdentifier()
1712 {buff = new StringBuffer(expr.toStringExpression());}
1713 expr = PrimaryExpression()
1714 {buff.append(expr.toStringExpression());
1715 expr = new ConstantIdentifier(buff.toString().toCharArray(),
1717 SimpleCharStream.getPosition());}
1719 {return new PrefixedUnaryExpression(expr,
1724 ConstantIdentifier ClassIdentifier():
1728 final int pos = SimpleCharStream.getPosition();
1731 token = <IDENTIFIER> {return new ConstantIdentifier(token.image.toCharArray(),
1733 SimpleCharStream.getPosition());}
1734 | expr = VariableDeclaratorId() {return new ConstantIdentifier(expr.toCharArray(),
1736 SimpleCharStream.getPosition());}
1739 AbstractSuffixExpression PrimarySuffix(Expression prefix) :
1741 final AbstractSuffixExpression expr;
1744 expr = Arguments(prefix) {return expr;}
1745 | expr = VariableSuffix(prefix) {return expr;}
1748 AbstractSuffixExpression VariableSuffix(Expression prefix) :
1751 final int pos = SimpleCharStream.getPosition();
1752 Expression expression = null;
1757 expr = VariableName()
1758 } catch (ParseException e) {
1759 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected";
1761 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1762 errorEnd = jj_input_stream.getPosition() + 1;
1765 {return new ClassAccess(prefix,
1766 new ConstantIdentifier(expr.toCharArray(),pos,SimpleCharStream.getPosition()),
1767 ClassAccess.NORMAL);}
1769 <LBRACKET> [ expression = Expression() | expression = Type() ] //Not good
1772 } catch (ParseException e) {
1773 errorMessage = "']' expected";
1775 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1776 errorEnd = jj_input_stream.getPosition() + 1;
1779 {return new ArrayDeclarator(prefix,expression,SimpleCharStream.getPosition());}
1788 token = <INTEGER_LITERAL> {pos = SimpleCharStream.getPosition();
1789 return new NumberLiteral(token.image.toCharArray(),pos-token.image.length(),pos);}
1790 | token = <FLOATING_POINT_LITERAL> {pos = SimpleCharStream.getPosition();
1791 return new NumberLiteral(token.image.toCharArray(),pos-token.image.length(),pos);}
1792 | token = <STRING_LITERAL> {pos = SimpleCharStream.getPosition();
1793 return new StringLiteral(token.image.toCharArray(),pos-token.image.length(),pos);}
1794 | <TRUE> {pos = SimpleCharStream.getPosition();
1795 return new TrueLiteral(pos-4,pos);}
1796 | <FALSE> {pos = SimpleCharStream.getPosition();
1797 return new FalseLiteral(pos-4,pos);}
1798 | <NULL> {pos = SimpleCharStream.getPosition();
1799 return new NullLiteral(pos-4,pos);}
1802 FunctionCall Arguments(Expression func) :
1804 ArgumentDeclaration[] args = null;
1807 <LPAREN> [ args = ArgumentList() ]
1810 } catch (ParseException e) {
1811 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list";
1813 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1814 errorEnd = jj_input_stream.getPosition() + 1;
1817 {return new FunctionCall(func,args,SimpleCharStream.getPosition());}
1820 ArgumentDeclaration[] ArgumentList() :
1822 ArgumentDeclaration arg;
1823 final ArrayList list = new ArrayList();
1824 ArgumentDeclaration argument;
1827 arg = argumentDeclaration()
1831 arg = argumentDeclaration()
1833 } catch (ParseException e) {
1834 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list";
1836 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1837 errorEnd = jj_input_stream.getPosition() + 1;
1842 ArgumentDeclaration[] args = new ArgumentDeclaration[list.size()];
1847 ArgumentDeclaration argumentDeclaration() :
1849 boolean reference = false;
1851 Expression initializer = null;
1852 final int pos = SimpleCharStream.getPosition();
1855 [<BIT_AND> {reference = true;}]
1856 varName = VariableDeclaratorId()
1860 initializer = VariableInitializer()
1861 } catch (ParseException e) {
1862 errorMessage = "Literal expression expected in variable initializer";
1864 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1865 errorEnd = jj_input_stream.getPosition() + 1;
1870 if (initializer == null) {
1871 return new ArgumentDeclaration(varName.toCharArray(),
1875 return new ArgumentDeclaration(varName.toCharArray(),
1882 * A Statement without break.
1884 Statement StatementNoBreak() :
1886 final Statement statement;
1891 statement = Expression()
1894 } catch (ParseException e) {
1895 if (e.currentToken.next.kind != 4) {
1896 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1898 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1899 errorEnd = jj_input_stream.getPosition() + 1;
1905 statement = LabeledStatement() {return statement;}
1906 | statement = Block() {return statement;}
1907 | statement = EmptyStatement() {return statement;}
1908 | statement = StatementExpression()
1911 } catch (ParseException e) {
1912 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1914 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1915 errorEnd = jj_input_stream.getPosition() + 1;
1919 | statement = SwitchStatement() {return statement;}
1920 | statement = IfStatement() {return statement;}
1921 | statement = WhileStatement() {return statement;}
1922 | statement = DoStatement() {return statement;}
1923 | statement = ForStatement() {return statement;}
1924 | statement = ForeachStatement() {return statement;}
1925 | statement = ContinueStatement() {return statement;}
1926 | statement = ReturnStatement() {return statement;}
1927 | statement = EchoStatement() {return statement;}
1928 | [token=<AT>] statement = IncludeStatement()
1929 {if (token != null) {
1930 ((InclusionStatement)statement).silent = true;
1933 | statement = StaticStatement() {return statement;}
1934 | statement = GlobalStatement() {return statement;}
1938 * A Normal statement.
1940 Statement Statement() :
1942 final Statement statement;
1945 statement = StatementNoBreak() {return statement;}
1946 | statement = BreakStatement() {return statement;}
1950 * An html block inside a php syntax.
1952 HTMLBlock htmlBlock() :
1954 final int startIndex = nodePtr;
1955 AstNode[] blockNodes;
1959 <PHPEND> (phpEchoBlock())*
1961 (<PHPSTARTLONG> | <PHPSTARTSHORT>)
1962 } catch (ParseException e) {
1963 errorMessage = "End of file unexpected, '<?php' expected";
1965 errorStart = jj_input_stream.getPosition();
1966 errorEnd = jj_input_stream.getPosition();
1970 nbNodes = nodePtr-startIndex;
1971 blockNodes = new AstNode[nbNodes];
1972 System.arraycopy(nodes,startIndex,blockNodes,0,nbNodes);
1973 return new HTMLBlock(nodes);}
1977 * An include statement. It's "include" an expression;
1979 InclusionStatement IncludeStatement() :
1981 final Expression expr;
1984 final int pos = jj_input_stream.getPosition();
1985 final InclusionStatement inclusionStatement;
1988 ( <REQUIRE> {keyword = InclusionStatement.REQUIRE;}
1989 | <REQUIRE_ONCE> {keyword = InclusionStatement.REQUIRE_ONCE;}
1990 | <INCLUDE> {keyword = InclusionStatement.INCLUDE;}
1991 | <INCLUDE_ONCE> {keyword = InclusionStatement.INCLUDE_ONCE;})
1994 } catch (ParseException e) {
1995 if (errorMessage != null) {
1998 errorMessage = "unexpected token '"+ e.currentToken.next.image+"', expression expected";
2000 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2001 errorEnd = jj_input_stream.getPosition() + 1;
2004 {inclusionStatement = new InclusionStatement(currentSegment,
2008 currentSegment.add(inclusionStatement);
2012 } catch (ParseException e) {
2013 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
2015 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2016 errorEnd = jj_input_stream.getPosition() + 1;
2019 {return inclusionStatement;}
2022 PrintExpression PrintExpression() :
2024 final Expression expr;
2025 final int pos = SimpleCharStream.getPosition();
2028 <PRINT> expr = Expression() {return new PrintExpression(expr,pos,SimpleCharStream.getPosition());}
2031 ListExpression ListExpression() :
2034 Expression expression = null;
2035 ArrayList list = new ArrayList();
2036 final int pos = SimpleCharStream.getPosition();
2042 } catch (ParseException e) {
2043 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected";
2045 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2046 errorEnd = jj_input_stream.getPosition() + 1;
2050 expr = VariableDeclaratorId()
2053 {if (expr == null) list.add(null);}
2057 } catch (ParseException e) {
2058 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected";
2060 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2061 errorEnd = jj_input_stream.getPosition() + 1;
2064 expr = VariableDeclaratorId()
2069 } catch (ParseException e) {
2070 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected";
2072 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2073 errorEnd = jj_input_stream.getPosition() + 1;
2076 [ <ASSIGN> expression = Expression()
2078 String[] strings = new String[list.size()];
2079 list.toArray(strings);
2080 return new ListExpression(strings,
2083 SimpleCharStream.getPosition());}
2086 String[] strings = new String[list.size()];
2087 list.toArray(strings);
2088 return new ListExpression(strings,pos,SimpleCharStream.getPosition());}
2092 * An echo statement.
2093 * echo anyexpression (, otherexpression)*
2095 EchoStatement EchoStatement() :
2097 final ArrayList expressions = new ArrayList();
2099 final int pos = SimpleCharStream.getPosition();
2102 <ECHO> expr = Expression()
2103 {expressions.add(expr);}
2105 <COMMA> expr = Expression()
2106 {expressions.add(expr);}
2111 Expression[] exprs = new Expression[expressions.size()];
2112 expressions.toArray(exprs);
2113 return new EchoStatement(exprs,pos);}
2114 } catch (ParseException e) {
2115 if (e.currentToken.next.kind != 4) {
2116 errorMessage = "';' expected after 'echo' statement";
2118 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2119 errorEnd = jj_input_stream.getPosition() + 1;
2125 GlobalStatement GlobalStatement() :
2127 final int pos = jj_input_stream.getPosition();
2129 ArrayList vars = new ArrayList();
2130 GlobalStatement global;
2134 expr = VariableDeclaratorId()
2137 expr = VariableDeclaratorId()
2143 String[] strings = new String[vars.size()];
2144 vars.toArray(strings);
2145 global = new GlobalStatement(currentSegment,
2148 SimpleCharStream.getPosition());
2149 currentSegment.add(global);
2151 } catch (ParseException e) {
2152 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected";
2154 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2155 errorEnd = jj_input_stream.getPosition() + 1;
2160 StaticStatement StaticStatement() :
2162 final int pos = SimpleCharStream.getPosition();
2163 final ArrayList vars = new ArrayList();
2164 VariableDeclaration expr;
2167 <STATIC> expr = VariableDeclarator() {vars.add(new String(expr.name));}
2168 (<COMMA> expr = VariableDeclarator() {vars.add(new String(expr.name));})*
2172 String[] strings = new String[vars.size()];
2173 vars.toArray(strings);
2174 return new StaticStatement(strings,
2176 SimpleCharStream.getPosition());}
2177 } catch (ParseException e) {
2178 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected";
2180 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2181 errorEnd = jj_input_stream.getPosition() + 1;
2186 LabeledStatement LabeledStatement() :
2188 final int pos = SimpleCharStream.getPosition();
2190 final Statement statement;
2193 label = <IDENTIFIER> <COLON> statement = Statement()
2194 {return new LabeledStatement(label.image.toCharArray(),statement,pos,SimpleCharStream.getPosition());}
2206 final int pos = SimpleCharStream.getPosition();
2207 Statement[] statements;
2208 Statement statement;
2209 final int startingPtr = statementPtr;
2215 } catch (ParseException e) {
2216 errorMessage = "'{' expected";
2218 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2219 errorEnd = jj_input_stream.getPosition() + 1;
2222 ( statement = BlockStatement() {pushOnStatementStack(statement);}
2223 | statement = htmlBlock() {pushOnStatementStack(statement);})*
2226 } catch (ParseException e) {
2227 errorMessage = "unexpected token : '"+ e.currentToken.image +"', '}' expected";
2229 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2230 errorEnd = jj_input_stream.getPosition() + 1;
2234 length = statementPtr-startingPtr+1;
2235 statements = new Statement[length];
2236 System.arraycopy(variableDeclarationStack,startingPtr+1,statements,0,length);
2237 statementPtr = startingPtr;
2238 return new Block(statements,pos,SimpleCharStream.getPosition());}
2241 Statement BlockStatement() :
2243 final Statement statement;
2246 statement = Statement() {return statement;}
2247 | statement = ClassDeclaration() {return statement;}
2248 | statement = MethodDeclaration() {return statement;}
2252 * A Block statement that will not contain any 'break'
2254 Statement BlockStatementNoBreak() :
2256 final Statement statement;
2259 statement = StatementNoBreak() {return statement;}
2260 | statement = ClassDeclaration() {return statement;}
2261 | statement = MethodDeclaration() {return statement;}
2264 VariableDeclaration[] LocalVariableDeclaration() :
2266 final ArrayList list = new ArrayList();
2267 VariableDeclaration var;
2270 var = LocalVariableDeclarator()
2272 ( <COMMA> var = LocalVariableDeclarator() {list.add(var);})*
2274 VariableDeclaration[] vars = new VariableDeclaration[list.size()];
2279 VariableDeclaration LocalVariableDeclarator() :
2281 final String varName;
2282 Expression initializer = null;
2283 final int pos = SimpleCharStream.getPosition();
2286 varName = VariableDeclaratorId() [ <ASSIGN> initializer = Expression() ]
2288 if (initializer == null) {
2289 return new VariableDeclaration(currentSegment,
2290 varName.toCharArray(),
2292 jj_input_stream.getPosition());
2294 return new VariableDeclaration(currentSegment,
2295 varName.toCharArray(),
2301 EmptyStatement EmptyStatement() :
2307 {pos = SimpleCharStream.getPosition();
2308 return new EmptyStatement(pos-1,pos);}
2311 Statement StatementExpression() :
2316 expr = PreIncDecExpression() {return expr;}
2318 expr = PrimaryExpression()
2319 [ <INCR> {expr = new PostfixedUnaryExpression(expr,
2320 OperatorIds.PLUS_PLUS,
2321 SimpleCharStream.getPosition());}
2322 | <DECR> {expr = new PostfixedUnaryExpression(expr,
2323 OperatorIds.MINUS_MINUS,
2324 SimpleCharStream.getPosition());}
2325 | AssignmentOperator() Expression() ]
2328 SwitchStatement SwitchStatement() :
2330 final Expression variable;
2331 final AbstractCase[] cases;
2332 final int pos = SimpleCharStream.getPosition();
2338 } catch (ParseException e) {
2339 errorMessage = "'(' expected after 'switch'";
2341 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2342 errorEnd = jj_input_stream.getPosition() + 1;
2346 variable = Expression()
2347 } catch (ParseException e) {
2348 if (errorMessage != null) {
2351 errorMessage = "expression expected";
2353 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2354 errorEnd = jj_input_stream.getPosition() + 1;
2359 } catch (ParseException e) {
2360 errorMessage = "')' expected";
2362 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2363 errorEnd = jj_input_stream.getPosition() + 1;
2366 (cases = switchStatementBrace() | cases = switchStatementColon(pos, pos + 6))
2367 {return new SwitchStatement(variable,cases,pos,SimpleCharStream.getPosition());}
2370 AbstractCase[] switchStatementBrace() :
2373 final ArrayList cases = new ArrayList();
2377 ( cas = switchLabel0() {cases.add(cas);})*
2381 AbstractCase[] abcase = new AbstractCase[cases.size()];
2382 cases.toArray(abcase);
2384 } catch (ParseException e) {
2385 errorMessage = "'}' expected";
2387 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2388 errorEnd = jj_input_stream.getPosition() + 1;
2393 * A Switch statement with : ... endswitch;
2394 * @param start the begin offset of the switch
2395 * @param end the end offset of the switch
2397 AbstractCase[] switchStatementColon(final int start, final int end) :
2400 final ArrayList cases = new ArrayList();
2405 setMarker(fileToParse,
2406 "Ugly syntax detected, you should switch () {...} instead of switch (): ... enswitch;",
2410 "Line " + token.beginLine);
2411 } catch (CoreException e) {
2412 PHPeclipsePlugin.log(e);
2414 ( cas = switchLabel0() {cases.add(cas);})*
2417 } catch (ParseException e) {
2418 errorMessage = "'endswitch' expected";
2420 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2421 errorEnd = jj_input_stream.getPosition() + 1;
2427 AbstractCase[] abcase = new AbstractCase[cases.size()];
2428 cases.toArray(abcase);
2430 } catch (ParseException e) {
2431 errorMessage = "';' expected after 'endswitch' keyword";
2433 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2434 errorEnd = jj_input_stream.getPosition() + 1;
2439 AbstractCase switchLabel0() :
2441 final Expression expr;
2442 Statement statement;
2443 final ArrayList stmts = new ArrayList();
2444 final int pos = SimpleCharStream.getPosition();
2447 expr = SwitchLabel()
2448 ( statement = BlockStatementNoBreak() {stmts.add(statement);}
2449 | statement = htmlBlock() {stmts.add(statement);})*
2450 [ statement = BreakStatement() {stmts.add(statement);}]
2452 Statement[] stmtsArray = new Statement[stmts.size()];
2453 stmts.toArray(stmtsArray);
2454 if (expr == null) {//it's a default
2455 return new DefaultCase(stmtsArray,pos,SimpleCharStream.getPosition());
2457 return new Case(expr,stmtsArray,pos,SimpleCharStream.getPosition());}
2462 * case Expression() :
2464 * @return the if it was a case and null if not
2466 Expression SwitchLabel() :
2469 final Expression expr;
2475 } catch (ParseException e) {
2476 if (errorMessage != null) throw e;
2477 errorMessage = "expression expected after 'case' keyword";
2479 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2480 errorEnd = jj_input_stream.getPosition() + 1;
2486 } catch (ParseException e) {
2487 errorMessage = "':' expected after case expression";
2489 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2490 errorEnd = jj_input_stream.getPosition() + 1;
2498 } catch (ParseException e) {
2499 errorMessage = "':' expected after 'default' keyword";
2501 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2502 errorEnd = jj_input_stream.getPosition() + 1;
2507 Break BreakStatement() :
2509 Expression expression = null;
2510 final int start = SimpleCharStream.getPosition();
2513 <BREAK> [ expression = Expression() ]
2516 } catch (ParseException e) {
2517 errorMessage = "';' expected after 'break' keyword";
2519 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2520 errorEnd = jj_input_stream.getPosition() + 1;
2523 {return new Break(expression, start, SimpleCharStream.getPosition());}
2526 IfStatement IfStatement() :
2528 final int pos = jj_input_stream.getPosition();
2529 Expression condition;
2530 IfStatement ifStatement;
2533 <IF> condition = Condition("if") ifStatement = IfStatement0(condition, pos,pos+2)
2534 {return ifStatement;}
2538 Expression Condition(final String keyword) :
2540 final Expression condition;
2545 } catch (ParseException e) {
2546 errorMessage = "'(' expected after " + keyword + " keyword";
2548 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length();
2549 errorEnd = errorStart +1;
2550 processParseException(e);
2552 condition = Expression()
2556 } catch (ParseException e) {
2557 errorMessage = "')' expected after " + keyword + " keyword";
2559 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2560 errorEnd = jj_input_stream.getPosition() + 1;
2565 IfStatement IfStatement0(Expression condition, final int start,final int end) :
2567 Statement statement;
2569 final Statement[] statementsArray;
2570 ElseIf elseifStatement;
2571 Else elseStatement = null;
2573 final ArrayList elseIfList = new ArrayList();
2575 int pos = SimpleCharStream.getPosition();
2580 {stmts = new ArrayList();}
2581 ( statement = Statement() {stmts.add(statement);}
2582 | statement = htmlBlock() {stmts.add(statement);})*
2583 {endStatements = SimpleCharStream.getPosition();}
2584 (elseifStatement = ElseIfStatementColon() {elseIfList.add(elseifStatement);})*
2585 [elseStatement = ElseStatementColon()]
2588 setMarker(fileToParse,
2589 "Ugly syntax detected, you should if () {...} instead of if (): ... endif;",
2593 "Line " + token.beginLine);
2594 } catch (CoreException e) {
2595 PHPeclipsePlugin.log(e);
2599 } catch (ParseException e) {
2600 errorMessage = "'endif' expected";
2602 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2603 errorEnd = jj_input_stream.getPosition() + 1;
2608 } catch (ParseException e) {
2609 errorMessage = "';' expected after 'endif' keyword";
2611 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2612 errorEnd = jj_input_stream.getPosition() + 1;
2616 elseIfs = new ElseIf[elseIfList.size()];
2617 elseIfList.toArray(elseIfs);
2618 if (stmts.size() == 1) {
2619 return new IfStatement(condition,
2620 (Statement) stmts.get(0),
2624 SimpleCharStream.getPosition());
2626 statementsArray = new Statement[stmts.size()];
2627 stmts.toArray(statementsArray);
2628 return new IfStatement(condition,
2629 new Block(statementsArray,pos,endStatements),
2633 SimpleCharStream.getPosition());
2638 (stmt = Statement() | stmt = htmlBlock())
2639 ( LOOKAHEAD(1) elseifStatement = ElseIfStatement() {elseIfList.add(elseifStatement);})*
2643 {pos = SimpleCharStream.getPosition();}
2644 statement = Statement()
2645 {elseStatement = new Else(statement,pos,SimpleCharStream.getPosition());}
2646 } catch (ParseException e) {
2647 if (errorMessage != null) {
2650 errorMessage = "unexpected token '"+e.currentToken.next.image+"', a statement was expected";
2652 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2653 errorEnd = jj_input_stream.getPosition() + 1;
2658 elseIfs = new ElseIf[elseIfList.size()];
2659 elseIfList.toArray(elseIfs);
2660 return new IfStatement(condition,
2665 SimpleCharStream.getPosition());}
2668 ElseIf ElseIfStatementColon() :
2670 Expression condition;
2671 Statement statement;
2672 final ArrayList list = new ArrayList();
2673 final int pos = SimpleCharStream.getPosition();
2676 <ELSEIF> condition = Condition("elseif")
2677 <COLON> ( statement = Statement() {list.add(statement);}
2678 | statement = htmlBlock() {list.add(statement);})*
2680 Statement[] stmtsArray = new Statement[list.size()];
2681 list.toArray(stmtsArray);
2682 return new ElseIf(condition,stmtsArray ,pos,SimpleCharStream.getPosition());}
2685 Else ElseStatementColon() :
2687 Statement statement;
2688 final ArrayList list = new ArrayList();
2689 final int pos = SimpleCharStream.getPosition();
2692 <ELSE> <COLON> ( statement = Statement() {list.add(statement);}
2693 | statement = htmlBlock() {list.add(statement);})*
2695 Statement[] stmtsArray = new Statement[list.size()];
2696 list.toArray(stmtsArray);
2697 return new Else(stmtsArray,pos,SimpleCharStream.getPosition());}
2700 ElseIf ElseIfStatement() :
2702 Expression condition;
2703 Statement statement;
2704 final ArrayList list = new ArrayList();
2705 final int pos = SimpleCharStream.getPosition();
2708 <ELSEIF> condition = Condition("elseif") statement = Statement() {list.add(statement);/*todo:do better*/}
2710 Statement[] stmtsArray = new Statement[list.size()];
2711 list.toArray(stmtsArray);
2712 return new ElseIf(condition,stmtsArray,pos,SimpleCharStream.getPosition());}
2715 WhileStatement WhileStatement() :
2717 final Expression condition;
2718 final Statement action;
2719 final int pos = SimpleCharStream.getPosition();
2723 condition = Condition("while")
2724 action = WhileStatement0(pos,pos + 5)
2725 {return new WhileStatement(condition,action,pos,SimpleCharStream.getPosition());}
2728 Statement WhileStatement0(final int start, final int end) :
2730 Statement statement;
2731 final ArrayList stmts = new ArrayList();
2732 final int pos = SimpleCharStream.getPosition();
2735 <COLON> (statement = Statement() {stmts.add(statement);})*
2737 setMarker(fileToParse,
2738 "Ugly syntax detected, you should while () {...} instead of while (): ... endwhile;",
2742 "Line " + token.beginLine);
2743 } catch (CoreException e) {
2744 PHPeclipsePlugin.log(e);
2748 } catch (ParseException e) {
2749 errorMessage = "'endwhile' expected";
2751 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2752 errorEnd = jj_input_stream.getPosition() + 1;
2758 Statement[] stmtsArray = new Statement[stmts.size()];
2759 stmts.toArray(stmtsArray);
2760 return new Block(stmtsArray,pos,SimpleCharStream.getPosition());}
2761 } catch (ParseException e) {
2762 errorMessage = "';' expected after 'endwhile' keyword";
2764 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2765 errorEnd = jj_input_stream.getPosition() + 1;
2769 statement = Statement()
2773 DoStatement DoStatement() :
2775 final Statement action;
2776 final Expression condition;
2777 final int pos = SimpleCharStream.getPosition();
2780 <DO> action = Statement() <WHILE> condition = Condition("while")
2783 {return new DoStatement(condition,action,pos,SimpleCharStream.getPosition());}
2784 } catch (ParseException e) {
2785 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
2787 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2788 errorEnd = jj_input_stream.getPosition() + 1;
2793 ForeachStatement ForeachStatement() :
2795 Statement statement;
2796 Expression expression;
2797 final StringBuffer buff = new StringBuffer();
2798 final int pos = SimpleCharStream.getPosition();
2799 ArrayVariableDeclaration variable;
2805 } catch (ParseException e) {
2806 errorMessage = "'(' expected after 'foreach' keyword";
2808 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2809 errorEnd = jj_input_stream.getPosition() + 1;
2813 expression = Expression()
2814 } catch (ParseException e) {
2815 errorMessage = "variable expected";
2817 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2818 errorEnd = jj_input_stream.getPosition() + 1;
2823 } catch (ParseException e) {
2824 errorMessage = "'as' expected";
2826 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2827 errorEnd = jj_input_stream.getPosition() + 1;
2831 variable = ArrayVariable()
2832 } catch (ParseException e) {
2833 errorMessage = "variable expected";
2835 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2836 errorEnd = jj_input_stream.getPosition() + 1;
2841 } catch (ParseException e) {
2842 errorMessage = "')' expected after 'foreach' keyword";
2844 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2845 errorEnd = jj_input_stream.getPosition() + 1;
2849 statement = Statement()
2850 } catch (ParseException e) {
2851 if (errorMessage != null) throw e;
2852 errorMessage = "statement expected";
2854 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2855 errorEnd = jj_input_stream.getPosition() + 1;
2858 {return new ForeachStatement(expression,
2862 SimpleCharStream.getPosition());}
2866 ForStatement ForStatement() :
2869 final int pos = SimpleCharStream.getPosition();
2870 Statement[] initializations = null;
2871 Expression condition = null;
2872 Statement[] increments = null;
2874 final ArrayList list = new ArrayList();
2875 final int startBlock, endBlock;
2881 } catch (ParseException e) {
2882 errorMessage = "'(' expected after 'for' keyword";
2884 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2885 errorEnd = jj_input_stream.getPosition() + 1;
2888 [ initializations = ForInit() ] <SEMICOLON>
2889 [ condition = Expression() ] <SEMICOLON>
2890 [ increments = StatementExpressionList() ] <RPAREN>
2892 action = Statement()
2893 {return new ForStatement(initializations,condition,increments,action,pos,SimpleCharStream.getPosition());}
2896 {startBlock = SimpleCharStream.getPosition();}
2897 (action = Statement() {list.add(action);})*
2900 setMarker(fileToParse,
2901 "Ugly syntax detected, you should for () {...} instead of for (): ... endfor;",
2903 pos+token.image.length(),
2905 "Line " + token.beginLine);
2906 } catch (CoreException e) {
2907 PHPeclipsePlugin.log(e);
2910 {endBlock = SimpleCharStream.getPosition();}
2913 } catch (ParseException e) {
2914 errorMessage = "'endfor' expected";
2916 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2917 errorEnd = jj_input_stream.getPosition() + 1;
2923 Statement[] stmtsArray = new Statement[list.size()];
2924 list.toArray(stmtsArray);
2925 return new ForStatement(initializations,condition,increments,new Block(stmtsArray,startBlock,endBlock),pos,SimpleCharStream.getPosition());}
2926 } catch (ParseException e) {
2927 errorMessage = "';' expected after 'endfor' keyword";
2929 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2930 errorEnd = jj_input_stream.getPosition() + 1;
2936 Statement[] ForInit() :
2938 Statement[] statements;
2941 LOOKAHEAD(LocalVariableDeclaration())
2942 statements = LocalVariableDeclaration()
2943 {return statements;}
2945 statements = StatementExpressionList()
2946 {return statements;}
2949 Statement[] StatementExpressionList() :
2951 final ArrayList list = new ArrayList();
2955 expr = StatementExpression() {list.add(expr);}
2956 (<COMMA> StatementExpression() {list.add(expr);})*
2958 Statement[] stmtsArray = new Statement[list.size()];
2959 list.toArray(stmtsArray);
2963 Continue ContinueStatement() :
2965 Expression expr = null;
2966 final int pos = SimpleCharStream.getPosition();
2969 <CONTINUE> [ expr = Expression() ]
2972 {return new Continue(expr,pos,SimpleCharStream.getPosition());}
2973 } catch (ParseException e) {
2974 errorMessage = "';' expected after 'continue' statement";
2976 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2977 errorEnd = jj_input_stream.getPosition() + 1;
2982 ReturnStatement ReturnStatement() :
2984 Expression expr = null;
2985 final int pos = SimpleCharStream.getPosition();
2988 <RETURN> [ expr = Expression() ]
2991 {return new ReturnStatement(expr,pos,SimpleCharStream.getPosition());}
2992 } catch (ParseException e) {
2993 errorMessage = "';' expected after 'return' statement";
2995 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2996 errorEnd = jj_input_stream.getPosition() + 1;