Search in sources :

Example 6 with Label

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);
}
Also used : LabeledStatement(org.mozilla.javascript.ast.LabeledStatement) Label(org.mozilla.javascript.ast.Label) XmlString(org.mozilla.javascript.ast.XmlString)

Example 7 with Label

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);
    }
}
Also used : Label(org.mozilla.javascript.ast.Label) XmlString(org.mozilla.javascript.ast.XmlString)

Aggregations

Label (org.mozilla.javascript.ast.Label)7 LabeledStatement (org.mozilla.javascript.ast.LabeledStatement)3 AstNode (org.mozilla.javascript.ast.AstNode)2 XmlString (org.mozilla.javascript.ast.XmlString)2 ExpressionStatement (org.mozilla.javascript.ast.ExpressionStatement)1 FunctionNode (org.mozilla.javascript.ast.FunctionNode)1 LetNode (org.mozilla.javascript.ast.LetNode)1 ScriptNode (org.mozilla.javascript.ast.ScriptNode)1