Class MarkLookBehindEntriesVisitor
java.lang.Object
com.oracle.truffle.regex.tregex.parser.ast.visitors.NFATraversalRegexASTVisitor
com.oracle.truffle.regex.tregex.parser.ast.visitors.MarkLookBehindEntriesVisitor
For all lookbehind assertions, mark all states where the assertion may begin. If an assertion may
begin before the root of the AST, the AST is wrapped into a non-capturing group and prepended
with a sequence of optional and non-optional any-char matchers, as shown in the following
example: /(?<=ab)/ is transformed to /(?:[_any_][_any_](?:|[_any_](?:|[_any_])))(?<=ab)/.
The sequence of non-optional any-char matchers is called "prefix", and is necessary for cases
where we want to start searching for a regex match on a random position in a string. When
starting on any other index than 0, we decrease the index by the length of the prefix (but stop
at position 0) and thereby guarantee that lookbehind matches are found, but no regex match prior
to the actual starting index is found. When starting at index 0, the prefix is ignored. When
starting at index 1, just the last element of the prefix is used, and so on.
This entire mechanism assumes that all lookbehind assertion have a fixed length!
- See Also:
-
Field Summary
Fields inherited from class com.oracle.truffle.regex.tregex.parser.ast.visitors.NFATraversalRegexASTVisitor
ast -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidenterLookAhead(LookAheadAssertion assertion) protected booleanprotected voidleaveLookAhead(LookAheadAssertion assertion) voidrun()protected voidvisit(RegexASTNode target) Visit the next successor found.Methods inherited from class com.oracle.truffle.regex.tregex.parser.ast.visitors.NFATraversalRegexASTVisitor
calcTransitionGuardsResult, canTraverseCaret, caretsOnPath, dollarsOnPath, dumpTransitionGuards, getCurrentMatchedConditionGroups, getGroupBoundaries, getMatchedConditionGroups, getTransitionGuardsOnPath, getTraversableLookBehindAssertions, hasTransitionGuards, isReverse, run, setCanTraverseCaret, setMatchedConditionGroups, setReverse, setTraversableLookBehindAssertions
-
Constructor Details
-
MarkLookBehindEntriesVisitor
-
-
Method Details
-
run
public void run() -
visit
Description copied from class:NFATraversalRegexASTVisitorVisit the next successor found.- Specified by:
visitin classNFATraversalRegexASTVisitor
-
enterLookAhead
- Specified by:
enterLookAheadin classNFATraversalRegexASTVisitor
-
leaveLookAhead
- Specified by:
leaveLookAheadin classNFATraversalRegexASTVisitor
-
isBuildingDFA
protected boolean isBuildingDFA()- Specified by:
isBuildingDFAin classNFATraversalRegexASTVisitor
-
canPruneAfterUnconditionalFinalState
protected boolean canPruneAfterUnconditionalFinalState()- Specified by:
canPruneAfterUnconditionalFinalStatein classNFATraversalRegexASTVisitor
-