}
setMarker(e);
errorMessage = null;
+ // if (PHPeclipsePlugin.DEBUG) PHPeclipsePlugin.log(e);
}
/**
- * Create marker for the parse error
+ * Create marker for the parse error.
* @param e the ParseException
*/
private static void setMarker(final ParseException e) {
final int indx,
final int brIndx) throws CoreException {
String current;
- StringBuffer lineNumberBuffer = new StringBuffer(10);
+ final StringBuffer lineNumberBuffer = new StringBuffer(10);
char ch;
current = output.substring(indx, brIndx);
if (current.indexOf(PARSE_WARNING_STRING) != -1 || current.indexOf(PARSE_ERROR_STRING) != -1) {
- int onLine = current.indexOf("on line <b>");
+ final int onLine = current.indexOf("on line <b>");
if (onLine != -1) {
lineNumberBuffer.delete(0, lineNumberBuffer.length());
for (int i = onLine; i < current.length(); i++) {
}
}
- int lineNumber = Integer.parseInt(lineNumberBuffer.toString());
+ final int lineNumber = Integer.parseInt(lineNumberBuffer.toString());
- Hashtable attributes = new Hashtable();
+ final Hashtable attributes = new Hashtable();
current = current.replaceAll("\n", "");
current = current.replaceAll("<b>", "");
pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition));
}
- /**
- * Create a new task.
- */
+ /** Create a new task. */
public static final void createNewTask() {
final int currentPosition = SimpleCharStream.getPosition();
- final String todo = SimpleCharStream.currentBuffer.substring(currentPosition+1,
+ final String todo = SimpleCharStream.currentBuffer.substring(currentPosition-3,
SimpleCharStream.currentBuffer.indexOf("\n",
currentPosition)-1);
+ PHPeclipsePlugin.log(1,SimpleCharStream.currentBuffer.toString());
try {
setMarker(fileToParse,
- "todo : " + todo,
+ todo,
SimpleCharStream.getBeginLine(),
TASK,
"Line "+SimpleCharStream.getBeginLine());
<#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"]
try {
<LBRACE>
} catch (ParseException e) {
- errorMessage = "unexpected token : '"+ e.currentToken.next.image + "', '{' expected";
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image + "'. '{' expected";
errorLevel = ERROR;
errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
errorEnd = SimpleCharStream.getPosition() + 1;
- throw e;
+ processParseException(e);
}
( ClassBodyDeclaration(classDeclaration) )*
try {
<RBRACE>
} catch (ParseException e) {
- errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', 'var', 'function' or '}' expected";
+ 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;
- throw e;
+ processParseException(e);
}
}
errorLevel = ERROR;
errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
errorEnd = SimpleCharStream.getPosition() + 1;
- throw e;
+ processParseException(e);
}
]
{
Expression Expression() :
{
final Expression expr;
+ Expression initializer = null;
+ int assignOperator = -1;
final int pos = SimpleCharStream.getPosition();
}
{
- <BANG> expr = Expression() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
-| expr = ExpressionNoBang() {return expr;}
-}
-
-Expression ExpressionNoBang() :
-{
- final Expression 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
- */
-VarAssignation varAssignation() :
-{
- final String varName;
- final Expression initializer;
- final int assignOperator;
- final int pos = SimpleCharStream.getPosition();
-}
-{
- varName = VariableDeclaratorId()
- assignOperator = AssignmentOperator()
+ LOOKAHEAD(1)
+ expr = ConditionalExpression()
+ [ assignOperator = AssignmentOperator()
try {
initializer = Expression()
} catch (ParseException e) {
if (errorMessage != null) {
throw e;
}
- errorMessage = "expression expected";
+ errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected";
errorLevel = ERROR;
- errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1;
- errorEnd = SimpleCharStream.getPosition() + 1;
+ errorEnd = SimpleCharStream.getPosition();
throw e;
}
- {return new VarAssignation(varName.toCharArray(),
+ ]
+ {
+ if (assignOperator == -1) return expr;
+ return new VarAssignation(expr,
initializer,
assignOperator,
pos,
- SimpleCharStream.getPosition());}
+ SimpleCharStream.getPosition());
+ return expr;}
+| expr = ExpressionWBang() {return expr;}
}
+Expression ExpressionWBang() :
+{
+ final Expression expr;
+ final int pos = SimpleCharStream.getPosition();
+}
+{
+ <BANG> expr = ExpressionWBang() {return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);}
+| expr = ExpressionNoBang() {return expr;}
+}
+
+Expression ExpressionNoBang() :
+{
+ final Expression expr;
+}
+{
+ expr = PrintExpression() {return expr;}
+| expr = ListExpression() {return expr;}
+}
+
+/**
+ * Any assignement operator.
+ * @return the assignement operator id
+ */
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()
Expression PrimaryExpression() :
{
- final Token identifier;
Expression expr;
- 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())
- expr = PrimarySuffix(expr))*
+ expr = PrimarySuffix(expr)
+ )*
{return expr;}
|
expr = ArrayDeclarator()
{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);