Class RegexAST
java.lang.Object
com.oracle.truffle.regex.tregex.parser.ast.RegexAST
- All Implemented Interfaces:
StateIndex<RegexASTNode>,JsonConvertible
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSourceSection(RegexASTNode node, com.oracle.truffle.api.source.SourceSection sourceSection) voidaddSourceSections(RegexASTNode node, Collection<com.oracle.truffle.api.source.SourceSection> src) booleancreateBackReference(int[] groupNumbers) createCaptureGroup(int groupNumber) createCharacterClass(CodePointSet matcherBuilder) createConditionalBackReferenceGroup(int referencedGroupNumber) createGroupBoundaries(TBitSet updateIndices, TBitSet clearIndices, int lastGroup) createLookAheadAssertion(boolean negated) createLookBehindAssertion(boolean negated) voidcreateNFAHelperNodes(RegexASTSubtreeRootNode rootNode) voidInserts a prefix of matchers that match any characters at the beginning of the AST.createSubexpressionCall(int groupNumber) getFlags()getGroup(int index) getGroupByBoundaryIndex(int index) intgetId(RegexASTNode state) getNFAAnchoredInitialState(int prefixOffset) getNFAUnAnchoredInitialState(int prefixOffset) intintintintgetRoot()List<com.oracle.truffle.api.source.SourceSection> Get a list of all source sections associated with the givenRegexASTNode.getState(int id) intvoidbooleanisGroupRecursivelyReferenced(int groupNumber) booleanisGroupReferenced(int groupNumber) booleanbooleanregister(AtomicGroup atomicGroup) register(BackReference backReference) register(CharacterClass characterClass) register(LookAheadAssertion lookAheadAssertion) register(LookBehindAssertion lookBehindAssertion) register(PositionAssertion positionAssertion) register(SubexpressionCall subexpressionCall) voidregisterGroupWithGuards(Group group) voidregisterQuantifier(QuantifiableTerm quantifiable) voidregisterZeroWidthQuantifiable(QuantifiableTerm zeroWidthQuantifiable) booleanvoidsetFlags(RegexFlags flags) voidsetFlavorSpecificFlags(AbstractRegexObject flavorSpecificFlags) voidsetGroupRecursivelyReferenced(int groupNumber) voidsetIndex(RegexASTNode[] index) voidstatic JsonArraysourceSectionsToJson(List<com.oracle.truffle.api.source.SourceSection> sourceSections) static JsonArraysourceSectionsToJson(Stream<com.oracle.truffle.api.source.SourceSection> sourceSections) toJson()voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.truffle.regex.tregex.automaton.StateIndex
isEmpty
-
Constructor Details
-
RegexAST
-
-
Method Details
-
getLanguage
-
getSource
-
getFlags
-
setFlags
-
getFlavorSpecificFlags
-
setFlavorSpecificFlags
-
getOptions
-
getEncoding
-
getRoot
-
setRoot
-
getWrappedRoot
-
rootIsWrapped
public boolean rootIsWrapped() -
getNodeCount
-
getNumberOfNodes
public int getNumberOfNodes() -
getGroupCount
-
getNumberOfCaptureGroups
public int getNumberOfCaptureGroups()- Returns:
- the number of capturing groups in the AST, including group 0.
-
getQuantifierCount
public int getQuantifierCount() -
registerQuantifier
-
getQuantifierArray
-
registerZeroWidthQuantifiable
-
getZeroWidthQuantifiables
-
getGroup
-
getGroupByBoundaryIndex
-
getProperties
-
isLiteralString
public boolean isLiteralString() -
getNumberOfStates
public int getNumberOfStates()- Specified by:
getNumberOfStatesin interfaceStateIndex<RegexASTNode>
-
getId
- Specified by:
getIdin interfaceStateIndex<RegexASTNode>
-
getState
- Specified by:
getStatein interfaceStateIndex<RegexASTNode>
-
setIndex
-
getWrappedPrefixLength
public int getWrappedPrefixLength()- Returns:
- length of prefix possibly generated by
createPrefix().
-
getEntryAfterPrefix
- Returns:
- first element of sequence of optional any-char matchers possibly generated by
createPrefix().
-
getSubtrees
-
registerGroupWithGuards
-
getGroupsWithGuards
-
getReachableCarets
-
getReachableDollars
-
getNfaAnchoredInitialStates
-
getHardPrefixNodes
-
createRootNode
-
createBackReference
-
getReferencedGroups
-
isGroupReferenced
public boolean isGroupReferenced(int groupNumber) -
setGroupRecursivelyReferenced
public void setGroupRecursivelyReferenced(int groupNumber) -
isGroupRecursivelyReferenced
public boolean isGroupRecursivelyReferenced(int groupNumber) -
createCharacterClass
-
createGroup
-
createCaptureGroup
-
createConditionalBackReferenceGroup
-
getConditionGroups
-
createLookAheadAssertion
-
createLookBehindAssertion
-
createAtomicGroup
-
createNFAHelperNodes
-
createPositionAssertion
-
createSequence
-
createSubexpressionCall
-
register
-
register
-
register
-
register
-
register
-
register
-
register
-
register
-
register
-
register
-
isNFAInitialState
-
getNFAUnAnchoredInitialState
-
getNFAAnchoredInitialState
-
createPrefix
public void createPrefix()Inserts a prefix of matchers that match any characters at the beginning of the AST. The length of the prefix is determined by the look-behind assertions present in the regex. Any necessary context that could be matched by the look-behind assertions but not by the original regex can be captured by the prefix. Exemplary prefix:regex: /(?<=ab)/ -> prefix length: 2 -> result: /(?:[_any_][_any_](?:|[_any_](?:|[_any_])))(?<=ab)/ -> the non-optional [_any_] - matchers will be used if fromIndex > 0, the optional matchers will always be used -
hidePrefix
public void hidePrefix() -
unhidePrefix
public void unhidePrefix() -
createGroupBoundaries
public GroupBoundaries createGroupBoundaries(TBitSet updateIndices, TBitSet clearIndices, int lastGroup) -
getSourceSections
Get a list of all source sections associated with the givenRegexASTNode. The parser will map nodes to source sections in the following way:Group: sections of the respective opening and closing brackets, in that order. For example, the source sections of a look-ahead assertion will be["(?=", ")"]. Groups generated by the parser, e.g.(?:a|)generated fora?, don't have source sections.CharacterClass: normally these nodes correspond to a singleToken.createCharClass(CodePointSet)Token.CharacterClass}, but the parser may optimize redundant nodes away and add their source sections to existing nodes. Example:a|bwill be optimized to[ab], which will be mapped to both original characters.Sequence,MatchFound,RegexASTSubtreeRootNode: no mapping.PositionAssertion,BackReference: mapped to their respectiveTokens.- Nodes generated by
CopyVisitorare mapped to the same source sections as their counterparts. - Nodes inserted as substitutions for e.g.
\bwill simply point to the source section they are substituting. - Source sections of
Token.createQuantifier(int, int, boolean, boolean, boolean)quantifiers} are mapped to their respectiveTerm.
-
addSourceSection
public void addSourceSection(RegexASTNode node, com.oracle.truffle.api.source.SourceSection sourceSection) -
addSourceSections
public void addSourceSections(RegexASTNode node, Collection<com.oracle.truffle.api.source.SourceSection> src) -
extractInnerLiteral
-
canTransformToDFA
public boolean canTransformToDFA() -
canTransformToDFAFailureReason
-
toJson
- Specified by:
toJsonin interfaceJsonConvertible
-
sourceSectionsToJson
-
sourceSectionsToJson
-