Class NFATraversalRegexASTVisitor

java.lang.Object
com.oracle.truffle.regex.tregex.parser.ast.visitors.NFATraversalRegexASTVisitor
Direct Known Subclasses:
ASTStepVisitor, MarkLookBehindEntriesVisitor, PureNFATransitionGenerator

public abstract class NFATraversalRegexASTVisitor extends Object
Special AST visitor that will find all immediate successors of a given Term when the AST is seen as a NFA, in priority order. A successor can either be a CharacterClass or a MatchFound node.
 
 Examples:

 Successors of "b" in (a|b)c:
 1.: "c"

 Successors of "b" in (a|b)*c:
 1.: "a"
 2.: "b"
 3.: "c"
 
 

For every successor, the visitor will find the full path of AST nodes that have been traversed from the initial node to the successor node, where Group nodes are treated specially: The path will contain separate entries for entering and leaving a Group, and a special pass-through node for empty sequences marked with RegexASTNode.isQuantifierPassThroughSequence(). Furthermore, the visitor will not descend into lookaround assertions, it will jump over them and just add their corresponding LookAheadAssertion or LookBehindAssertion node to the path.

 
 Examples with full path information:

 Successors of "b" in (a|b)c:
 1.: [leave group 1], [CharClass c]

 Successors of "b" in (a|b)*c:
 1.: [leave group 1], [enter group 1], [CharClass a]
 2.: [leave group 1], [enter group 1], [CharClass b]
 3.: [leave group 1], [CharClass c]
 
 
  • Field Details

  • Constructor Details

    • NFATraversalRegexASTVisitor

      protected NFATraversalRegexASTVisitor(RegexAST ast)
  • Method Details

    • getTraversableLookBehindAssertions

      public Set<LookBehindAssertion> getTraversableLookBehindAssertions()
    • setTraversableLookBehindAssertions

      public void setTraversableLookBehindAssertions(Set<LookBehindAssertion> traversableLookBehindAssertions)
    • canTraverseCaret

      public boolean canTraverseCaret()
    • setCanTraverseCaret

      public void setCanTraverseCaret(boolean canTraverseCaret)
    • setMatchedConditionGroups

      public void setMatchedConditionGroups(TBitSet matchedConditionGroups)
    • getMatchedConditionGroups

      public TBitSet getMatchedConditionGroups()
    • getCurrentMatchedConditionGroups

      protected TBitSet getCurrentMatchedConditionGroups()
    • isReverse

      protected boolean isReverse()
    • setReverse

      public void setReverse(boolean reverse)
    • isBuildingDFA

      protected abstract boolean isBuildingDFA()
    • canPruneAfterUnconditionalFinalState

      protected abstract boolean canPruneAfterUnconditionalFinalState()
    • run

      protected void run(Term runRoot)
    • visit

      protected abstract void visit(RegexASTNode target)
      Visit the next successor found.
    • enterLookAhead

      protected abstract void enterLookAhead(LookAheadAssertion assertion)
    • leaveLookAhead

      protected abstract void leaveLookAhead(LookAheadAssertion assertion)
    • caretsOnPath

      protected boolean caretsOnPath()
    • dollarsOnPath

      protected boolean dollarsOnPath()
    • hasTransitionGuards

      protected boolean hasTransitionGuards()
    • getTransitionGuardsOnPath

      protected long[] getTransitionGuardsOnPath()
    • calcTransitionGuardsResult

      protected void calcTransitionGuardsResult()
    • getGroupBoundaries

      protected GroupBoundaries getGroupBoundaries()
    • dumpTransitionGuards

      protected void dumpTransitionGuards(long[] guards)