use of org.mozilla.javascript.ast.EmptyStatement in project HL4A by HL4A.
the class Parser method statementHelper.
private AstNode statementHelper() throws IOException {
// If the statement is set, then it's been told its label by now.
if (currentLabel != null && currentLabel.getStatement() != null)
currentLabel = null;
AstNode pn = null;
int tt = peekToken(), pos = ts.tokenBeg;
switch(tt) {
case Token.IF:
return ifStatement();
case Token.SWITCH:
return switchStatement();
case Token.WHILE:
return whileLoop();
case Token.DO:
return doLoop();
case Token.FOR:
return forLoop();
case Token.TRY:
return tryStatement();
case Token.THROW:
pn = throwStatement();
break;
case Token.BREAK:
pn = breakStatement();
break;
case Token.CONTINUE:
pn = continueStatement();
break;
case Token.WITH:
if (this.inUseStrictDirective) {
reportError("msg.no.with.strict");
}
return withStatement();
case Token.CONST:
case Token.VAR:
consumeToken();
int lineno = ts.lineno;
pn = variables(currentToken, ts.tokenBeg, true);
pn.setLineno(lineno);
break;
case Token.LET:
pn = letStatement();
if (pn instanceof VariableDeclaration && peekToken() == Token.SEMI)
break;
return pn;
case Token.RETURN:
case Token.YIELD:
pn = returnOrYield(tt, false);
break;
case Token.DEBUGGER:
consumeToken();
pn = new KeywordLiteral(ts.tokenBeg, ts.tokenEnd - ts.tokenBeg, tt);
pn.setLineno(ts.lineno);
break;
case Token.LC:
return block();
case Token.ERROR:
consumeToken();
return makeErrorNode();
case Token.SEMI:
consumeToken();
pos = ts.tokenBeg;
pn = new EmptyStatement(pos, ts.tokenEnd - pos);
pn.setLineno(ts.lineno);
return pn;
case Token.FUNCTION:
consumeToken();
return function(FunctionNode.FUNCTION_EXPRESSION_STATEMENT);
case Token.DEFAULT:
pn = defaultXmlNamespace();
break;
case Token.NAME:
pn = nameOrLabel();
if (pn instanceof ExpressionStatement)
break;
// LabeledStatement
return pn;
default:
lineno = ts.lineno;
pn = new ExpressionStatement(expr(), !insideFunction());
pn.setLineno(lineno);
break;
}
autoInsertSemicolon(pn);
return pn;
}
use of org.mozilla.javascript.ast.EmptyStatement in project HL4A by HL4A.
the class Parser method statement.
private AstNode statement() throws IOException {
int pos = ts.tokenBeg;
try {
AstNode pn = statementHelper();
if (pn != null) {
if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) {
int beg = pn.getPosition();
beg = Math.max(beg, lineBeginningFor(beg));
addStrictWarning(pn instanceof EmptyStatement ? "msg.extra.trailing.semi" : "msg.no.side.effects", "", beg, nodeEnd(pn) - beg);
}
return pn;
}
} catch (ParserException e) {
// an ErrorNode was added to the ErrorReporter
}
// error: skip ahead to a probable statement boundary
guessingStatementEnd: for (; ; ) {
int tt = peekTokenOrEOL();
consumeToken();
switch(tt) {
case Token.ERROR:
case Token.EOF:
case Token.EOL:
case Token.SEMI:
break guessingStatementEnd;
}
}
// something different here.
return new EmptyStatement(pos, ts.tokenBeg - pos);
}
Aggregations