Class SemanticContext.Predicate

java.lang.Object
org.antlr.v4.runtime.atn.SemanticContext
org.antlr.v4.runtime.atn.SemanticContext.Predicate
Enclosing class:
SemanticContext

public static class SemanticContext.Predicate extends SemanticContext
  • Field Details

    • ruleIndex

      public final int ruleIndex
    • predIndex

      public final int predIndex
    • isCtxDependent

      public final boolean isCtxDependent
  • Constructor Details

    • Predicate

      protected Predicate()
    • Predicate

      public Predicate(int ruleIndex, int predIndex, boolean isCtxDependent)
  • Method Details

    • eval

      public boolean eval(Recognizer<?,?> parser, RuleContext parserCallStack)
      Description copied from class: SemanticContext
      For context independent predicates, we evaluate them without a local context (i.e., null context). That way, we can evaluate them without having to create proper rule-specific context during prediction (as opposed to the parser, which creates them naturally). In a practical sense, this avoids a cast exception from RuleContext to myruleContext.

      For context dependent predicates, we must pass in a local context so that references such as $arg evaluate properly as _localctx.arg. We only capture context dependent predicates in the context in which we begin prediction, so we passed in the outer context here in case of context dependent predicate evaluation.

      Specified by:
      eval in class SemanticContext
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object