Class PredicateLabel

java.lang.Object
org.antlr.analysis.Label
org.antlr.analysis.PredicateLabel
All Implemented Interfaces:
Cloneable, Comparable

public class PredicateLabel extends Label
  • Field Details

    • semanticContext

      protected SemanticContext semanticContext
      A tree of semantic predicates from the grammar AST if label==SEMPRED. In the NFA, labels will always be exactly one predicate, but the DFA may have to combine a bunch of them as it collects predicates from multiple NFA configurations into a single DFA state.
  • Constructor Details

    • PredicateLabel

      public PredicateLabel(GrammarAST predicateASTNode)
      Make a semantic predicate label
    • PredicateLabel

      public PredicateLabel(SemanticContext semCtx)
      Make a semantic predicates label
  • Method Details

    • hashCode

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

      public boolean equals(Object o)
      Overrides:
      equals in class Label
    • isSemanticPredicate

      public boolean isSemanticPredicate()
      Overrides:
      isSemanticPredicate in class Label
    • getSemanticContext

      public SemanticContext getSemanticContext()
      Overrides:
      getSemanticContext in class Label
    • toString

      public String toString()
      Description copied from class: Label
      Predicates are lists of AST nodes from the NFA created from the grammar, but the same predicate could be cut/paste into multiple places in the grammar. I must compare the text of all the predicates to truly answer whether {p1,p2} .equals {p1,p2}. Unfortunately, I cannot rely on the AST.equals() to work properly so I must do a brute force O(n^2) nested traversal of the Set doing a String compare. At this point, Labels are not compared for equals when they are predicates, but here's the code for future use.
      Overrides:
      toString in class Label
    • toString

      public String toString(Grammar g)
      Overrides:
      toString in class Label