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

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

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

Parser.getTokenNames介绍

暂无

代码示例

代码示例来源:origin: antlr/intellij-plugin-v4

public AstBuilderListener(Language language, Parser parser, PsiBuilder builder) {
  this.language = language;
  this.builder = builder;
  this.tokenElementTypes = PSIElementTypeFactory.getTokenIElementTypes(language, Arrays.asList(parser.getTokenNames()));
  this.ruleElementTypes = PSIElementTypeFactory.getRuleIElementTypes(language, Arrays.asList(parser.getRuleNames()));
  for (ANTLRErrorListener listener : parser.getErrorListeners()) {
    if (listener instanceof SyntaxErrorListener) {
      syntaxErrors.addAll(((SyntaxErrorListener)listener).getSyntaxErrors());
    }
  }
  Collections.sort(syntaxErrors, new Comparator<SyntaxError>() {
    @Override
    public int compare(SyntaxError o1, SyntaxError o2) {
      return Integer.valueOf(getStart(o1)).compareTo(getStart(o2));
    }
  });
}

代码示例来源:origin: javamonkey/beetl2.0

String expect = expecting.toString(recognizer.getTokenNames());
if(expects.containsKey(expect)){
  expect = expects.get(expect);

代码示例来源:origin: com.ibeetl/beetl

String expect = expecting.toString(recognizer.getTokenNames());
if(expects.containsKey(expect)){
  expect = expects.get(expect);

代码示例来源:origin: com.ibeetl/beetl

protected void reportInputMismatch(@NotNull Parser recognizer, @NotNull InputMismatchException e)
{
  Token t1 = recognizer.getInputStream().LT(-1);
  String msg = "缺少输入在 " + getTokenErrorDisplay(t1) + " 后面, 期望 "
      + e.getExpectedTokens().toString(recognizer.getTokenNames());
  BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg, e);
  //		exception.token = this.getGrammarToken(e.getOffendingToken());
  exception.pushToken(this.getGrammarToken(t1));
  throw exception;
}

代码示例来源:origin: javamonkey/beetl2.0

protected void reportInputMismatch(@NotNull Parser recognizer, @NotNull InputMismatchException e)
{
  Token t1 = recognizer.getInputStream().LT(-1);
  String msg = "缺少输入在 " + getTokenErrorDisplay(t1) + " 后面, 期望 "
      + e.getExpectedTokens().toString(recognizer.getTokenNames());
  BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg, e);
  //		exception.token = this.getGrammarToken(e.getOffendingToken());
  exception.pushToken(this.getGrammarToken(t1));
  throw exception;
}

代码示例来源:origin: com.ibeetl/beetl

protected void reportUnwantedToken(@NotNull Parser recognizer)
{
  if (inErrorRecoveryMode(recognizer))
  {
    return;
  }
  beginErrorCondition(recognizer);
  Token t = recognizer.getCurrentToken();
  String tokenName = getTokenErrorDisplay(t);
  IntervalSet expecting = getExpectedTokens(recognizer);
  String msg = "多余输入 " + tokenName + " 期望 " + expecting.toString(recognizer.getTokenNames());
  BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg);
  //		exception.token = this.getGrammarToken(t);
  exception.pushToken(this.getGrammarToken(t));
  throw exception;
}

代码示例来源:origin: javamonkey/beetl2.0

protected void reportUnwantedToken(@NotNull Parser recognizer)
{
  if (inErrorRecoveryMode(recognizer))
  {
    return;
  }
  beginErrorCondition(recognizer);
  Token t = recognizer.getCurrentToken();
  String tokenName = getTokenErrorDisplay(t);
  IntervalSet expecting = getExpectedTokens(recognizer);
  String msg = "多余输入 " + tokenName + " 期望 " + expecting.toString(recognizer.getTokenNames());
  BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg);
  //		exception.token = this.getGrammarToken(t);
  exception.pushToken(this.getGrammarToken(t));
  throw exception;
}

相关文章