本文整理汇总了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");
}
示例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");
}
示例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);
}
}
示例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;
}
示例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);
}
示例6: FlowContentHandler
import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
public FlowContentHandler(Lexer lex, Token.Builder tokenBuilder) {
this.lex = lex;
this.tokenBuilder = tokenBuilder;
}
示例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();
}
示例8: create
import com.sonar.sslr.api.Token; //导入方法依赖的package包/类
@Nonnull
ParseRunnerListener<Token.Builder> create(final CodeReader reader,
final Lexer lexer);