use of org.mozilla.javascript.ast.BreakStatement in project HL4A by HL4A.
the class Parser method breakStatement.
private BreakStatement breakStatement() throws IOException {
if (currentToken != Token.BREAK)
codeBug();
consumeToken();
int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd;
Name breakLabel = null;
if (peekTokenOrEOL() == Token.NAME) {
breakLabel = createNameNode();
end = getNodeEnd(breakLabel);
}
// matchJumpLabelName only matches if there is one
LabeledStatement labels = matchJumpLabelName();
// always use first label as target
Jump breakTarget = labels == null ? null : labels.getFirstLabel();
if (breakTarget == null && breakLabel == null) {
if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) {
if (breakLabel == null) {
reportError("msg.bad.break", pos, end - pos);
}
} else {
breakTarget = loopAndSwitchSet.get(loopAndSwitchSet.size() - 1);
}
}
BreakStatement pn = new BreakStatement(pos, end - pos);
pn.setBreakLabel(breakLabel);
// can be null if it's a bad break in error-recovery mode
if (breakTarget != null)
pn.setBreakTarget(breakTarget);
pn.setLineno(lineno);
return pn;
}
use of org.mozilla.javascript.ast.BreakStatement in project st-js by st-js.
the class RhinoJavaScriptBuilder method breakStatement.
/**
* {@inheritDoc}
*/
@Override
public AstNode breakStatement(AstNode label) {
BreakStatement b = new BreakStatement();
b.setBreakLabel(cast(label, Name.class));
return b;
}
Aggregations