예제 #1
0
파일: Parser.java 프로젝트: antlr/antlr4
 public ParserRuleContext getInvokingContext(int ruleIndex) {
   ParserRuleContext p = _ctx;
   while (p != null) {
     if (p.getRuleIndex() == ruleIndex) return p;
     p = (ParserRuleContext) p.parent;
   }
   return null;
 }
예제 #2
0
  public static ParserRuleContext findTopContext(
      ParserRuleContext context, IntervalSet values, boolean checkTop) {
    if (checkTop && values.contains(context.getRuleIndex())) {
      return context;
    }

    if (context.isEmpty()) {
      return null;
    }

    return findTopContext((ParserRuleContext) context.parent, values, true);
  }
예제 #3
0
  public static boolean isInContexts(
      @NonNull ParserRuleContext context, boolean allowGaps, @NonNull int... stack) {
    Parameters.notNull("context", context);
    Parameters.notNull("stack", stack);

    if (allowGaps) {
      throw new UnsupportedOperationException("Not implemented yet.");
    }

    ParserRuleContext currentContext = context;
    for (int element : stack) {
      if (currentContext.getRuleIndex() != element) {
        return false;
      }

      currentContext = currentContext.getParent();
      if (currentContext == null) {
        return false;
      }
    }

    return true;
  }
예제 #4
0
파일: Parser.java 프로젝트: antlr/antlr4
 @Override
 public void exitEveryRule(ParserRuleContext ctx) {
   System.out.println(
       "exit    " + getRuleNames()[ctx.getRuleIndex()] + ", LT(1)=" + _input.LT(1).getText());
 }