}
setMarker(e);
errorMessage = null;
+ if (PHPeclipsePlugin.DEBUG) PHPeclipsePlugin.log(e);
}
/**
<#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
|
<STRING_LITERAL: (<STRING_1> | <STRING_2> | <STRING_3>)>
-| <STRING_1: "\"" ( ~["\"","\\"] | "\\" ( ["\"","\\"] ) )* "\"">
-| <STRING_2: "'" ( ~["'","\\"] | "\\" ( ["'","\\"] ) )* "'">
-| <STRING_3: "`" ( ~["`","\\"] | "\\" ( ["`","\\"] ) )* "`">
+| <STRING_1: "\"" ( ~["\"","\\"] | "\\" ~[] )* "\"">
+| <STRING_2: "'" ( ~["'","\\"] | "\\" ~[] )* "'">
+| <STRING_3: "`" ( ~["`","\\"] | "\\" ~[] )* "`">
}
/* IDENTIFIERS */
<PHPPARSING> TOKEN :
{
- < IDENTIFIER: (<LETTER>|<SPECIAL>) (<LETTER>|<DIGIT>|<SPECIAL>)* >
+ <IDENTIFIER: (<LETTER>|<SPECIAL>) (<LETTER>|<DIGIT>|<SPECIAL>)* >
|
< #LETTER:
["a"-"z"] | ["A"-"Z"]
Expression Expression() :
{
final Expression expr;
+ Expression initializer = null;
+ int assignOperator = -1;
+ final int pos = SimpleCharStream.getPosition();
+}
+{
+ LOOKAHEAD(2)
+ expr = ConditionalExpression() [ assignOperator = AssignmentOperator() initializer = Expression() ]
+ {
+ if (assignOperator == -1) return expr;
+ return new VarAssignation(expr,
+ initializer,
+ assignOperator,
+ pos,
+ SimpleCharStream.getPosition());
+ return expr;}
+| expr = ExpressionWBang() {return expr;}
+}
+
+Expression ExpressionWBang() :
+{
+ final Expression expr;
final int pos = SimpleCharStream.getPosition();
}
{
- <BANG> expr = Expression() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
+ <BANG> expr = ExpressionWBang() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
| expr = ExpressionNoBang() {return expr;}
}
{
expr = PrintExpression() {return expr;}
| expr = ListExpression() {return expr;}
-| LOOKAHEAD(varAssignation())
- expr = varAssignation() {return expr;}
-| expr = ConditionalExpression() {return expr;}
}
/**
- * A Variable assignation.
- * varName (an assign operator) any expression
+ * Any assignement operator.
+ * @return the assignement operator id
*/
-VarAssignation varAssignation() :
-{
- final String varName;
- final Expression initializer;
- final int assignOperator;
- final int pos = SimpleCharStream.getPosition();
-}
-{
- varName = VariableDeclaratorId()
- assignOperator = AssignmentOperator()
- try {
- initializer = Expression()
- } catch (ParseException e) {
- if (errorMessage != null) {
- throw e;
- }
- errorMessage = "expression expected";
- errorLevel = ERROR;
- errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = SimpleCharStream.getPosition() + 1;
- throw e;
- }
- {return new VarAssignation(varName.toCharArray(),
- initializer,
- assignOperator,
- pos,
- SimpleCharStream.getPosition());}
-}
-
int AssignmentOperator() :
{}
{
Expression UnaryExpressionNotPlusMinus() :
{
final Expression expr;
+ final int pos = SimpleCharStream.getPosition();
}
{
-// <BANG> expr = UnaryExpression() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
LOOKAHEAD( <LPAREN> (Type() | <ARRAY>) <RPAREN> )
expr = CastExpression() {return expr;}
+| <BANG> expr = UnaryExpression() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
| expr = PostfixExpression() {return expr;}
| expr = Literal() {return expr;}
| <LPAREN> expr = Expression()
final int pos = SimpleCharStream.getPosition();
}
{
- LOOKAHEAD(2)
- identifier = <IDENTIFIER> <STATICCLASSACCESS> expr = ClassIdentifier()
- {expr = new ClassAccess(new ConstantIdentifier(identifier.image.toCharArray(),
- pos,
- SimpleCharStream.getPosition()),
- expr,
- ClassAccess.STATIC);}
- (
- LOOKAHEAD(PrimarySuffix())
- expr = PrimarySuffix(expr))*
- {return expr;}
-|
expr = PrimaryPrefix()
(
LOOKAHEAD(PrimarySuffix())
{return expr;}
}
-/**
- * An array declarator.
- * array(vars)
- * @return an array
- */
-ArrayInitializer ArrayDeclarator() :
-{
- final ArrayVariableDeclaration[] vars;
- final int pos = SimpleCharStream.getPosition();
-}
-{
- <ARRAY> vars = ArrayInitializer()
- {return new ArrayInitializer(vars,pos,SimpleCharStream.getPosition());}
-}
-
Expression PrimaryPrefix() :
{
final Expression expr;
SimpleCharStream.getPosition());}
}
+AbstractSuffixExpression PrimarySuffix(final Expression prefix) :
+{
+ final AbstractSuffixExpression suffix;
+ final Expression expr;
+}
+{
+ suffix = Arguments(prefix) {return suffix;}
+| suffix = VariableSuffix(prefix) {return suffix;}
+| <STATICCLASSACCESS> expr = ClassIdentifier()
+ {suffix = new ClassAccess(prefix,
+ expr,
+ ClassAccess.STATIC);
+ return suffix;}
+}
+
+/**
+ * An array declarator.
+ * array(vars)
+ * @return an array
+ */
+ArrayInitializer ArrayDeclarator() :
+{
+ final ArrayVariableDeclaration[] vars;
+ final int pos = SimpleCharStream.getPosition();
+}
+{
+ <ARRAY> vars = ArrayInitializer()
+ {return new ArrayInitializer(vars,pos,SimpleCharStream.getPosition());}
+}
+
PrefixedUnaryExpression classInstantiation() :
{
Expression expr;
final String expr;
final Token token;
final int pos = SimpleCharStream.getPosition();
+ final ConstantIdentifier type;
}
{
token = <IDENTIFIER> {return new ConstantIdentifier(token.image.toCharArray(),
pos,
SimpleCharStream.getPosition());}
+| type = Type() {return type;}
| expr = VariableDeclaratorId() {return new ConstantIdentifier(expr.toCharArray(),
pos,
SimpleCharStream.getPosition());}
}
-AbstractSuffixExpression PrimarySuffix(final Expression prefix) :
-{
- final AbstractSuffixExpression expr;
-}
-{
- expr = Arguments(prefix) {return expr;}
-| expr = VariableSuffix(prefix) {return expr;}
-}
-
AbstractSuffixExpression VariableSuffix(final Expression prefix) :
{
String expr = null;
processParseException(e);
}
try {
- ( defineValue = PrintExpression()
- | LOOKAHEAD(varAssignation())
- defineValue = varAssignation()
- | defineValue = ConditionalExpression())
+ defineValue = Expression()
} catch (ParseException e) {
errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected";
errorLevel = ERROR;
final Statement statement;
}
{
- try {
statement = Statement() {if (phpDocument == currentSegment) pushOnAstNodes(statement);
return statement;}
- } catch (ParseException e) {
- if (errorMessage != null) throw e;
- errorMessage = "statement expected";
- errorLevel = ERROR;
- errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = SimpleCharStream.getPosition() + 1;
- throw e;
- }
| statement = ClassDeclaration() {return statement;}
| statement = MethodDeclaration() {if (phpDocument == currentSegment) pushOnAstNodes(statement);
currentSegment.add((MethodDeclaration) statement);