<PHPECHOSTART> Expression() [ <SEMICOLON> ] <PHPEND>
|
[ <PHPSTARTLONG>
- | <PHPSTARTSHORT>
- {try {
- setMarker(fileToParse,
- "You should use '<?php' instead of '<?' it will avoid some problems with XML",
- start,
- jj_input_stream.bufpos,
- INFO,
- "Line " + token.beginLine);
- } catch (CoreException e) {
- PHPeclipsePlugin.log(e);
- }}
- ]Php()
+ | <PHPSTARTSHORT>
+ {try {
+ setMarker(fileToParse,
+ "You should use '<?php' instead of '<?' it will avoid some problems with XML",
+ start,
+ jj_input_stream.bufpos,
+ INFO,
+ "Line " + token.beginLine);
+ } catch (CoreException e) {
+ PHPeclipsePlugin.log(e);
+ }}
+ ]
+ Php()
try {
<PHPEND>
} catch (ParseException e) {
PHPVarDeclaration VariableDeclarator() :
{
final String varName;
- String varValue = null;
+ String varValue;
final int pos = jj_input_stream.bufpos;
}
{
expr = Literal()
{return expr;}
|
- <LPAREN> expr = Expression()<RPAREN>
+ <LPAREN> expr = Expression()
+ try {
+ <RPAREN>
+ } catch (ParseException e) {
+ errorMessage = "')' expected";
+ errorLevel = ERROR;
+ throw e;
+ }
{return "("+expr+")";}
}
String expr = null;
}
{
- <CLASSACCESS> expr = VariableName()
+ <CLASSACCESS>
+ try {
+ expr = VariableName()
+ } catch (ParseException e) {
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected";
+ errorLevel = ERROR;
+ throw e;
+ }
{return "->" + expr;}
|
<LBRACKET> [ expr = Expression() ]
try {
<RPAREN>
} catch (ParseException e) {
- errorMessage = "')' expected to close the argument list";
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list";
errorLevel = ERROR;
throw e;
}
{return buff.toString();}
}
-/*
- * Statement syntax follows.
+/**
+ * A Statement without break
*/
-
-void Statement() :
+void StatementNoBreak() :
{}
{
LOOKAHEAD(2)
|
ForeachStatement()
|
- BreakStatement()
-|
ContinueStatement()
|
ReturnStatement()
GlobalStatement()
}
+/**
+ * A Normal statement
+ */
+void Statement() :
+{}
+{
+ StatementNoBreak()
+|
+ BreakStatement()
+}
+
void IncludeStatement() :
{
final String expr;
String expr;
}
{
- <LIST> <LPAREN>
+ <LIST>
+ try {
+ <LPAREN>
+ } catch (ParseException e) {
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected";
+ errorLevel = ERROR;
+ throw e;
+ }
[
expr = VariableDeclaratorId()
{buff.append(expr);}
]
- <COMMA>
- {buff.append(",");}
[
+ try {
+ <COMMA>
+ } catch (ParseException e) {
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected";
+ errorLevel = ERROR;
+ throw e;
+ }
expr = VariableDeclaratorId()
- {buff.append(expr);}
+ {buff.append(",").append(expr);}
]
- <RPAREN>
- {
- buff.append(")");
- return buff.toString();
+ {buff.append(")");}
+ try {
+ <RPAREN>
+ } catch (ParseException e) {
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected";
+ errorLevel = ERROR;
+ throw e;
}
+ [ <ASSIGN> expr = Expression() {buff.append("(").append(expr);}]
+ {return buff.toString();}
}
void EchoStatement() :
throw e;
}
( BlockStatement() )*
- <RBRACE>
+ try {
+ <RBRACE>
+ } catch (ParseException e) {
+ errorMessage = "unexpected token : '"+ e.currentToken.image +"', '}' expected";
+ errorLevel = ERROR;
+ throw e;
+ }
}
void BlockStatement() :
MethodDeclaration()
}
+/**
+ * A Block statement that will not contain any 'break'
+ */
+void BlockStatementNoBreak() :
+{}
+{
+ StatementNoBreak()
+|
+ ClassDeclaration()
+|
+ MethodDeclaration()
+}
+
void LocalVariableDeclaration() :
{}
{
}
void SwitchStatement() :
-{}
{
- <SWITCH> <LPAREN> Expression() <RPAREN> <LBRACE>
- ( SwitchLabel() ( BlockStatement() )* )*
- <RBRACE>
+ Token breakToken = null;
+ int line;
+}
+{
+ <SWITCH>
+ try {
+ <LPAREN>
+ } catch (ParseException e) {
+ errorMessage = "'(' expected after 'switch'";
+ errorLevel = ERROR;
+ throw e;
+ }
+ Expression()
+ try {
+ <RPAREN>
+ } catch (ParseException e) {
+ errorMessage = "')' expected";
+ errorLevel = ERROR;
+ throw e;
+ }
+ try {
+ <LBRACE>
+ } catch (ParseException e) {
+ errorMessage = "'{' expected";
+ errorLevel = ERROR;
+ throw e;
+ }
+ (
+ line = SwitchLabel()
+ ( BlockStatementNoBreak() )*
+ [ breakToken = <BREAK>
+ try {
+ <SEMICOLON>
+ } catch (ParseException e) {
+ errorMessage = "';' expected after 'break' keyword";
+ errorLevel = ERROR;
+ throw e;
+ }
+ ]
+ {
+ try {
+ if (breakToken == null) {
+ setMarker(fileToParse,
+ "You should use put a 'break' at the end of your statement",
+ line,
+ INFO,
+ "Line " + line);
+ }
+ } catch (CoreException e) {
+ PHPeclipsePlugin.log(e);
+ }
+ }
+ )*
+ try {
+ <RBRACE>
+ } catch (ParseException e) {
+ errorMessage = "'}' expected";
+ errorLevel = ERROR;
+ throw e;
+ }
}
-void SwitchLabel() :
-{}
+int SwitchLabel() :
+{
+ final Token token;
+}
{
- <CASE> Expression() <COLON>
+ token = <CASE>
+ try {
+ Expression()
+ } catch (ParseException e) {
+ if (errorMessage != null) throw e;
+ errorMessage = "expression expected after 'case' keyword";
+ errorLevel = ERROR;
+ throw e;
+ }
+ try {
+ <COLON>
+ } catch (ParseException e) {
+ errorMessage = "':' expected after case expression";
+ errorLevel = ERROR;
+ throw e;
+ }
+ {return token.beginLine;}
|
- <_DEFAULT> <COLON>
+ token = <_DEFAULT>
+ try {
+ <COLON>
+ } catch (ParseException e) {
+ errorMessage = "':' expected after 'default' keyword";
+ errorLevel = ERROR;
+ throw e;
+ }
+ {return token.beginLine;}
}
void IfStatement() :
}
void IfStatement0(final int start,final int end) :
-{
-}
+{}
{
<COLON> (Statement())* (ElseIfStatementColon())* [ElseStatementColon()]
try {
<SEMICOLON>
} catch (ParseException e) {
- errorMessage = "';' expected 'endif' keyword";
+ errorMessage = "';' expected after 'endif' keyword";
errorLevel = ERROR;
throw e;
}
errorLevel = ERROR;
throw e;
}
- [ ForInit() ] <SEMICOLON> [ Expression() ] <SEMICOLON> [ ForUpdate() ] <RPAREN>
+ [ ForInit() ] <SEMICOLON> [ Expression() ] <SEMICOLON> [ StatementExpressionList() ] <RPAREN>
(
Statement()
|
try {
<SEMICOLON>
} catch (ParseException e) {
- errorMessage = "';' expected 'endfor' keyword";
+ errorMessage = "';' expected after 'endfor' keyword";
errorLevel = ERROR;
throw e;
}
StatementExpression() ( <COMMA> StatementExpression() )*
}
-void ForUpdate() :
-{}
-{
- StatementExpressionList()
-}
-
void BreakStatement() :
{}
{
- <BREAK> [ <IDENTIFIER> ] <SEMICOLON>
+ <BREAK> [ <IDENTIFIER> ]
+ try {
+ <SEMICOLON>
+ } catch (ParseException e) {
+ errorMessage = "';' expected after 'break' statement";
+ errorLevel = ERROR;
+ throw e;
+ }
}
void ContinueStatement() :
{}
{
- <CONTINUE> [ <IDENTIFIER> ] <SEMICOLON>
+ <CONTINUE> [ <IDENTIFIER> ]
+ try {
+ <SEMICOLON>
+ } catch (ParseException e) {
+ errorMessage = "';' expected after 'continue' statement";
+ errorLevel = ERROR;
+ throw e;
+ }
}
void ReturnStatement() :
{}
{
- <RETURN> [ Expression() ] <SEMICOLON>
+ <RETURN> [ Expression() ]
+ try {
+ <SEMICOLON>
+ } catch (ParseException e) {
+ errorMessage = "';' expected after 'return' statement";
+ errorLevel = ERROR;
+ throw e;
+ }
}
\ No newline at end of file