private Block statementList() {
boolean branchStatement = false;
Statement statement;
- int sourceStart;
- int sourceEnd;
int blockStart = scanner.getCurrentTokenStartPosition();
ArrayList blockStatements = new ArrayList();
do {
try {
- sourceStart = scanner.getCurrentTokenStartPosition();
statement = statement();
blockStatements.add(statement);
- if (branchStatement) {
- sourceEnd = scanner.getCurrentTokenEndPosition();
- reportSyntaxError("Unreachable code", sourceStart, sourceEnd);
+ if (branchStatement && statement!=null) {
+ reportSyntaxError("Unreachable code", statement.sourceStart, statement.sourceEnd);
}
if ((token == TokenNameRBRACE) || (token == TokenNamecase) || (token == TokenNamedefault) || (token == TokenNameelse)
|| (token == TokenNameelseif) || (token == TokenNameendif) || (token == TokenNameendfor)
return createBlock(blockStart, blockStatements);
}
branchStatement = checkUnreachableStatements(statement);
-// return createBlock(blockStart, blockStatements);
} catch (SyntaxError sytaxErr1) {
// if an error occured,
// try to find keywords
* @return
*/
private boolean checkUnreachableStatements(Statement statement) {
- boolean branchStatement = false;
if (statement instanceof ReturnStatement || statement instanceof ContinueStatement || statement instanceof BreakStatement) {
- branchStatement = true;
+ return true;
} else if (statement instanceof IfStatement && ((IfStatement)statement).checkUnreachable) {
- branchStatement = true;
+ return true;
}
- return branchStatement;
+ return false;
}
/**
int off = b.statements.length - 1;
if (!(b.statements[off] instanceof ReturnStatement) && !(b.statements[off] instanceof ContinueStatement)
&& !(b.statements[off] instanceof BreakStatement)) {
- iState.checkUnreachable = false;
- }
+ if (!(b.statements[off] instanceof IfStatement) || !((IfStatement)b.statements[off]).checkUnreachable) {
+ iState.checkUnreachable = false;
+ }
+ }
}
} else {
if (!(s instanceof ReturnStatement) && !(s instanceof ContinueStatement) && !(s instanceof BreakStatement)) {
- iState.checkUnreachable = false;
+ if (!(s instanceof IfStatement) || !((IfStatement)s).checkUnreachable) {
+ iState.checkUnreachable = false;
+ }
}
}
}