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

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

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

Parser.getRuleInvocationStack介绍

[英]Return List<String> of the rule names in your parser instance leading up to a call to the current rule. You could override if you want more details such as the file/line info of where in the ATN a rule is invoked. This is very useful for error messages.
[中]返回解析器实例中规则名称的列表<String>,以调用当前规则。如果需要更多详细信息,例如ATN中调用规则的位置的文件/行信息,可以覆盖。这对于错误消息非常有用。

代码示例

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

/** Return List&lt;String&gt; of the rule names in your parser instance
 *  leading up to a call to the current rule.  You could override if
 *  you want more details such as the file/line info of where
 *  in the ATN a rule is invoked.
 *
 *  This is very useful for error messages.
 */
public List<String> getRuleInvocationStack() {
  return getRuleInvocationStack(_ctx);
}

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

/** Used for rule context info debugging during parse-time, not so much for ATN debugging */
  public String toInfoString(Parser recognizer) {
    List<String> rules = recognizer.getRuleInvocationStack(this);
    Collections.reverse(rules);
    return "ParserRuleContext"+rules+"{" +
      "start=" + start +
      ", stop=" + stop +
      '}';
  }
}

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

/** Return List&lt;String&gt; of the rule names in your parser instance
 *  leading up to a call to the current rule.  You could override if
 *  you want more details such as the file/line info of where
 *  in the ATN a rule is invoked.
 *
 *  This is very useful for error messages.
 */
public List<String> getRuleInvocationStack() {
  return getRuleInvocationStack(_ctx);
}

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

/** Return List&lt;String&gt; of the rule names in your parser instance
 *  leading up to a call to the current rule.  You could override if
 *  you want more details such as the file/line info of where
 *  in the ATN a rule is invoked.
 *
 *  This is very useful for error messages.
 */
public List<String> getRuleInvocationStack() {
  return getRuleInvocationStack(_ctx);
}

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

/** Return List&lt;String&gt; of the rule names in your parser instance
 *  leading up to a call to the current rule.  You could override if
 *  you want more details such as the file/line info of where
 *  in the ATN a rule is invoked.
 *
 *  This is very useful for error messages.
 */
public List<String> getRuleInvocationStack() {
  return getRuleInvocationStack(_ctx);
}

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

/** Return List&lt;String&gt; of the rule names in your parser instance
 *  leading up to a call to the current rule.  You could override if
 *  you want more details such as the file/line info of where
 *  in the ATN a rule is invoked.
 *
 *  This is very useful for error messages.
 */
public List<String> getRuleInvocationStack() {
  return getRuleInvocationStack(_ctx);
}

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

/** Used for rule context info debugging during parse-time, not so much for ATN debugging */
  public String toInfoString(Parser recognizer) {
    List<String> rules = recognizer.getRuleInvocationStack(this);
    Collections.reverse(rules);
    return "ParserRuleContext"+rules+"{" +
      "start=" + start +
      ", stop=" + stop +
      '}';
  }
}

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

/** Used for rule context info debugging during parse-time, not so much for ATN debugging */
  public String toInfoString(Parser recognizer) {
    List<String> rules = recognizer.getRuleInvocationStack(this);
    Collections.reverse(rules);
    return "ParserRuleContext"+rules+"{" +
        "start=" + start +
        ", stop=" + stop +
        '}';
  }
}

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

/** Used for rule context info debugging during parse-time, not so much for ATN debugging */
  public String toInfoString(Parser recognizer) {
    List<String> rules = recognizer.getRuleInvocationStack(this);
    Collections.reverse(rules);
    return "ParserRuleContext"+rules+"{" +
        "start=" + start +
        ", stop=" + stop +
        '}';
  }
}

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

/** Used for rule context info debugging during parse-time, not so much for ATN debugging */
  public String toInfoString(Parser recognizer) {
    List<String> rules = recognizer.getRuleInvocationStack(this);
    Collections.reverse(rules);
    return "ParserRuleContext"+rules+"{" +
      "start=" + start +
      ", stop=" + stop +
      '}';
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.sightly.compiler

@Override
  public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg,
              RecognitionException e) {
    String offendingInput;
    if (Parser.class.isAssignableFrom(recognizer.getClass())) {
      List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
      Collections.reverse(stack);
      offendingInput = ((CommonTokenStream) recognizer.getInputStream()).getTokenSource().getInputStream().toString();
    } else {
      offendingInput = recognizer.getInputStream().toString();
    }
    if (e != null) {
      throw new SightlyCompilerException(msg, offendingInput, line, charPositionInLine, e);
    }
    throw new SightlyCompilerException(msg, offendingInput, line, charPositionInLine);
  }
}

代码示例来源:origin: org.kie/kie-dmn-feel

final int tokenIndex = token.getTokenIndex();
final Parser parser = (Parser) recognizer;
if( parser.getRuleInvocationStack().contains( "nameDefinition" ) ) {
  error = generateInvalidVariableError(offendingSymbol, line, charPositionInLine, e, token);
} else if ( "}".equals(token.getText()) && tokenIndex > 1 && ":".equals(parser.getTokenStream().get(tokenIndex - 1).getText()) ) {

代码示例来源:origin: org.kie/kie-dmn-feel

charPositionInLine,
                offendingSymbol);
} else if( "}".equals( token.getText() ) &&  e != null && e.getRecognizer() instanceof Parser && ((Parser)e.getRecognizer()).getRuleInvocationStack().contains( "key" ) ) {
  return new SyntaxErrorEvent(FEELEvent.Severity.ERROR,
                Msg.createMessage(Msg.MISSING_EXPRESSION, e.getCtx().getText()),

相关文章

微信公众号

最新文章

更多