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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. @Override
  2. public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg,
  3. RecognitionException e) {
  4. String offendingInput;
  5. if (Parser.class.isAssignableFrom(recognizer.getClass())) {
  6. List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
  7. Collections.reverse(stack);
  8. offendingInput = ((CommonTokenStream) recognizer.getInputStream()).getTokenSource().getInputStream().toString();
  9. } else {
  10. offendingInput = recognizer.getInputStream().toString();
  11. }
  12. if (e != null) {
  13. throw new SightlyCompilerException(msg, offendingInput, line, charPositionInLine, e);
  14. }
  15. throw new SightlyCompilerException(msg, offendingInput, line, charPositionInLine);
  16. }
  17. }

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

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

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

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

相关文章