Rule.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:codebuff 作者:
/**
 * Get {@code #} labels. The keys of the map are the labels applied to outer
 * alternatives of a lexer rule, and the values are collections of pairs
 * (alternative number and {@link AltAST}) identifying the alternatives with
 * this label. Unlabeled alternatives are not included in the result.
 */
public Map<String, List<Pair<Integer, AltAST>>> getAltLabels() {
    Map<String, List<Pair<Integer, AltAST>>> labels = new LinkedHashMap<String, List<Pair<Integer, AltAST>>>();
    for (int i=1; i<=numberOfAlts; i++) {
        GrammarAST altLabel = alt[i].ast.altLabel;
        if ( altLabel!=null ) {
            List<Pair<Integer, AltAST>> list = labels.get(altLabel.getText());
            if (list == null) {
                list = new ArrayList<Pair<Integer, AltAST>>();
                labels.put(altLabel.getText(), list);
            }

            list.add(new Pair<Integer, AltAST>(i, alt[i].ast));
        }
    }
    if ( labels.isEmpty() ) return null;
    return labels;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号