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


Java Token.Builder方法代码示例

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


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

示例1: matchSuccess

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
@Override
public void matchSuccess(final MatchSuccessEvent<Token.Builder> event)
{
    final MatcherContext<Token.Builder> context = event.getContext();
    if (!context.inPredicate())
        consumed = Math.max(consumed, context.getCurrentIndex());
    if (context.getLevel() != 0)
        return;
    if (context.getMatcher() != rootMatcher)
        throw new IllegalStateException("was expecting root rule here");
}
 
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:12,代码来源:CodeReaderListener.java

示例2: matchFailure

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
@Override
public void matchFailure(final MatchFailureEvent<Token.Builder> event)
{
    final MatcherContext<Token.Builder> context = event.getContext();
    if (context.getLevel() != 0)
        return;
    if (context.getMatcher() != rootMatcher)
        throw new IllegalStateException("was expecting root rule here");
}
 
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:10,代码来源:CodeReaderListener.java

示例3: afterParse

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
@Override
public void afterParse(final PostParseEvent<Token.Builder> event)
{
    final int length = reader.length();

    /*
     * We want a match
     */

    final ParsingResult<Token.Builder> result = event.getResult();
    if (!result.isSuccess())
        throw new GrappaException("match failure (consumed: "
            + consumed + " out of " + length + ')');

    /*
     * Check that we did consume all the text
     */

    if (consumed != length)
        throw new GrappaException("was expecting to fully match, but only "
            + consumed + " chars were matched out of " + length);

    final ValueStack<Token.Builder> stack = result.getValueStack();

    final URI uri = lexer.getURI();
    final int size = stack.size();
    Token token;

    for (int index = size - 1; index >= 0; index--) {
        token = stack.peek(index).setURI(uri).build();
        if (token.getType() == GenericTokenType.COMMENT)
            lexer.addTrivia(Trivia.createComment(token));
        else
            lexer.addToken(token);
    }
}
 
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:37,代码来源:CodeReaderListener.java

示例4: consume

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
@Override
public boolean consume(final CodeReader code, final Lexer output)
{
    final InputBuffer buffer = new CodeReaderInputBuffer(code);

    final ListeningParseRunner<Token.Builder> runner
        = new ListeningParseRunner<>(rule);

    suppliers.stream().map(supplier -> supplier.create(code, output))
        .forEach(runner::registerListener);

    runner.run(buffer);

    /*
     * Because of the CodeReaderListener here, we know that we have consumed
     * the full input text; if this isn't the case (because of a parsing
     * failure or because not all the input was consumed), an exception will
     * have been thrown.
     *
     * We therefore pop() all the contents of the reader at this point...
     */

    final int length = code.length();

    for (int i = 0; i < length; i++)
        code.pop();

    return true;
}
 
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:30,代码来源:GrappaChannel.java

示例5: pushToken

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
public boolean pushToken(final TokenType tokenType)
{
    final Context<Token.Builder> context = getContext();
    final int startIndex = context.getMatchStartIndex();
    final Position position
        = context.getInputBuffer().getPosition(startIndex);

    final Token.Builder token = Token.builder()
        .setValueAndOriginalValue(match())
        .setLine(position.getLine())
        .setColumn(position.getColumn())
        .setType(tokenType);

    return push(token);
}
 
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:16,代码来源:SonarParserBase.java

示例6: FlowContentHandler

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
public FlowContentHandler(Lexer lex, Token.Builder tokenBuilder) {
	this.lex = lex;
	this.tokenBuilder = tokenBuilder;
}
 
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:5,代码来源:FlowContentHandler.java

示例7: beforeParse

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
@Override
public void beforeParse(final PreParseEvent<Token.Builder> event)
{
    final MatcherContext<Token.Builder> context = event.getContext();
    rootMatcher = context.getMatcher();
}
 
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:7,代码来源:CodeReaderListener.java

示例8: create

import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
@Nonnull
ParseRunnerListener<Token.Builder> create(final CodeReader reader,
    final Lexer lexer);
 
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:4,代码来源:ListenerSupplier.java


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