/** The cursor in expression stack. */
private static int nodePtr;
- public static final boolean PARSER_DEBUG = false;
+ public static final boolean PARSER_DEBUG = true;
public final void setFileToParse(final IFile fileToParse) {
PHPParser.fileToParse = fileToParse;
public static final void createNewHTMLCode() {
final int currentPosition = token.sourceStart;
if (currentPosition == htmlStart ||
+ currentPosition < htmlStart ||
currentPosition > SimpleCharStream.currentBuffer.length()) {
return;
}
- final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,currentPosition+1).toCharArray();
+ final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,
+ currentPosition).toCharArray();
pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition));
}
/** Create a new task. */
- public static final void createNewTask() {
- final int currentPosition = token.sourceStart;
- final String todo = SimpleCharStream.currentBuffer.substring(currentPosition-3,
+ public static final void createNewTask(final int todoStart) {
+ final String todo = SimpleCharStream.currentBuffer.substring(todoStart,
SimpleCharStream.currentBuffer.indexOf("\n",
- currentPosition)-1);
+ todoStart)-1);
if (!PARSER_DEBUG) {
try {
setMarker(fileToParse,
<DEFAULT> TOKEN :
{
- <PHPSTARTSHORT : "<?"> {PHPParser.createNewHTMLCode();} : PHPPARSING
-| <PHPSTARTLONG : "<?php"> {PHPParser.createNewHTMLCode();} : PHPPARSING
-| <PHPECHOSTART : "<?="> {PHPParser.createNewHTMLCode();} : PHPPARSING
+ <PHPSTARTSHORT : "<?"> : PHPPARSING
+| <PHPSTARTLONG : "<?php"> : PHPPARSING
+| <PHPECHOSTART : "<?="> : PHPPARSING
}
-<PHPPARSING, IN_SINGLE_LINE_COMMENT> TOKEN :
+<PHPPARSING, IN_SINGLE_LINE_COMMENT,IN_VARIABLE> TOKEN :
{
- <PHPEND :"?>"> {PHPParser.htmlStart = PHPParser.token.sourceEnd;} : DEFAULT
+ <PHPEND :"?>"> : DEFAULT
}
/* Skip any character if we are not in php mode */
| "\f"
}
+<IN_VARIABLE> SPECIAL_TOKEN :
+{
+ " " : PHPPARSING
+| "\t" : PHPPARSING
+| "\n" : PHPPARSING
+| "\r" : PHPPARSING
+| "\f" : PHPPARSING
+}
/* COMMENTS */
<PHPPARSING> SPECIAL_TOKEN :
{
<IN_SINGLE_LINE_COMMENT,IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT> SPECIAL_TOKEN :
{
- "todo" {PHPParser.createNewTask();}
+ "todo"
}
+void todo() :
+{Token todoToken;}
+{
+ todoToken = "TODO" {createNewTask(todoToken.sourceStart);}
+}
<IN_FORMAL_COMMENT> SPECIAL_TOKEN :
{
"*/" : PHPPARSING
| <GLOBAL : "global">
| <DEFINE : "define">
| <STATIC : "static">
-| <CLASSACCESS : "->">
-| <STATICCLASSACCESS : "::">
-| <ARRAYASSIGN : "=>">
+}
+
+<PHPPARSING,IN_VARIABLE> TOKEN :
+{
+ <CLASSACCESS : "->"> : PHPPARSING
+| <STATICCLASSACCESS : "::"> : PHPPARSING
+| <ARRAYASSIGN : "=>"> : PHPPARSING
}
/* RESERVED WORDS AND LITERALS */
}
//Misc token
-<PHPPARSING> TOKEN :
+<PHPPARSING,IN_VARIABLE> TOKEN :
{
- <AT : "@">
-| <DOLLAR : "$">
-| <BANG : "!">
-| <TILDE : "~">
-| <HOOK : "?">
-| <COLON : ":">
+ <AT : "@"> : PHPPARSING
+| <BANG : "!"> : PHPPARSING
+| <TILDE : "~"> : PHPPARSING
+| <HOOK : "?"> : PHPPARSING
+| <COLON : ":"> : PHPPARSING
}
/* OPERATORS */
-<PHPPARSING> TOKEN :
-{
- <OR_OR : "||">
-| <AND_AND : "&&">
-| <PLUS_PLUS : "++">
-| <MINUS_MINUS : "--">
-| <PLUS : "+">
-| <MINUS : "-">
-| <STAR : "*">
-| <SLASH : "/">
-| <BIT_AND : "&">
-| <BIT_OR : "|">
-| <XOR : "^">
-| <REMAINDER : "%">
-| <LSHIFT : "<<">
-| <RSIGNEDSHIFT : ">>">
-| <RUNSIGNEDSHIFT : ">>>">
-| <_ORL : "OR">
-| <_ANDL : "AND">
+<PHPPARSING,IN_VARIABLE> TOKEN :
+{
+ <OR_OR : "||"> : PHPPARSING
+| <AND_AND : "&&"> : PHPPARSING
+| <PLUS_PLUS : "++"> : PHPPARSING
+| <MINUS_MINUS : "--"> : PHPPARSING
+| <PLUS : "+"> : PHPPARSING
+| <MINUS : "-"> : PHPPARSING
+| <STAR : "*"> : PHPPARSING
+| <SLASH : "/"> : PHPPARSING
+| <BIT_AND : "&"> : PHPPARSING
+| <BIT_OR : "|"> : PHPPARSING
+| <XOR : "^"> : PHPPARSING
+| <REMAINDER : "%"> : PHPPARSING
+| <LSHIFT : "<<"> : PHPPARSING
+| <RSIGNEDSHIFT : ">>"> : PHPPARSING
+| <RUNSIGNEDSHIFT : ">>>"> : PHPPARSING
+| <_ORL : "OR"> : PHPPARSING
+| <_ANDL : "AND"> : PHPPARSING
}
/* LITERALS */
/* IDENTIFIERS */
-<PHPPARSING> TOKEN :
+
+<PHPPARSING,IN_VARIABLE> TOKEN : {<DOLLAR : "$"> : IN_VARIABLE}
+
+
+<PHPPARSING, IN_VARIABLE> TOKEN :
{
<IDENTIFIER: (<LETTER>|<SPECIAL>) (<LETTER>|<DIGIT>|<SPECIAL>)* >
|
/* SEPARATORS */
-<PHPPARSING> TOKEN :
+<PHPPARSING,IN_VARIABLE> TOKEN :
{
- <LPAREN : "(">
-| <RPAREN : ")">
-| <LBRACE : "{">
-| <RBRACE : "}">
-| <LBRACKET : "[">
-| <RBRACKET : "]">
-| <SEMICOLON : ";">
-| <COMMA : ",">
-| <DOT : ".">
+ <LPAREN : "("> : PHPPARSING
+| <RPAREN : ")"> : PHPPARSING
+| <LBRACE : "{"> : PHPPARSING
+| <RBRACE : "}"> : PHPPARSING
+| <LBRACKET : "["> : PHPPARSING
+| <RBRACKET : "]"> : PHPPARSING
+| <SEMICOLON : ";"> : PHPPARSING
+| <COMMA : ","> : PHPPARSING
+| <DOT : "."> : PHPPARSING
}
/* COMPARATOR */
-<PHPPARSING> TOKEN :
+<PHPPARSING,IN_VARIABLE> TOKEN :
{
- <GT : ">">
-| <LT : "<">
-| <EQUAL_EQUAL : "==">
-| <LE : "<=">
-| <GE : ">=">
-| <NOT_EQUAL : "!=">
-| <DIF : "<>">
-| <BANGDOUBLEEQUAL : "!==">
-| <TRIPLEEQUAL : "===">
+ <GT : ">"> : PHPPARSING
+| <LT : "<"> : PHPPARSING
+| <EQUAL_EQUAL : "=="> : PHPPARSING
+| <LE : "<="> : PHPPARSING
+| <GE : ">="> : PHPPARSING
+| <NOT_EQUAL : "!="> : PHPPARSING
+| <DIF : "<>"> : PHPPARSING
+| <BANGDOUBLEEQUAL : "!=="> : PHPPARSING
+| <TRIPLEEQUAL : "==="> : PHPPARSING
}
/* ASSIGNATION */
-<PHPPARSING> TOKEN :
-{
- <ASSIGN : "=">
-| <PLUSASSIGN : "+=">
-| <MINUSASSIGN : "-=">
-| <STARASSIGN : "*=">
-| <SLASHASSIGN : "/=">
-| <ANDASSIGN : "&=">
-| <ORASSIGN : "|=">
-| <XORASSIGN : "^=">
-| <DOTASSIGN : ".=">
-| <REMASSIGN : "%=">
-| <TILDEEQUAL : "~=">
-| <LSHIFTASSIGN : "<<=">
-| <RSIGNEDSHIFTASSIGN : ">>=">
-}
-
-<PHPPARSING> TOKEN :
-{
- <DOLLAR_ID: <DOLLAR> <IDENTIFIER>>
+<PHPPARSING,IN_VARIABLE> TOKEN :
+{
+ <ASSIGN : "="> : PHPPARSING
+| <PLUSASSIGN : "+="> : PHPPARSING
+| <MINUSASSIGN : "-="> : PHPPARSING
+| <STARASSIGN : "*="> : PHPPARSING
+| <SLASHASSIGN : "/="> : PHPPARSING
+| <ANDASSIGN : "&="> : PHPPARSING
+| <ORASSIGN : "|="> : PHPPARSING
+| <XORASSIGN : "^="> : PHPPARSING
+| <DOTASSIGN : ".="> : PHPPARSING
+| <REMASSIGN : "%="> : PHPPARSING
+| <TILDEEQUAL : "~="> : PHPPARSING
+| <LSHIFTASSIGN : "<<="> : PHPPARSING
+| <RSIGNEDSHIFTASSIGN : ">>="> : PHPPARSING
}
void phpTest() :
void PhpBlock() :
{
final PHPEchoBlock phpEchoBlock;
- final Token token;
+ final Token token,phpEnd;
}
{
phpEchoBlock = phpEchoBlock()
PHPeclipsePlugin.log(e);
}}
]
+ {PHPParser.createNewHTMLCode();}
Php()
try {
- <PHPEND>
+ phpEnd = <PHPEND>
+ {htmlStart = phpEnd.sourceEnd;}
} catch (ParseException e) {
errorMessage = "'?>' expected";
errorLevel = ERROR;
final Token token, token2;
}
{
- token = <PHPECHOSTART> expr = Expression() [ <SEMICOLON> ] token2 = <PHPEND>
+ token = <PHPECHOSTART> {PHPParser.createNewHTMLCode();}
+ expr = Expression() [ <SEMICOLON> ] token2 = <PHPEND>
{
+ htmlStart = token2.sourceEnd;
+
echoBlock = new PHPEchoBlock(expr,token.sourceStart,token2.sourceEnd);
pushOnAstNodes(echoBlock);
return echoBlock;}
final Token superclassName, token, extendsToken;
String classNameImage = SYNTAX_ERROR_CHAR;
String superclassNameImage = null;
+ final int classEnd;
}
{
token = <CLASS>
currentSegment.add(classDeclaration);
currentSegment = classDeclaration;
}
- ClassBody(classDeclaration)
+ classEnd = ClassBody(classDeclaration)
{currentSegment = (OutlineableWithChildren) currentSegment.getParent();
- classDeclaration.sourceEnd = SimpleCharStream.getPosition();
+ classDeclaration.sourceEnd = classEnd;
pushOnAstNodes(classDeclaration);
return classDeclaration;}
}
-void ClassBody(final ClassDeclaration classDeclaration) :
-{}
+int ClassBody(final ClassDeclaration classDeclaration) :
+{
+Token token;
+}
{
try {
<LBRACE>
}
( ClassBodyDeclaration(classDeclaration) )*
try {
- <RBRACE>
+ token = <RBRACE>
+ {return token.sourceEnd;}
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. 'var', 'function' or '}' expected";
errorLevel = ERROR;
errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
errorEnd = SimpleCharStream.getPosition() + 1;
processParseExceptionDebug(e);
+ return PHPParser.token.sourceEnd;
}
}
*/
VariableDeclaration VariableDeclaratorNoSuffix() :
{
- final Token varName;
- Expression initializer = null;
+ final Token dollar, token, lbrace,rbrace;
+ Expression expr, initializer = null;
Token assignToken;
+ Variable variable;
}
{
- varName = <DOLLAR_ID>
+ dollar = <DOLLAR>
+ (
+ token = <IDENTIFIER>
+ {variable = new Variable(token.image,dollar.sourceStart,token.sourceEnd);}
+ |
+ lbrace = <LBRACE> expr = Expression() rbrace = <RBRACE>
+ {variable = new Variable(expr,dollar.sourceStart,rbrace.sourceEnd);}
+ )
[
assignToken = <ASSIGN>
try {
{
if (initializer == null) {
return new VariableDeclaration(currentSegment,
- new Variable(varName.image.substring(1),
- varName.sourceStart+1,
- varName.sourceEnd+1),
- varName.sourceStart+1,
- varName.sourceEnd+1);
+ variable,
+ variable.sourceStart,
+ variable.sourceEnd);
}
return new VariableDeclaration(currentSegment,
- new Variable(varName.image.substring(1),
- varName.sourceStart+1,
- varName.sourceEnd+1),
+ variable,
initializer,
VariableDeclaration.EQUAL,
- varName.sourceStart+1);
+ variable.sourceStart);
}
}
}
}
-/**
- * Return a variablename without the $.
- * @return a variable name
- *//*
-Variable Variable():
-{
- final StringBuffer buff;
- Expression expression = null;
- final Token token;
- Variable expr;
- final int pos;
-}
-{
- token = <DOLLAR_ID>
- [<LBRACE> expression = Expression() <RBRACE>]
- {
- if (expression == null) {
- return new Variable(token.image.substring(1),
- token.sourceStart+1,
- token.sourceEnd+1);
- }
- String s = expression.toStringExpression();
- buff = new StringBuffer(token.image.length()+s.length()+2);
- buff.append(token.image);
- buff.append("{");
- buff.append(s);
- buff.append("}");
- s = buff.toString();
- return new Variable(s,token.sourceStart+1,token.sourceEnd+1);
- }
-|
- token = <DOLLAR>
- expr = VariableName()
- {return new Variable(expr,token.sourceStart,expr.sourceEnd);}
-} */
-
Variable Variable() :
{
Variable variable = null;
final Token token;
}
{
- token = <DOLLAR_ID> [variable = Var(token)]
- {
- if (variable == null) {
- return new Variable(token.image.substring(1),token.sourceStart+1,token.sourceEnd+1);
- }
- final StringBuffer buff = new StringBuffer();
- buff.append(token.image.substring(1));
- buff.append(variable.toStringExpression());
- return new Variable(buff.toString(),token.sourceStart+1,variable.sourceEnd+1);
- }
-|
token = <DOLLAR> variable = Var(token)
{
return new Variable(variable,token.sourceStart,variable.sourceEnd);
Variable Var(final Token dollar) :
{
Variable variable = null;
- final Token token;
+ final Token token,token2;
ConstantIdentifier constant;
+ Expression expression;
}
{
- token = <DOLLAR_ID> [variable = Var(token)]
- {if (variable == null) {
- return new Variable(token.image.substring(1),token.sourceStart+1,token.sourceEnd+1);
- }
- final StringBuffer buff = new StringBuffer();
- buff.append(token.image.substring(1));
- buff.append(variable.toStringExpression());
- return new Variable(buff.toString(),dollar.sourceStart,variable.sourceEnd);
- }
-|
- LOOKAHEAD(<DOLLAR> <DOLLAR>)
token = <DOLLAR> variable = Var(token)
{return new Variable(variable,dollar.sourceStart,variable.sourceEnd);}
|
- constant = VariableName()
- {return new Variable(constant.name,dollar.sourceStart,constant.sourceEnd);}
-}
-
-/**
- * A Variable name (without the $)
- * @return a variable name String
- */
-ConstantIdentifier VariableName():
-{
- final StringBuffer buff;
- String expr;
- Expression expression = null;
- final Token token;
- Token token2 = null;
-}
-{
token = <LBRACE> expression = Expression() token2 = <RBRACE>
- {expr = expression.toStringExpression();
- buff = new StringBuffer(expr.length()+2);
- buff.append("{");
- buff.append(expr);
- buff.append("}");
- expr = buff.toString();
- return new ConstantIdentifier(expr,
- token.sourceStart,
- token2.sourceEnd);
-
- }
-|
- token = <IDENTIFIER>
- [<LBRACE> expression = Expression() token2 = <RBRACE>]
{
- if (expression == null) {
- return new ConstantIdentifier(token.image,
- token.sourceStart,
- token.sourceEnd);
- }
- expr = expression.toStringExpression();
- buff = new StringBuffer(token.image.length()+expr.length()+2);
- buff.append(token.image);
- buff.append("{");
- buff.append(expr);
- buff.append("}");
- expr = buff.toString();
- return new ConstantIdentifier(expr,
- token.sourceStart,
- token2.sourceEnd);
- }
-/*|
- <DOLLAR>
- var = VariableName()
- {
- return new Variable(var,
- var.sourceStart-1,
- var.sourceEnd);
+ return new Variable(expression,
+ dollar.sourceStart,
+ token2.sourceEnd);
}
|
- token = <DOLLAR_ID>
- {
- return new Variable(token.image,
- token.sourceStart+1,
- token.sourceEnd+1);
- } */
+ token = <IDENTIFIER>
+ {return new Variable(token.image,dollar.sourceStart,token.sourceEnd);}
}
Expression VariableInitializer() :
/* <BIT_AND> expr = UnaryExpressionNoPrefix() //why did I had that ?
{return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);}
| */
- expr = AtNotUnaryExpression() {return expr;}
+ expr = AtNotTildeUnaryExpression() {return expr;}
+}
+
+Expression AtNotTildeUnaryExpression() :
+{
+ final Expression expr;
+ final Token token;
+}
+{
+ token = <AT>
+ expr = AtNotTildeUnaryExpression()
+ {return new PrefixedUnaryExpression(expr,OperatorIds.AT,token.sourceStart);}
+|
+ token = <TILDE>
+ expr = AtNotTildeUnaryExpression()
+ {return new PrefixedUnaryExpression(expr,OperatorIds.TWIDDLE,token.sourceStart);}
+|
+ token = <BANG>
+ expr = AtNotUnaryExpression()
+ {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,token.sourceStart);}
+|
+ expr = UnaryExpressionNoPrefix()
+ {return expr;}
}
/**
final Token token;
}
{
- token = <PLUS> expr = AtNotUnaryExpression() {return new PrefixedUnaryExpression(expr,
+ token = <PLUS> expr = AtNotTildeUnaryExpression() {return new PrefixedUnaryExpression(expr,
OperatorIds.PLUS,
token.sourceStart);}
|
- token = <MINUS> expr = AtNotUnaryExpression() {return new PrefixedUnaryExpression(expr,
+ token = <MINUS> expr = AtNotTildeUnaryExpression() {return new PrefixedUnaryExpression(expr,
OperatorIds.MINUS,
token.sourceStart);}
|
AbstractVariable VariableSuffix(final AbstractVariable prefix) :
{
Expression expression = null;
- final Token classAccessToken;
+ final Token classAccessToken,lbrace,rbrace;
Token token;
int pos;
}
{
classAccessToken = <CLASSACCESS>
try {
- ( expression = VariableName() | expression = Variable() )
+ (
+ lbrace = <LBRACE> expression = Expression() rbrace = <RBRACE>
+ {
+ expression = new Variable(expression,
+ lbrace.sourceStart,
+ rbrace.sourceEnd);
+ }
+ |
+ token = <IDENTIFIER>
+ {expression = new Variable(token.image,token.sourceStart,token.sourceEnd);}
+ |
+ expression = Variable()
+ )
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected";
errorLevel = ERROR;
processParseExceptionDebug(e);
}
{return new ArrayDeclarator(prefix,expression,pos);}
+|
+ token = <LBRACE> {pos = token.sourceEnd+1;}
+ [ expression = Expression() {pos = expression.sourceEnd+1;}
+ | expression = Type() {pos = expression.sourceEnd+1;}] //Not good
+ try {
+ token = <RBRACE>
+ {pos = token.sourceEnd;}
+ } catch (ParseException e) {
+ errorMessage = "']' expected";
+ errorLevel = ERROR;
+ errorStart = pos;
+ errorEnd = pos;
+ processParseExceptionDebug(e);
+ }
+ {return new ArrayDeclarator(prefix,expression,pos);}//todo : check braces here
}
Literal Literal() :
final int startIndex = nodePtr;
final AstNode[] blockNodes;
final int nbNodes;
+ final Token phpEnd;
}
{
- <PHPEND> (phpEchoBlock())*
+ phpEnd = <PHPEND>
+ {htmlStart = phpEnd.sourceEnd;}
+ (phpEchoBlock())*
try {
(<PHPSTARTLONG> | <PHPSTARTSHORT>)
+ {PHPParser.createNewHTMLCode();}
} catch (ParseException e) {
errorMessage = "unexpected end of file , '<?php' expected";
errorLevel = ERROR;
}
{
nbNodes = nodePtr - startIndex;
+ if (nbNodes == 0) {
+ return null;
+ }
blockNodes = new AstNode[nbNodes];
- System.arraycopy(nodes,startIndex,blockNodes,0,nbNodes);
+ System.arraycopy(nodes,startIndex+1,blockNodes,0,nbNodes);
nodePtr = startIndex;
return new HTMLBlock(blockNodes);}
}
| token = <INCLUDE_ONCE> {keyword = InclusionStatement.INCLUDE_ONCE;pos=token.sourceEnd;})
try {
expr = Expression()
- {pos=expr.sourceEnd;}
+ {pos = expr.sourceEnd;}
} catch (ParseException e) {
if (errorMessage != null) {
throw e;
}
errorMessage = "unexpected token '"+ e.currentToken.next.image+"', expression expected";
errorLevel = ERROR;
- errorStart = pos+1;
- errorEnd = pos+1;
+ errorStart = e.currentToken.next.sourceStart;
+ errorEnd = e.currentToken.next.sourceEnd;
expr = new ConstantIdentifier(SYNTAX_ERROR_CHAR,pos,pos);
processParseExceptionDebug(e);
}
- {inclusionStatement = new InclusionStatement(currentSegment,
- keyword,
- expr,
- token.sourceStart);
- currentSegment.add(inclusionStatement);
- }
try {
token2 = <SEMICOLON>
+ {pos=token2.sourceEnd;}
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected";
errorLevel = ERROR;
- errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = SimpleCharStream.getPosition() + 1;
- throw e;
+ errorStart = e.currentToken.next.sourceStart;
+ errorEnd = e.currentToken.next.sourceEnd;
+ processParseExceptionDebug(e);
+ }
+ {
+ inclusionStatement = new InclusionStatement(currentSegment,
+ keyword,
+ expr,
+ token.sourceStart,
+ pos);
+ currentSegment.add(inclusionStatement);
+ return inclusionStatement;
}
- {inclusionStatement.sourceEnd = token2.sourceEnd;
- return inclusionStatement;}
}
PrintExpression PrintExpression() :
processParseExceptionDebug(e);
}
( statement = BlockStatement() {list.add(statement);pos = statement.sourceEnd+1;}
- | statement = htmlBlock() {list.add(statement);pos = statement.sourceEnd+1;})*
+ | statement = htmlBlock() {if (statement != null) {
+ list.add(statement);
+ pos = statement.sourceEnd+1;
+ }
+ pos = PHPParser.token.sourceEnd+1;
+ }
+ )*
try {
token2 = <RBRACE>
{pos = token2.sourceEnd+1;}
return abcase;
}
}
+
/**
* A Switch statement with : ... endswitch;
* @param start the begin offset of the switch
{
expr = SwitchLabel()
( statement = BlockStatementNoBreak() {stmts.add(statement);}
- | statement = htmlBlock() {stmts.add(statement);})*
- [ statement = BreakStatement() {stmts.add(statement);}]
+ | statement = htmlBlock() {if (statement != null) {stmts.add(statement);}}
+ | statement = BreakStatement() {stmts.add(statement);})*
+ //[ statement = BreakStatement() {stmts.add(statement);}]
{
final int listSize = stmts.size();
final Statement[] stmtsArray = new Statement[listSize];
<COLON>
{stmts = new ArrayList();}
( statement = Statement() {stmts.add(statement);}
- | statement = htmlBlock() {stmts.add(statement);})*
+ | statement = htmlBlock() {if (statement != null) {stmts.add(statement);}})*
{endStatements = SimpleCharStream.getPosition();}
(elseifStatement = ElseIfStatementColon() {elseIfList.add(elseifStatement);})*
[elseStatement = ElseStatementColon()]
{
elseifToken = <ELSEIF> condition = Condition("elseif")
<COLON> ( statement = Statement() {list.add(statement);}
- | statement = htmlBlock() {list.add(statement);})*
+ | statement = htmlBlock() {if (statement != null) {list.add(statement);}})*
{
final int sizeList = list.size();
final Statement[] stmtsArray = new Statement[sizeList];
}
{
elseToken = <ELSE> <COLON> ( statement = Statement() {list.add(statement);}
- | statement = htmlBlock() {list.add(statement);})*
+ | statement = htmlBlock() {if (statement != null) {list.add(statement);}})*
{
final int sizeList = list.size();
final Statement[] stmtsArray = new Statement[sizeList];