public final class RegexAST extends Object implements StateIndex<RegexASTNode>, JsonConvertible
| Constructor and Description |
|---|
RegexAST(RegexLanguage language,
RegexSource source,
RegexFlags flags) |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisEmptypublic RegexAST(RegexLanguage language, RegexSource source, RegexFlags flags)
public RegexLanguage getLanguage()
public RegexSource getSource()
public RegexFlags getFlags()
public void setFlags(RegexFlags flags)
public RegexOptions getOptions()
public Encodings.Encoding getEncoding()
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 void registerZeroWidthQuantifiable(QuantifiableTerm zeroWidthQuantifiable)
public List<QuantifiableTerm> getZeroWidthQuantifiables()
public Group getGroup(int index)
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 GlobalSubTreeIndex getSubtrees()
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[] groupNumbers)
public boolean isGroupReferenced(int groupNumber)
public void setGroupRecursivelyReferenced(int groupNumber)
public boolean isGroupRecursivelyReferenced(int groupNumber)
public CharacterClass createCharacterClass(CodePointSet matcherBuilder)
public Group createGroup()
public Group createCaptureGroup(int groupNumber)
public Group createConditionalBackReferenceGroup(int referencedGroupNumber)
public TBitSet getConditionGroups()
public LookAheadAssertion createLookAheadAssertion(boolean negated)
public LookBehindAssertion createLookBehindAssertion(boolean negated)
public AtomicGroup createAtomicGroup()
public void createNFAHelperNodes(RegexASTSubtreeRootNode rootNode)
public PositionAssertion createPositionAssertion(PositionAssertion.Type type)
public Sequence createSequence()
public SubexpressionCall createSubexpressionCall(int groupNumber)
public BackReference register(BackReference backReference)
public CharacterClass register(CharacterClass characterClass)
public ConditionalBackReferenceGroup register(ConditionalBackReferenceGroup group)
public LookAheadAssertion register(LookAheadAssertion lookAheadAssertion)
public LookBehindAssertion register(LookBehindAssertion lookBehindAssertion)
public AtomicGroup register(AtomicGroup atomicGroup)
public PositionAssertion register(PositionAssertion positionAssertion)
public SubexpressionCall register(SubexpressionCall subexpressionCall)
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(TBitSet updateIndices, TBitSet clearIndices, int lastGroup)
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.createCharClass(CodePointSet) 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.Token.createQuantifier(int, int, boolean) 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()
public boolean canTransformToDFA()
public String canTransformToDFAFailureReason()
public JsonValue toJson()
toJson in interface JsonConvertiblepublic static JsonArray sourceSectionsToJson(List<com.oracle.truffle.api.source.SourceSection> sourceSections)