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.io.StringReader;
35 import java.text.MessageFormat;
37 import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
38 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
39 import net.sourceforge.phpdt.internal.compiler.parser.*;
40 import net.sourceforge.phpdt.internal.compiler.ast.*;
44 * This php parser is inspired by the Java 1.2 grammar example
45 * given with JavaCC. You can get JavaCC at http://www.webgain.com
46 * You can test the parser with the PHPParserTestCase2.java
47 * @author Matthieu Casanova
49 public final class PHPParser extends PHPParserSuperclass {
51 /** The file that is parsed. */
52 private static IFile fileToParse;
54 /** The current segment. */
55 private static PHPSegmentWithChildren currentSegment;
57 private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$
58 private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$
59 PHPOutlineInfo outlineInfo;
61 private static PHPFunctionDeclaration currentFunction;
62 private static boolean assigning;
64 /** The error level of the current ParseException. */
65 private static int errorLevel = ERROR;
66 /** The message of the current ParseException. If it's null it's because the parse exception wasn't handled */
67 private static String errorMessage;
69 private static int errorStart = -1;
70 private static int errorEnd = -1;
73 private final static int AstStackIncrement = 100;
74 /** The stack of node. */
75 private static AstNode[] astStack;
76 /** The cursor in expression stack. */
77 private static int expressionPtr;
79 public final void setFileToParse(final IFile fileToParse) {
80 this.fileToParse = fileToParse;
86 public PHPParser(final IFile fileToParse) {
87 this(new StringReader(""));
88 this.fileToParse = fileToParse;
91 public static final void phpParserTester(final String strEval) throws CoreException, ParseException {
92 PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING);
93 final StringReader stream = new StringReader(strEval);
94 if (jj_input_stream == null) {
95 jj_input_stream = new SimpleCharStream(stream, 1, 1);
97 ReInit(new StringReader(strEval));
98 astStack = new AstNode[AstStackIncrement];
102 public static final void htmlParserTester(final File fileName) throws CoreException, ParseException {
104 final Reader stream = new FileReader(fileName);
105 if (jj_input_stream == null) {
106 jj_input_stream = new SimpleCharStream(stream, 1, 1);
109 astStack = new AstNode[AstStackIncrement];
111 } catch (FileNotFoundException e) {
112 e.printStackTrace(); //To change body of catch statement use Options | File Templates.
116 public static final void htmlParserTester(final String strEval) throws CoreException, ParseException {
117 final StringReader stream = new StringReader(strEval);
118 if (jj_input_stream == null) {
119 jj_input_stream = new SimpleCharStream(stream, 1, 1);
122 astStack = new AstNode[AstStackIncrement];
126 public final PHPOutlineInfo parseInfo(final Object parent, final String s) {
127 outlineInfo = new PHPOutlineInfo(parent);
128 currentSegment = outlineInfo.getDeclarations();
129 final StringReader stream = new StringReader(s);
130 if (jj_input_stream == null) {
131 jj_input_stream = new SimpleCharStream(stream, 1, 1);
134 astStack = new AstNode[AstStackIncrement];
137 } catch (ParseException e) {
138 processParseException(e);
144 * This method will process the parse exception.
145 * If the error message is null, the parse exception wasn't catched and a trace is written in the log
146 * @param e the ParseException
148 private static void processParseException(final ParseException e) {
149 if (errorMessage == null) {
150 PHPeclipsePlugin.log(e);
151 errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it";
152 errorStart = jj_input_stream.getPosition();
153 errorEnd = errorStart + 1;
160 * Create marker for the parse error
161 * @param e the ParseException
163 private static void setMarker(final ParseException e) {
165 if (errorStart == -1) {
166 setMarker(fileToParse,
168 jj_input_stream.tokenBegin,
169 jj_input_stream.tokenBegin + e.currentToken.image.length(),
171 "Line " + e.currentToken.beginLine);
173 setMarker(fileToParse,
178 "Line " + e.currentToken.beginLine);
182 } catch (CoreException e2) {
183 PHPeclipsePlugin.log(e2);
188 * Create markers according to the external parser output
190 private static void createMarkers(final String output, final IFile file) throws CoreException {
191 // delete all markers
192 file.deleteMarkers(IMarker.PROBLEM, false, 0);
197 while ((brIndx = output.indexOf("<br />", indx)) != -1) {
198 // newer php error output (tested with 4.2.3)
199 scanLine(output, file, indx, brIndx);
204 while ((brIndx = output.indexOf("<br>", indx)) != -1) {
205 // older php error output (tested with 4.2.3)
206 scanLine(output, file, indx, brIndx);
212 private static void scanLine(final String output,
215 final int brIndx) throws CoreException {
217 StringBuffer lineNumberBuffer = new StringBuffer(10);
219 current = output.substring(indx, brIndx);
221 if (current.indexOf(PARSE_WARNING_STRING) != -1 || current.indexOf(PARSE_ERROR_STRING) != -1) {
222 int onLine = current.indexOf("on line <b>");
224 lineNumberBuffer.delete(0, lineNumberBuffer.length());
225 for (int i = onLine; i < current.length(); i++) {
226 ch = current.charAt(i);
227 if ('0' <= ch && '9' >= ch) {
228 lineNumberBuffer.append(ch);
232 int lineNumber = Integer.parseInt(lineNumberBuffer.toString());
234 Hashtable attributes = new Hashtable();
236 current = current.replaceAll("\n", "");
237 current = current.replaceAll("<b>", "");
238 current = current.replaceAll("</b>", "");
239 MarkerUtilities.setMessage(attributes, current);
241 if (current.indexOf(PARSE_ERROR_STRING) != -1)
242 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
243 else if (current.indexOf(PARSE_WARNING_STRING) != -1)
244 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
246 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
247 MarkerUtilities.setLineNumber(attributes, lineNumber);
248 MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);
253 public final void parse(final String s) throws CoreException {
254 final StringReader stream = new StringReader(s);
255 if (jj_input_stream == null) {
256 jj_input_stream = new SimpleCharStream(stream, 1, 1);
259 astStack = new AstNode[AstStackIncrement];
262 } catch (ParseException e) {
263 processParseException(e);
268 * Call the php parse command ( php -l -f <filename> )
269 * and create markers according to the external parser output
271 public static void phpExternalParse(final IFile file) {
272 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
273 final String filename = file.getLocation().toString();
275 final String[] arguments = { filename };
276 final MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF));
277 final String command = form.format(arguments);
279 final String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: ");
282 // parse the buffer to find the errors and warnings
283 createMarkers(parserResult, file);
284 } catch (CoreException e) {
285 PHPeclipsePlugin.log(e);
289 private static final void parse() throws ParseException {
294 PARSER_END(PHPParser)
298 <PHPSTARTSHORT : "<?"> : PHPPARSING
299 | <PHPSTARTLONG : "<?php"> : PHPPARSING
300 | <PHPECHOSTART : "<?="> : PHPPARSING
305 <PHPEND :"?>"> : DEFAULT
308 /* Skip any character if we are not in php mode */
326 <PHPPARSING> SPECIAL_TOKEN :
328 "//" : IN_SINGLE_LINE_COMMENT
330 "#" : IN_SINGLE_LINE_COMMENT
332 <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
334 "/*" : IN_MULTI_LINE_COMMENT
337 <IN_SINGLE_LINE_COMMENT> SPECIAL_TOKEN :
339 <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : PHPPARSING
342 <IN_SINGLE_LINE_COMMENT> SPECIAL_TOKEN :
344 <SINGLE_LINE_COMMENT_PHPEND : "?>" > : DEFAULT
350 <FORMAL_COMMENT: "*/" > : PHPPARSING
353 <IN_MULTI_LINE_COMMENT>
356 <MULTI_LINE_COMMENT: "*/" > : PHPPARSING
359 <IN_SINGLE_LINE_COMMENT,IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
369 | <FUNCTION : "function">
372 | <ELSEIF : "elseif">
379 /* LANGUAGE CONSTRUCT */
384 | <INCLUDE : "include">
385 | <REQUIRE : "require">
386 | <INCLUDE_ONCE : "include_once">
387 | <REQUIRE_ONCE : "require_once">
388 | <GLOBAL : "global">
389 | <STATIC : "static">
390 | <CLASSACCESS : "->">
391 | <STATICCLASSACCESS : "::">
392 | <ARRAYASSIGN : "=>">
395 /* RESERVED WORDS AND LITERALS */
401 | <CONTINUE : "continue">
402 | <_DEFAULT : "default">
404 | <EXTENDS : "extends">
409 | <RETURN : "return">
411 | <SWITCH : "switch">
416 | <ENDWHILE : "endwhile">
417 | <ENDSWITCH: "endswitch">
419 | <ENDFOR : "endfor">
420 | <FOREACH : "foreach">
428 | <OBJECT : "object">
430 | <BOOLEAN : "boolean">
432 | <DOUBLE : "double">
435 | <INTEGER : "integer">
448 <DECIMAL_LITERAL> (["l","L"])?
449 | <HEX_LITERAL> (["l","L"])?
450 | <OCTAL_LITERAL> (["l","L"])?
453 < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
455 < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
457 < #OCTAL_LITERAL: "0" (["0"-"7"])* >
459 < FLOATING_POINT_LITERAL:
460 (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
461 | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
462 | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
463 | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
466 < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
468 < STRING_LITERAL: (<STRING_1> | <STRING_2> | <STRING_3>)>
504 < IDENTIFIER: (<LETTER>|<SPECIAL>) (<LETTER>|<DIGIT>|<SPECIAL>)* >
507 ["a"-"z"] | ["A"-"Z"]
515 "_" | ["\u007f"-"\u00ff"]
545 | <BANGDOUBLEEQUAL : "!==">
546 | <TRIPLEEQUAL : "===">
553 | <PLUSASSIGN : "+=">
554 | <MINUSASSIGN : "-=">
555 | <STARASSIGN : "*=">
556 | <SLASHASSIGN : "/=">
562 | <TILDEEQUAL : "~=">
587 | <RSIGNEDSHIFT : ">>">
588 | <RUNSIGNEDSHIFT : ">>>">
589 | <LSHIFTASSIGN : "<<=">
590 | <RSIGNEDSHIFTASSIGN : ">>=">
595 < DOLLAR_ID: <DOLLAR> <IDENTIFIER> >
611 } catch (TokenMgrError e) {
612 PHPeclipsePlugin.log(e);
613 errorStart = SimpleCharStream.getPosition();
614 errorEnd = errorStart + 1;
615 errorMessage = e.getMessage();
617 throw generateParseException();
622 * A php block is a <?= expression [;]?>
623 * or <?php somephpcode ?>
624 * or <? somephpcode ?>
628 final int start = jj_input_stream.getPosition();
636 setMarker(fileToParse,
637 "You should use '<?php' instead of '<?' it will avoid some problems with XML",
639 jj_input_stream.getPosition(),
641 "Line " + token.beginLine);
642 } catch (CoreException e) {
643 PHPeclipsePlugin.log(e);
649 } catch (ParseException e) {
650 errorMessage = "'?>' expected";
652 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
653 errorEnd = jj_input_stream.getPosition() + 1;
658 void phpEchoBlock() :
661 <PHPECHOSTART> Expression() [ <SEMICOLON> ] <PHPEND>
670 void ClassDeclaration() :
672 final PHPClassDeclaration classDeclaration;
673 final Token className;
679 {pos = jj_input_stream.getPosition();}
680 className = <IDENTIFIER>
681 } catch (ParseException e) {
682 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
684 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
685 errorEnd = jj_input_stream.getPosition() + 1;
692 } catch (ParseException e) {
693 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected";
695 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
696 errorEnd = jj_input_stream.getPosition() + 1;
701 if (currentSegment != null) {
702 classDeclaration = new PHPClassDeclaration(currentSegment,className.image,pos);
703 currentSegment.add(classDeclaration);
704 currentSegment = classDeclaration;
709 if (currentSegment != null) {
710 currentSegment = (PHPSegmentWithChildren) currentSegment.getParent();
720 } catch (ParseException e) {
721 errorMessage = "unexpected token : '"+ e.currentToken.next.image + "', '{' expected";
723 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
724 errorEnd = jj_input_stream.getPosition() + 1;
727 ( ClassBodyDeclaration() )*
730 } catch (ParseException e) {
731 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', 'var', 'function' or '}' expected";
733 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
734 errorEnd = jj_input_stream.getPosition() + 1;
740 * A class can contain only methods and fields.
742 void ClassBodyDeclaration() :
751 * A class field declaration : it's var VariableDeclarator() (, VariableDeclarator())*;.
753 void FieldDeclaration() :
755 PHPVarDeclaration variableDeclaration;
758 <VAR> variableDeclaration = VariableDeclarator()
760 if (currentSegment != null) {
761 currentSegment.add(variableDeclaration);
765 variableDeclaration = VariableDeclarator()
767 if (currentSegment != null) {
768 currentSegment.add(variableDeclaration);
774 } catch (ParseException e) {
775 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected after variable declaration";
777 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
778 errorEnd = jj_input_stream.getPosition() + 1;
783 PHPVarDeclaration VariableDeclarator() :
785 final String varName, varValue;
786 final int pos = jj_input_stream.getPosition();
789 varName = VariableDeclaratorId()
793 varValue = VariableInitializer()
794 {return new PHPVarDeclaration(currentSegment,varName,pos,varValue);}
795 } catch (ParseException e) {
796 errorMessage = "Literal expression expected in variable initializer";
798 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
799 errorEnd = jj_input_stream.getPosition() + 1;
803 {return new PHPVarDeclaration(currentSegment,varName,pos);}
806 String VariableDeclaratorId() :
809 final StringBuffer buff = new StringBuffer();
815 ( LOOKAHEAD(2) expr = VariableSuffix()
818 {return buff.toString();}
819 } catch (ParseException e) {
820 errorMessage = "'$' expected for variable identifier";
822 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
823 errorEnd = jj_input_stream.getPosition() + 1;
834 token = <DOLLAR_ID> [<LBRACE> expr = Expression() <RBRACE>]
836 if (expr == null && !assigning) {
837 if (currentFunction != null) {
838 PHPVarDeclaration var = currentFunction.getParameter(token.image.substring(1));
840 var.getVariable().setUsed(true);
843 return token.image.substring(1);
845 return token + "{" + expr + "}";
848 <DOLLAR> expr = VariableName()
852 String VariableName():
858 <LBRACE> expr = Expression() <RBRACE>
859 {return "{"+expr+"}";}
861 token = <IDENTIFIER> [<LBRACE> expr = Expression() <RBRACE>]
864 if (currentFunction != null) {
865 PHPVarDeclaration var = currentFunction.getParameter(token.image);
867 var.getVariable().setUsed(true);
872 return token + "{" + expr + "}";
875 <DOLLAR> expr = VariableName()
877 if (currentFunction != null) {
878 PHPVarDeclaration var = currentFunction.getParameter(expr);
880 var.getVariable().setUsed(true);
888 if (currentFunction != null) {
889 PHPVarDeclaration var = currentFunction.getParameter(token.image.substring(1));
891 var.getVariable().setUsed(true);
894 return token.image + expr;
897 token = <DOLLAR_ID> [expr = VariableName()]
902 return token.image + expr;
906 String VariableInitializer() :
915 <MINUS> (token = <INTEGER_LITERAL> | token = <FLOATING_POINT_LITERAL>)
916 {return "-" + token.image;}
918 <PLUS> (token = <INTEGER_LITERAL> | token = <FLOATING_POINT_LITERAL>)
919 {return "+" + token.image;}
921 expr = ArrayDeclarator()
925 {return token.image;}
928 String ArrayVariable() :
931 final StringBuffer buff = new StringBuffer();
936 [<ARRAYASSIGN> expr = Expression()
937 {buff.append("=>").append(expr);}]
938 {return buff.toString();}
941 String ArrayInitializer() :
944 final StringBuffer buff = new StringBuffer("(");
947 <LPAREN> [ expr = ArrayVariable()
949 ( LOOKAHEAD(2) <COMMA> expr = ArrayVariable()
950 {buff.append(",").append(expr);}
953 [<COMMA> {buff.append(",");}]
957 return buff.toString();
962 * A Method Declaration.
963 * <b>function</b> MetodDeclarator() Block()
965 void MethodDeclaration() :
967 final PHPFunctionDeclaration functionDeclaration;
971 functionToken = <FUNCTION>
973 functionDeclaration = MethodDeclarator()
974 } catch (ParseException e) {
975 if (errorMessage != null) {
978 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected";
980 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
981 errorEnd = jj_input_stream.getPosition() + 1;
985 if (currentSegment != null) {
986 currentSegment.add(functionDeclaration);
987 currentSegment = functionDeclaration;
989 currentFunction = functionDeclaration;
993 Hashtable parameters = currentFunction.getParameters();
994 Enumeration vars = parameters.elements();
995 while (vars.hasMoreElements()) {
996 PHPVarDeclaration o = (PHPVarDeclaration) vars.nextElement();
997 if (!o.getVariable().isUsed()) {
999 setMarker(fileToParse,
1000 "Parameter "+o.getVariable().getName()+" is never used in function",
1001 functionToken.beginLine,
1003 "Line " + token.beginLine);
1004 } catch (CoreException e) {
1005 PHPeclipsePlugin.log(e);
1009 currentFunction = null;
1010 if (currentSegment != null) {
1011 currentSegment = (PHPSegmentWithChildren) currentSegment.getParent();
1017 * A MethodDeclarator.
1018 * [&] IDENTIFIER(parameters ...).
1019 * @return a function description for the outline
1021 PHPFunctionDeclaration MethodDeclarator() :
1023 final Token identifier;
1024 final StringBuffer methodDeclaration = new StringBuffer();
1025 final Hashtable formalParameters;
1026 final int pos = jj_input_stream.getPosition();
1029 [ <BIT_AND> {methodDeclaration.append("&");} ]
1030 identifier = <IDENTIFIER>
1031 formalParameters = FormalParameters()
1033 methodDeclaration.append(identifier);
1034 return new PHPFunctionDeclaration(currentSegment,methodDeclaration.toString(),pos,formalParameters);
1039 * FormalParameters follows method identifier.
1040 * (FormalParameter())
1042 Hashtable FormalParameters() :
1045 final StringBuffer buff = new StringBuffer("(");
1046 PHPVarDeclaration var;
1047 final Hashtable parameters = new Hashtable();
1052 } catch (ParseException e) {
1053 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier";
1055 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1056 errorEnd = jj_input_stream.getPosition() + 1;
1059 [ var = FormalParameter()
1060 {parameters.put(var.getVariable().getName(),var);}
1062 <COMMA> var = FormalParameter()
1063 {parameters.put(var.getVariable().getName(),var);}
1068 } catch (ParseException e) {
1069 errorMessage = "')' expected";
1071 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1072 errorEnd = jj_input_stream.getPosition() + 1;
1075 {return parameters;}
1079 * A formal parameter.
1080 * $varname[=value] (,$varname[=value])
1082 PHPVarDeclaration FormalParameter() :
1084 final PHPVarDeclaration variableDeclaration;
1088 [token = <BIT_AND>] variableDeclaration = VariableDeclarator()
1090 if (token != null) {
1091 variableDeclaration.getVariable().setReference(true);
1093 return variableDeclaration;
1128 String Expression() :
1131 final String assignOperator;
1135 expr = PrintExpression()
1138 expr = ListExpression()
1141 LOOKAHEAD(varAssignation())
1142 expr = varAssignation()
1145 expr = ConditionalExpression()
1150 * A Variable assignation.
1151 * varName (an assign operator) any expression
1153 String varAssignation() :
1155 String varName,assignOperator,expr2;
1156 PHPVarDeclaration variable;
1157 final int pos = SimpleCharStream.getPosition();
1160 varName = VariableDeclaratorId()
1161 assignOperator = AssignmentOperator()
1163 expr2 = Expression()
1164 } catch (ParseException e) {
1165 if (errorMessage != null) {
1168 errorMessage = "expression expected";
1170 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1171 errorEnd = jj_input_stream.getPosition() + 1;
1174 {return varName + assignOperator + expr2;}
1177 String AssignmentOperator() :
1194 | <RSIGNEDSHIFTASSIGN>
1208 String ConditionalExpression() :
1211 String expr2 = null;
1212 String expr3 = null;
1215 expr = ConditionalOrExpression() [ <HOOK> expr2 = Expression() <COLON> expr3 = ConditionalExpression() ]
1217 if (expr3 == null) {
1220 return expr + "?" + expr2 + ":" + expr3;
1225 String ConditionalOrExpression() :
1229 final StringBuffer buff = new StringBuffer();
1232 expr = ConditionalAndExpression()
1233 {buff.append(expr);}
1235 (operator = <SC_OR> | operator = <_ORL>) expr = ConditionalAndExpression()
1237 buff.append(operator.image);
1242 return buff.toString();
1246 String ConditionalAndExpression() :
1250 final StringBuffer buff = new StringBuffer();
1253 expr = ConcatExpression()
1254 {buff.append(expr);}
1256 (operator = <SC_AND> | operator = <_ANDL>) expr = ConcatExpression()
1258 buff.append(operator.image);
1262 {return buff.toString();}
1265 String ConcatExpression() :
1268 final StringBuffer buff = new StringBuffer();
1271 expr = InclusiveOrExpression()
1272 {buff.append(expr);}
1274 <DOT> expr = InclusiveOrExpression()
1275 {buff.append(".").append(expr);}
1277 {return buff.toString();}
1280 String InclusiveOrExpression() :
1283 final StringBuffer buff = new StringBuffer();
1286 expr = ExclusiveOrExpression()
1287 {buff.append(expr);}
1289 <BIT_OR> expr = ExclusiveOrExpression()
1290 {buff.append("|").append(expr);}
1292 {return buff.toString();}
1295 String ExclusiveOrExpression() :
1298 final StringBuffer buff = new StringBuffer();
1301 expr = AndExpression()
1306 <XOR> expr = AndExpression()
1313 return buff.toString();
1317 String AndExpression() :
1320 final StringBuffer buff = new StringBuffer();
1323 expr = EqualityExpression()
1328 <BIT_AND> expr = EqualityExpression()
1330 buff.append("&").append(expr);
1333 {return buff.toString();}
1336 String EqualityExpression() :
1340 final StringBuffer buff = new StringBuffer();
1343 expr = RelationalExpression()
1344 {buff.append(expr);}
1349 | operator = <BANGDOUBLEEQUAL>
1350 | operator = <TRIPLEEQUAL>
1353 expr = RelationalExpression()
1354 } catch (ParseException e) {
1355 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected after '"+operator.image+"'";
1357 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1358 errorEnd = jj_input_stream.getPosition() + 1;
1362 buff.append(operator.image);
1366 {return buff.toString();}
1369 String RelationalExpression() :
1373 final StringBuffer buff = new StringBuffer();
1376 expr = ShiftExpression()
1377 {buff.append(expr);}
1379 ( operator = <LT> | operator = <GT> | operator = <LE> | operator = <GE> ) expr = ShiftExpression()
1380 {buff.append(operator.image).append(expr);}
1382 {return buff.toString();}
1385 String ShiftExpression() :
1389 final StringBuffer buff = new StringBuffer();
1392 expr = AdditiveExpression()
1393 {buff.append(expr);}
1395 (operator = <LSHIFT> | operator = <RSIGNEDSHIFT> | operator = <RUNSIGNEDSHIFT> ) expr = AdditiveExpression()
1397 buff.append(operator.image);
1401 {return buff.toString();}
1404 String AdditiveExpression() :
1408 final StringBuffer buff = new StringBuffer();
1411 expr = MultiplicativeExpression()
1412 {buff.append(expr);}
1414 ( operator = <PLUS> | operator = <MINUS> ) expr = MultiplicativeExpression()
1416 buff.append(operator.image);
1420 {return buff.toString();}
1423 String MultiplicativeExpression() :
1427 final StringBuffer buff = new StringBuffer();}
1430 expr = UnaryExpression()
1431 } catch (ParseException e) {
1432 errorMessage = "unexpected token '"+e.currentToken.next.image+"'";
1434 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1435 errorEnd = jj_input_stream.getPosition() + 1;
1438 {buff.append(expr);}
1440 ( operator = <STAR> | operator = <SLASH> | operator = <REM> ) expr = UnaryExpression()
1442 buff.append(operator.image);
1446 {return buff.toString();}
1450 * An unary expression starting with @, & or nothing
1452 String UnaryExpression() :
1456 final StringBuffer buff = new StringBuffer();
1459 token = <BIT_AND> expr = UnaryExpressionNoPrefix()
1461 if (token == null) {
1464 return token.image + expr;
1467 (<AT> {buff.append("@");})* expr = UnaryExpressionNoPrefix()
1468 {return buff.append(expr).toString();}
1471 String UnaryExpressionNoPrefix() :
1477 ( token = <PLUS> | token = <MINUS> ) expr = UnaryExpression()
1479 return token.image + expr;
1482 expr = PreIncDecExpression()
1485 expr = UnaryExpressionNotPlusMinus()
1490 String PreIncDecExpression() :
1496 (token = <INCR> | token = <DECR>) expr = PrimaryExpression()
1497 {return token.image + expr;}
1500 String UnaryExpressionNotPlusMinus() :
1505 <BANG> expr = UnaryExpression()
1506 {return "!" + expr;}
1508 LOOKAHEAD( <LPAREN> (Type() | <ARRAY>) <RPAREN> )
1509 expr = CastExpression()
1512 expr = PostfixExpression()
1518 <LPAREN> expr = Expression()
1521 } catch (ParseException e) {
1522 errorMessage = "')' expected";
1524 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1525 errorEnd = jj_input_stream.getPosition() + 1;
1528 {return "("+expr+")";}
1531 String CastExpression() :
1533 final String type, expr;
1536 <LPAREN> (type = Type() | <ARRAY> {type = "array";}) <RPAREN> expr = UnaryExpression()
1537 {return "(" + type + ")" + expr;}
1540 String PostfixExpression() :
1543 Token operator = null;
1546 expr = PrimaryExpression() [ operator = <INCR> | operator = <DECR> ]
1548 if (operator == null) {
1551 return expr + operator.image;
1555 String PrimaryExpression() :
1557 final Token identifier;
1559 final StringBuffer buff = new StringBuffer();
1563 identifier = <IDENTIFIER> <STATICCLASSACCESS> expr = ClassIdentifier()
1564 {buff.append(identifier.image).append("::").append(expr);}
1566 expr = PrimarySuffix()
1567 {buff.append(expr);}
1569 {return buff.toString();}
1571 expr = PrimaryPrefix() {buff.append(expr);}
1572 ( expr = PrimarySuffix() {buff.append(expr);} )*
1573 {return buff.toString();}
1575 expr = ArrayDeclarator()
1576 {return "array" + expr;}
1579 String ArrayDeclarator() :
1584 <ARRAY> expr = ArrayInitializer()
1585 {return "array" + expr;}
1588 String PrimaryPrefix() :
1594 token = <IDENTIFIER>
1595 {return token.image;}
1597 <NEW> expr = ClassIdentifier()
1599 return "new " + expr;
1602 expr = VariableDeclaratorId()
1606 String classInstantiation() :
1609 final StringBuffer buff = new StringBuffer("new ");
1612 <NEW> expr = ClassIdentifier()
1613 {buff.append(expr);}
1615 expr = PrimaryExpression()
1616 {buff.append(expr);}
1618 {return buff.toString();}
1621 String ClassIdentifier():
1627 token = <IDENTIFIER>
1628 {return token.image;}
1630 expr = VariableDeclaratorId()
1634 String PrimarySuffix() :
1642 expr = VariableSuffix()
1646 String VariableSuffix() :
1653 expr = VariableName()
1654 } catch (ParseException e) {
1655 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected";
1657 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1658 errorEnd = jj_input_stream.getPosition() + 1;
1661 {return "->" + expr;}
1663 <LBRACKET> [ expr = Expression() | expr = Type() ] //Not good
1666 } catch (ParseException e) {
1667 errorMessage = "']' expected";
1669 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1670 errorEnd = jj_input_stream.getPosition() + 1;
1677 return "[" + expr + "]";
1687 token = <INTEGER_LITERAL>
1688 {return token.image;}
1690 token = <FLOATING_POINT_LITERAL>
1691 {return token.image;}
1693 token = <STRING_LITERAL>
1694 {return token.image;}
1696 expr = BooleanLiteral()
1703 String BooleanLiteral() :
1713 String Arguments() :
1718 <LPAREN> [ expr = ArgumentList() ]
1721 } catch (ParseException e) {
1722 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list";
1724 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1725 errorEnd = jj_input_stream.getPosition() + 1;
1732 return "(" + expr + ")";
1736 String ArgumentList() :
1739 final StringBuffer buff = new StringBuffer();
1743 {buff.append(expr);}
1747 } catch (ParseException e) {
1748 errorMessage = "expression expected after a comma in argument list";
1750 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1751 errorEnd = jj_input_stream.getPosition() + 1;
1755 buff.append(",").append(expr);
1758 {return buff.toString();}
1762 * A Statement without break
1764 void StatementNoBreak() :
1771 } catch (ParseException e) {
1772 if (e.currentToken.next.kind != 4) {
1773 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1775 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1776 errorEnd = jj_input_stream.getPosition() + 1;
1788 StatementExpression()
1791 } catch (ParseException e) {
1792 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1794 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1795 errorEnd = jj_input_stream.getPosition() + 1;
1817 [<AT>] IncludeStatement()
1825 * A Normal statement
1838 <PHPEND> (phpEchoBlock())* (<PHPSTARTLONG> | <PHPSTARTSHORT>)
1842 * An include statement. It's "include" an expression;
1844 void IncludeStatement() :
1848 final int pos = jj_input_stream.getPosition();
1852 | token = <REQUIRE_ONCE>
1854 | token = <INCLUDE_ONCE> )
1857 if (currentSegment != null) {
1858 currentSegment.add(new PHPReqIncDeclaration(currentSegment, token.image,pos,expr));
1863 } catch (ParseException e) {
1864 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1866 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1867 errorEnd = jj_input_stream.getPosition() + 1;
1872 String PrintExpression() :
1874 final StringBuffer buff = new StringBuffer("print ");
1878 <PRINT> expr = Expression()
1881 return buff.toString();
1885 String ListExpression() :
1887 final StringBuffer buff = new StringBuffer("list(");
1894 } catch (ParseException e) {
1895 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected";
1897 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1898 errorEnd = jj_input_stream.getPosition() + 1;
1902 expr = VariableDeclaratorId()
1903 {buff.append(expr);}
1908 } catch (ParseException e) {
1909 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected";
1911 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1912 errorEnd = jj_input_stream.getPosition() + 1;
1915 expr = VariableDeclaratorId()
1916 {buff.append(",").append(expr);}
1921 } catch (ParseException e) {
1922 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected";
1924 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1925 errorEnd = jj_input_stream.getPosition() + 1;
1928 [ <ASSIGN> expr = Expression() {buff.append("(").append(expr);}]
1929 {return buff.toString();}
1933 * An echo statement is like this : echo anyexpression (, otherexpression)*
1935 void EchoStatement() :
1938 <ECHO> Expression() (<COMMA> Expression())*
1941 } catch (ParseException e) {
1942 if (e.currentToken.next.kind != 4) {
1943 errorMessage = "';' expected after 'echo' statement";
1945 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1946 errorEnd = jj_input_stream.getPosition() + 1;
1952 void GlobalStatement() :
1954 final int pos = jj_input_stream.getPosition();
1959 expr = VariableDeclaratorId()
1960 {if (currentSegment != null) {
1961 currentSegment.add(new PHPGlobalDeclaration(currentSegment, "global",pos,expr));
1964 expr = VariableDeclaratorId()
1965 {if (currentSegment != null) {
1966 currentSegment.add(new PHPGlobalDeclaration(currentSegment, "global",pos,expr));
1971 } catch (ParseException e) {
1972 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1974 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1975 errorEnd = jj_input_stream.getPosition() + 1;
1980 void StaticStatement() :
1983 <STATIC> VariableDeclarator() (<COMMA> VariableDeclarator())*
1986 } catch (ParseException e) {
1987 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
1989 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
1990 errorEnd = jj_input_stream.getPosition() + 1;
1995 void LabeledStatement() :
1998 <IDENTIFIER> <COLON> Statement()
2006 } catch (ParseException e) {
2007 errorMessage = "'{' expected";
2009 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2010 errorEnd = jj_input_stream.getPosition() + 1;
2013 ( BlockStatement() | htmlBlock())*
2016 } catch (ParseException e) {
2017 errorMessage = "unexpected token : '"+ e.currentToken.image +"', '}' expected";
2019 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2020 errorEnd = jj_input_stream.getPosition() + 1;
2025 void BlockStatement() :
2036 * A Block statement that will not contain any 'break'
2038 void BlockStatementNoBreak() :
2048 void LocalVariableDeclaration() :
2051 LocalVariableDeclarator() ( <COMMA> LocalVariableDeclarator() )*
2054 void LocalVariableDeclarator() :
2057 VariableDeclaratorId() [ <ASSIGN> Expression() ]
2060 void EmptyStatement() :
2066 void StatementExpression() :
2069 PreIncDecExpression()
2077 AssignmentOperator() Expression()
2081 void SwitchStatement() :
2083 final int pos = jj_input_stream.getPosition();
2089 } catch (ParseException e) {
2090 errorMessage = "'(' expected after 'switch'";
2092 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2093 errorEnd = jj_input_stream.getPosition() + 1;
2098 } catch (ParseException e) {
2099 if (errorMessage != null) {
2102 errorMessage = "expression expected";
2104 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2105 errorEnd = jj_input_stream.getPosition() + 1;
2110 } catch (ParseException e) {
2111 errorMessage = "')' expected";
2113 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2114 errorEnd = jj_input_stream.getPosition() + 1;
2117 (switchStatementBrace() | switchStatementColon(pos, pos + 6))
2120 void switchStatementBrace() :
2127 } catch (ParseException e) {
2128 errorMessage = "'}' expected";
2130 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2131 errorEnd = jj_input_stream.getPosition() + 1;
2136 * A Switch statement with : ... endswitch;
2137 * @param start the begin offset of the switch
2138 * @param end the end offset of the switch
2140 void switchStatementColon(final int start, final int end) :
2145 setMarker(fileToParse,
2146 "Ugly syntax detected, you should switch () {...} instead of switch (): ... enswitch;",
2150 "Line " + token.beginLine);
2151 } catch (CoreException e) {
2152 PHPeclipsePlugin.log(e);
2157 } catch (ParseException e) {
2158 errorMessage = "'endswitch' expected";
2160 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2161 errorEnd = jj_input_stream.getPosition() + 1;
2166 } catch (ParseException e) {
2167 errorMessage = "';' expected after 'endswitch' keyword";
2169 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2170 errorEnd = jj_input_stream.getPosition() + 1;
2175 void switchLabel0() :
2177 Token breakToken = null;
2181 line = SwitchLabel()
2182 ( BlockStatementNoBreak() | htmlBlock() )*
2183 [ breakToken = BreakStatement() ]
2186 if (breakToken == null) {
2187 setMarker(fileToParse,
2188 "You should use put a 'break' at the end of your statement",
2193 } catch (CoreException e) {
2194 PHPeclipsePlugin.log(e);
2199 Token BreakStatement() :
2204 token = <BREAK> [ Expression() ]
2207 } catch (ParseException e) {
2208 errorMessage = "';' expected after 'break' keyword";
2210 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2211 errorEnd = jj_input_stream.getPosition() + 1;
2225 } catch (ParseException e) {
2226 if (errorMessage != null) throw e;
2227 errorMessage = "expression expected after 'case' keyword";
2229 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2230 errorEnd = jj_input_stream.getPosition() + 1;
2235 } catch (ParseException e) {
2236 errorMessage = "':' expected after case expression";
2238 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2239 errorEnd = jj_input_stream.getPosition() + 1;
2242 {return token.beginLine;}
2247 } catch (ParseException e) {
2248 errorMessage = "':' expected after 'default' keyword";
2250 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2251 errorEnd = jj_input_stream.getPosition() + 1;
2254 {return token.beginLine;}
2257 void IfStatement() :
2260 final int pos = jj_input_stream.getPosition();
2263 token = <IF> Condition("if") IfStatement0(pos,pos+token.image.length())
2266 void Condition(final String keyword) :
2271 } catch (ParseException e) {
2272 errorMessage = "'(' expected after " + keyword + " keyword";
2274 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length();
2275 errorEnd = errorStart +1;
2276 processParseException(e);
2281 } catch (ParseException e) {
2282 errorMessage = "')' expected after " + keyword + " keyword";
2284 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2285 errorEnd = jj_input_stream.getPosition() + 1;
2290 void IfStatement0(final int start,final int end) :
2293 <COLON> (Statement() | htmlBlock())* (ElseIfStatementColon())* [ElseStatementColon()]
2296 setMarker(fileToParse,
2297 "Ugly syntax detected, you should if () {...} instead of if (): ... endif;",
2301 "Line " + token.beginLine);
2302 } catch (CoreException e) {
2303 PHPeclipsePlugin.log(e);
2307 } catch (ParseException e) {
2308 errorMessage = "'endif' expected";
2310 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2311 errorEnd = jj_input_stream.getPosition() + 1;
2316 } catch (ParseException e) {
2317 errorMessage = "';' expected after 'endif' keyword";
2319 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2320 errorEnd = jj_input_stream.getPosition() + 1;
2324 (Statement() | htmlBlock())
2325 ( LOOKAHEAD(1) ElseIfStatement() )*
2330 } catch (ParseException e) {
2331 if (errorMessage != null) {
2334 errorMessage = "unexpected token '"+e.currentToken.next.image+"', a statement was expected";
2336 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2337 errorEnd = jj_input_stream.getPosition() + 1;
2343 void ElseIfStatementColon() :
2346 <ELSEIF> Condition("elseif") <COLON> (Statement() | htmlBlock())*
2349 void ElseStatementColon() :
2352 <ELSE> <COLON> (Statement() | htmlBlock())*
2355 void ElseIfStatement() :
2358 <ELSEIF> Condition("elseif") Statement()
2361 void WhileStatement() :
2364 final int pos = jj_input_stream.getPosition();
2367 token = <WHILE> Condition("while") WhileStatement0(pos,pos + token.image.length())
2370 void WhileStatement0(final int start, final int end) :
2373 <COLON> (Statement())*
2375 setMarker(fileToParse,
2376 "Ugly syntax detected, you should while () {...} instead of while (): ... endwhile;",
2380 "Line " + token.beginLine);
2381 } catch (CoreException e) {
2382 PHPeclipsePlugin.log(e);
2386 } catch (ParseException e) {
2387 errorMessage = "'endwhile' expected";
2389 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2390 errorEnd = jj_input_stream.getPosition() + 1;
2395 } catch (ParseException e) {
2396 errorMessage = "';' expected after 'endwhile' keyword";
2398 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2399 errorEnd = jj_input_stream.getPosition() + 1;
2406 void DoStatement() :
2409 <DO> Statement() <WHILE> Condition("while")
2412 } catch (ParseException e) {
2413 errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
2415 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2416 errorEnd = jj_input_stream.getPosition() + 1;
2421 void ForeachStatement() :
2427 } catch (ParseException e) {
2428 errorMessage = "'(' expected after 'foreach' keyword";
2430 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2431 errorEnd = jj_input_stream.getPosition() + 1;
2436 } catch (ParseException e) {
2437 errorMessage = "variable expected";
2439 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2440 errorEnd = jj_input_stream.getPosition() + 1;
2443 ( VariableSuffix() )*
2446 } catch (ParseException e) {
2447 errorMessage = "'as' expected";
2449 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2450 errorEnd = jj_input_stream.getPosition() + 1;
2455 } catch (ParseException e) {
2456 errorMessage = "variable expected";
2458 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2459 errorEnd = jj_input_stream.getPosition() + 1;
2462 [ <ARRAYASSIGN> Expression() ]
2465 } catch (ParseException e) {
2466 errorMessage = "')' expected after 'foreach' keyword";
2468 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2469 errorEnd = jj_input_stream.getPosition() + 1;
2474 } catch (ParseException e) {
2475 if (errorMessage != null) throw e;
2476 errorMessage = "statement expected";
2478 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2479 errorEnd = jj_input_stream.getPosition() + 1;
2484 void ForStatement() :
2487 final int pos = jj_input_stream.getPosition();
2493 } catch (ParseException e) {
2494 errorMessage = "'(' expected after 'for' keyword";
2496 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2497 errorEnd = jj_input_stream.getPosition() + 1;
2500 [ ForInit() ] <SEMICOLON> [ Expression() ] <SEMICOLON> [ StatementExpressionList() ] <RPAREN>
2504 <COLON> (Statement())*
2507 setMarker(fileToParse,
2508 "Ugly syntax detected, you should for () {...} instead of for (): ... endfor;",
2510 pos+token.image.length(),
2512 "Line " + token.beginLine);
2513 } catch (CoreException e) {
2514 PHPeclipsePlugin.log(e);
2519 } catch (ParseException e) {
2520 errorMessage = "'endfor' expected";
2522 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2523 errorEnd = jj_input_stream.getPosition() + 1;
2528 } catch (ParseException e) {
2529 errorMessage = "';' expected after 'endfor' keyword";
2531 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2532 errorEnd = jj_input_stream.getPosition() + 1;
2541 LOOKAHEAD(LocalVariableDeclaration())
2542 LocalVariableDeclaration()
2544 StatementExpressionList()
2547 void StatementExpressionList() :
2550 StatementExpression() ( <COMMA> StatementExpression() )*
2553 void ContinueStatement() :
2556 <CONTINUE> [ Expression() ]
2559 } catch (ParseException e) {
2560 errorMessage = "';' expected after 'continue' statement";
2562 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2563 errorEnd = jj_input_stream.getPosition() + 1;
2568 void ReturnStatement() :
2571 <RETURN> [ Expression() ]
2574 } catch (ParseException e) {
2575 errorMessage = "';' expected after 'return' statement";
2577 errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1;
2578 errorEnd = jj_input_stream.getPosition() + 1;