org.antlr.v4.runtime.Parser.getExpectedTokens()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中org.antlr.v4.runtime.Parser.getExpectedTokens()方法的一些代码示例,展示了Parser.getExpectedTokens()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getExpectedTokens()方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称:Parser
方法名:getExpectedTokens

Parser.getExpectedTokens介绍

[英]Computes the set of input symbols which could follow the current parser state and context, as given by #getState and #getContext, respectively.
[中]计算可以跟随当前解析器状态和上下文的输入符号集,分别由#getState和#getContext给出。

代码示例

代码示例来源:origin: org.antlr/antlr4-runtime

protected IntervalSet getExpectedTokens(Parser recognizer) {
  return recognizer.getExpectedTokens();
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

protected IntervalSet getExpectedTokens(Parser recognizer) {
  return recognizer.getExpectedTokens();
}

代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime

protected IntervalSet getExpectedTokens(Parser recognizer) {
  return recognizer.getExpectedTokens();
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

protected IntervalSet getExpectedTokens(Parser recognizer) {
  return recognizer.getExpectedTokens();
}

代码示例来源:origin: org.antlr/antlr4-runtime

IntervalSet expecting = recognizer.getExpectedTokens();
IntervalSet whatFollowsLoopIterationOrRule =
  expecting.or(getErrorRecoverySet(recognizer));

代码示例来源:origin: com.tunnelvisionlabs/antlr4-runtime

@NotNull
protected IntervalSet getExpectedTokens(@NotNull Parser recognizer) {
  return recognizer.getExpectedTokens();
}

代码示例来源:origin: org.codelibs.elasticsearch.module/lang-painless

@Override
public Token recoverInline(final Parser recognizer) throws RecognitionException {
  final Token token = recognizer.getCurrentToken();
  final String message = "unexpected token [" + getTokenErrorDisplay(token) + "]" +
    " was expecting one of [" + recognizer.getExpectedTokens().toString(recognizer.getVocabulary()) + "].";
  Location location = new Location(sourceName, token.getStartIndex());
  throw location.createError(new IllegalArgumentException(message));
}

代码示例来源:origin: batfish/batfish

/**
 * Consume all tokens a whole line at a time until the next token is one expected by the current
 * rule. Each line (as delimited by supplied separator token) starting from the current line up to
 * the last line consumed is placed in an {@link ErrorNode} and inserted as a child of the current
 * rule.
 *
 * @param recognizer The {@link Parser} to whom to delegate creation of each {@link ErrorNode}
 */
private void consumeBlocksUntilWanted(Parser recognizer) {
 IntervalSet expecting = recognizer.getExpectedTokens();
 IntervalSet whatFollowsLoopIterationOrRule = expecting.or(getErrorRecoverySet(recognizer));
 int nextToken;
 do {
  // Eat tokens until we are at the end of the line
  consumeUntilEndOfLine(recognizer);
  // Get the line number and separator text from the separator token
  Token separatorToken = recognizer.getCurrentToken();
  // Insert the current line as an {@link ErrorNode} as a child of the current rule
  createErrorNode(recognizer, recognizer.getContext(), separatorToken);
  // Eat the separator token
  recognizer.consume();
  nextToken = recognizer.getInputStream().LA(1);
 } while (!whatFollowsLoopIterationOrRule.contains(nextToken) && nextToken != Lexer.EOF);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

IntervalSet expecting = recognizer.getExpectedTokens();
IntervalSet whatFollowsLoopIterationOrRule =
  expecting.or(getErrorRecoverySet(recognizer));

代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime

IntervalSet expecting = recognizer.getExpectedTokens();
IntervalSet whatFollowsLoopIterationOrRule =
  expecting.or(getErrorRecoverySet(recognizer));

代码示例来源:origin: io.virtdata/virtdata-lib-realer

IntervalSet expecting = recognizer.getExpectedTokens();
IntervalSet whatFollowsLoopIterationOrRule =
  expecting.or(getErrorRecoverySet(recognizer));

代码示例来源:origin: com.tunnelvisionlabs/antlr4-runtime

IntervalSet expecting = recognizer.getExpectedTokens();
IntervalSet whatFollowsLoopIterationOrRule =
  expecting.or(getErrorRecoverySet(recognizer));

相关文章