ParserATNFactory.java 文件源码

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

项目:codebuff 作者:
/**
 * From {@code (A)?} build either:
 *
 * <pre>
 *  o--A-&gt;o
 *  |     ^
 *  o----&gt;|
 * </pre>
 *
 * or, if {@code A} is a block, just add an empty alt to the end of the
 * block
 */

@Override
public Handle optional(GrammarAST optAST, Handle blk) {
    BlockStartState blkStart = (BlockStartState)blk.left;
    ATNState blkEnd = blk.right;
    preventEpsilonOptionalBlocks.add(new Triple<Rule, ATNState, ATNState>(currentRule, blkStart, blkEnd));

    boolean greedy = ((QuantifierAST)optAST).isGreedy();
    blkStart.nonGreedy = !greedy;
    epsilon(blkStart, blk.right, !greedy);

    optAST.atnState = blk.left;
    return blk;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号