public final class RegexAST extends Object implements StateIndex<RegexASTNode>, JsonConvertible
| Constructor and Description |
|---|
RegexAST(RegexSource source,
RegexFlags flags,
RegexOptions options) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisEmptypublic RegexAST(RegexSource source, RegexFlags flags, RegexOptions options)
public RegexSource getSource()
public RegexFlags getFlags()
public RegexOptions getOptions()
public Group getRoot()
public void setRoot(Group root)
public Group getWrappedRoot()
public boolean rootIsWrapped()
public Counter.ThresholdCounter getNodeCount()
public int getNumberOfNodes()
public Counter.ThresholdCounter getGroupCount()
public int getNumberOfCaptureGroups()
public Counter getQuantifierCount()
public Counter getZeroWidthQuantifierCount()
public Group getGroupByBoundaryIndex(int index)
public RegexProperties getProperties()
public boolean isLiteralString()
public int getNumberOfStates()
getNumberOfStates in interface StateIndex<RegexASTNode>public int getId(RegexASTNode state)
getId in interface StateIndex<RegexASTNode>public RegexASTNode getState(int id)
getState in interface StateIndex<RegexASTNode>public void setIndex(RegexASTNode[] index)
public int getWrappedPrefixLength()
RegexAST.createPrefix().public RegexASTNode getEntryAfterPrefix()
RegexAST.createPrefix().public LookAroundIndex getLookArounds()
public List<PositionAssertion> getReachableCarets()
public List<PositionAssertion> getReachableDollars()
public StateSet<RegexAST,PositionAssertion> getNfaAnchoredInitialStates()
public StateSet<RegexAST,RegexASTNode> getHardPrefixNodes()
public RegexASTRootNode createRootNode()
public BackReference createBackReference(int groupNumber)
public CharacterClass createCharacterClass(CodePointSet matcherBuilder)
public Group createGroup()
public Group createCaptureGroup(int groupNumber)
public LookAheadAssertion createLookAheadAssertion(boolean negated)
public LookBehindAssertion createLookBehindAssertion(boolean negated)
public void createNFAHelperNodes(RegexASTSubtreeRootNode rootNode)
public PositionAssertion createPositionAssertion(PositionAssertion.Type type)
public Sequence createSequence()
public BackReference register(BackReference backReference)
public CharacterClass register(CharacterClass characterClass)
public LookAheadAssertion register(LookAheadAssertion lookAheadAssertion)
public LookBehindAssertion register(LookBehindAssertion lookBehindAssertion)
public void invertNegativeLookAround(LookAroundAssertion assertion)
public PositionAssertion register(PositionAssertion positionAssertion)
public boolean isNFAInitialState(RegexASTNode node)
public MatchFound getNFAUnAnchoredInitialState(int prefixOffset)
public PositionAssertion getNFAAnchoredInitialState(int prefixOffset)
public void createPrefix()
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
public void hidePrefix()
public void unhidePrefix()
public GroupBoundaries createGroupBoundaries(CompilationFinalBitSet updateIndices, CompilationFinalBitSet clearIndices)
public List<com.oracle.truffle.api.source.SourceSection> getSourceSections(RegexASTNode node)
RegexASTNode. 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 for a?, don't have
source sections.CharacterClass: normally these nodes correspond to a single
Token.CharacterClass, but
the parser may optimize redundant nodes away and add their source sections to existing nodes.
Example: a|b will be optimized to [ab], which will be mapped to both original
characters.Sequence, MatchFound, RegexASTSubtreeRootNode: no mapping.PositionAssertion, BackReference: mapped to their respective
Tokens.CopyVisitor are mapped to the same source sections as their
counterparts.\b will simply point to the source
section they are substituting.quantifiers are mapped to their respective Term.public void addSourceSection(RegexASTNode node, Token token)
public void addSourceSections(RegexASTNode node, Collection<com.oracle.truffle.api.source.SourceSection> src)
public InnerLiteral extractInnerLiteral(CompilationBuffer compilationBuffer)
public JsonValue toJson()
toJson in interface JsonConvertiblepublic static JsonArray sourceSectionsToJson(List<com.oracle.truffle.api.source.SourceSection> sourceSections)