当前位置: 首页>>代码示例>>Java>>正文


Java MatcherContext.getPath方法代码示例

本文整理汇总了Java中org.parboiled.MatcherContext.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java MatcherContext.getPath方法的具体用法?Java MatcherContext.getPath怎么用?Java MatcherContext.getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.parboiled.MatcherContext的用法示例。


在下文中一共展示了MatcherContext.getPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: match

import org.parboiled.MatcherContext; //导入方法依赖的package包/类
public boolean match(MatcherContext context) {
    boolean matched = subMatcher.getSubContext(context).runMatcher();
    if (!matched) return false;

    // collect all further matches as well
    int lastIndex = context.getCurrentIndex();
    while (subMatcher.getSubContext(context).runMatcher()) {
        int currentIndex = context.getCurrentIndex();
        if (currentIndex == lastIndex) {
            throw new GrammarException("The inner rule of OneOrMore rule '%s' must not allow empty matches",
                    context.getPath());
        }
        lastIndex = currentIndex;
    }

    context.createNode();
    return true;
}
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:19,代码来源:OneOrMoreMatcher.java

示例2: match

import org.parboiled.MatcherContext; //导入方法依赖的package包/类
public boolean match(MatcherContext context) {
    checkArgNotNull(context, "context");
    int lastIndex = context.getCurrentIndex();
    while (subMatcher.getSubContext(context).runMatcher()) {
        int currentLocation = context.getCurrentIndex();
        if (currentLocation == lastIndex) {
            throw new GrammarException("The inner rule of ZeroOrMore rule '%s' must not allow empty matches",
                    context.getPath());
        }
        lastIndex = currentLocation;
    }

    context.createNode();
    return true;
}
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:16,代码来源:ZeroOrMoreMatcher.java

示例3: match

import org.parboiled.MatcherContext; //导入方法依赖的package包/类
public boolean match(MatcherContext<?> context) {
    Matcher matcher = context.getMatcher();
    if (matcher.accept(isSingleCharMatcherVisitor)) {
        if (prepareErrorLocation(context) && matcher.match(context)) {
            if (fringeIndex < context.getCurrentIndex()) {
                fringeIndex = context.getCurrentIndex();
                lastMatchPath = context.getPath();
            }
            return true;
        }
        return false;
    }

    if (matcher.match(context)) {
        return true;
    }

    // if we didn't match we might have to resynchronize
    if (matcher instanceof SequenceMatcher) {
        switch(context.getCurrentChar()) {
            case RESYNC:
            case RESYNC_START:
            case RESYNC_EOI:
                // however we only resynchronize if we are at a RESYNC location and the matcher is a SequenceMatcher
                // that has already matched at least one character and that is a parent of the last match
                return qualifiesForResync(context) && resynchronize(context);
        }
        
        // check for timeout only on failures of sequences so as to not add too much overhead
        if (System.currentTimeMillis() - startTimeStamp > timeout) {
            throw new TimeoutException(getRootMatcher(), buffer, lastParsingResult);
        }
    }
    return false;
}
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:36,代码来源:RecoveringParseRunner.java

示例4: print

import org.parboiled.MatcherContext; //导入方法依赖的package包/类
private void print(MatcherContext<?> context, boolean matched) {
    Position pos = context.getInputBuffer().getPosition(context.getCurrentIndex());
    MatcherPath path = context.getPath();
    MatcherPath prefix = lastPath != null ? path.commonPrefix(lastPath) : null;
    if (prefix != null && prefix.length() > 1) getLog().receive("..(" + (prefix.length() - 1) + ")../");
    getLog().receive(path.toString(prefix != null ? prefix.parent : null));
    String line = context.getInputBuffer().extractLine(pos.line);
    getLog().receive(", " + (matched ? "matched" : "failed") + ", cursor at " + pos.line + ':' + pos.column +
            " after \"" + line.substring(0, Math.min(line.length(), pos.column - 1)) + "\"\n");
    lastPath = path;
}
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:12,代码来源:TracingParseRunner.java


注:本文中的org.parboiled.MatcherContext.getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。