use of org.mozilla.javascript.ast.Label in project HL4A by HL4A.
the class Parser method recordLabel.
private void recordLabel(Label label, LabeledStatement bundle) throws IOException {
// current token should be colon that primaryExpr left untouched
if (peekToken() != Token.COLON)
codeBug();
consumeToken();
String name = label.getName();
if (labelSet == null) {
labelSet = new HashMap<String, LabeledStatement>();
} else {
LabeledStatement ls = labelSet.get(name);
if (ls != null) {
if (compilerEnv.isIdeMode()) {
Label dup = ls.getLabelByName(name);
reportError("msg.dup.label", dup.getAbsolutePosition(), dup.getLength());
}
reportError("msg.dup.label", label.getPosition(), label.getLength());
}
}
bundle.addLabel(label);
labelSet.put(name, bundle);
}
use of org.mozilla.javascript.ast.Label in project HL4A by HL4A.
the class Parser method name.
private AstNode name(int ttFlagged, int tt) throws IOException {
String nameString = ts.getString();
int namePos = ts.tokenBeg, nameLineno = ts.lineno;
if (0 != (ttFlagged & TI_CHECK_LABEL) && peekToken() == Token.COLON) {
// Do not consume colon. It is used as an unwind indicator
// to return to statementHelper.
Label label = new Label(namePos, ts.tokenEnd - namePos);
label.setName(nameString);
label.setLineno(ts.lineno);
return label;
}
// Not a label. Unfortunately peeking the next token to check for
// a colon has biffed ts.tokenBeg, ts.tokenEnd. We store the name's
// bounds in instance vars and createNameNode uses them.
saveNameTokenData(namePos, nameString, nameLineno);
if (compilerEnv.isXmlAvailable()) {
return propertyName(-1, nameString, 0);
} else {
return createNameNode(true, Token.NAME);
}
}
Aggregations