Class RegexASTNode
java.lang.Object
com.oracle.truffle.regex.tregex.parser.ast.RegexASTNode
- All Implemented Interfaces:
JsonConvertible
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasGroup()protected static JsonValueastNodeId(RegexASTNode astNode) abstract RegexASTNodeCopy this node only, without any child nodes.abstract RegexASTNodecopyRecursive(RegexAST ast, CompilationBuffer compilationBuffer) Recursively copy this subtree.booleanAll paths out of this subexpression go through"$".abstract booleanprotected intgetFlags(int mask) final intgetId()intintGets the syntactic parent of this AST node.intintabstract RegexASTSubtreeRootNodeReturns the subtree root node that this node is a part of.booleanSubexpression containsback-references.booleanSubexpression containscapturing groups.booleanhasCaret()Subexpression contains"^".booleanSubexpression contains"$".booleanIndicates whether this node should be allowed to match the empty string.booleanSubexpression containslook-ahead assertions.booleanSubexpression containslook-behind assertions.booleanhasLoops()Subexpression containsloops.booleanSubexpression containsnot unrolled quantifiers.booleanbooleanvoidvoidincMaxPath(int n) voidvoidincMinPath(int n) booleanbooleanbooleanisCaret()booleanbooleanbooleanisDead()Returns whether the node is dead, i.e.booleanisDollar()booleanIndicates whether thisRegexASTNodewas inserted into the AST as the result of expanding quantifier syntax (*, +, ?, {n,m}).protected booleanisFlagSet(int flag) booleanisGroup()booleanbooleanbooleanbooleanbooleanbooleanbooleanIndicates whether thisRegexASTNoderepresents a mandatory copy of a quantified term after unrolling.booleanbooleanbooleanisPrefix()This flag marks all nodes that were inserted into the AST for look-behind matching, seeMarkLookBehindEntriesVisitorandRegexAST.createPrefix().booleanbooleanIndicates whether this node is an emptySequenceinserted as an early escape alternative when unrolling a quantifier expression.booleanisRoot()booleanbooleanbooleanvoidMarks the node as dead, i.e.voidsetDead(boolean dead) voidsetEmptyGuard(boolean emptyGuard) voidvoidsetEndsWithDollar(boolean endsWithDollar) voidsetExpandedQuantifier(boolean expandedQuantifier) Marks thisRegexASTNodeas being inserted into the AST as part of expanding quantifier syntax (*, +, ?, {n,m}).protected voidsetFlag(int flag) protected voidsetFlag(int flag, boolean value) protected voidsetFlags(int newFlags, int mask) Update all flags denoted bymaskwith the values fromnewFlags.voidvoidvoidvoidsetHasCaret(boolean hasCaret) voidvoidsetHasDollar(boolean hasDollar) voidvoidvoidvoidsetHasLoops(boolean hasLoops) voidfinal voidsetId(int id) voidsetMandatoryUnrolledQuantifier(boolean mandatoryUnrolledQuantifier) Marks thisRegexASTNodeas being inserted into the AST as part of unrolling the mandatory part of a quantified term.voidsetMaxPath(int n) voidsetMinPath(int n) voidsetParent(RegexASTNode parent) Sets the syntactic parent of this AST node.voidSets theisPrefix()flag to true.voidsetPrefixLengthMax(int prefixLengthMax) voidsetPrefixLengthMin(int prefixLengthMin) voidsetQuantifierPassThroughSequence(boolean quantifierPassThroughSequence) Marks this emptySequenceas being inserted into the AST as part of unrolling the optional suffix of a quantified term.voidvoidsetStartsWithCaret(boolean startsWithCaret) booleanThis subexpression is dominated by"^".protected JsonObjectMethods 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.util.json.JsonConvertible
toJson
-
Constructor Details
-
RegexASTNode
protected RegexASTNode() -
RegexASTNode
-
-
Method Details
-
copy
Copy this node only, without any child nodes. The ID and minPath of the copied nodes is left unset.- Parameters:
ast- RegexAST the node should belong to.- Returns:
- A shallow copy of this node.
-
copyRecursive
Recursively copy this subtree. This method should be used instead ofCopyVisitorif the copying process is required to be thread-safe. The ID and minPath of the copied nodes is left unset.- Parameters:
ast- RegexAST the new nodes should belong to.- Returns:
- A deep copy of this node.
-
equalsSemantic
-
idInitialized
public boolean idInitialized() -
getId
public final int getId() -
setId
public final void setId(int id) -
getParent
Gets the syntactic parent of this AST node. -
setParent
Sets the syntactic parent of this AST node.- Parameters:
parent-
-
isFlagSet
protected boolean isFlagSet(int flag) -
setFlag
protected void setFlag(int flag) -
getFlags
protected int getFlags(int mask) -
setFlags
protected void setFlags(int newFlags, int mask) Update all flags denoted bymaskwith the values fromnewFlags. -
setFlag
protected void setFlag(int flag, boolean value) -
markAsDead
public void markAsDead()Marks the node as dead, i.e. unmatchable. -
setDead
public void setDead(boolean dead) -
isDead
public boolean isDead()Returns whether the node is dead, i.e. unmatchable. -
isPrefix
public boolean isPrefix()This flag marks all nodes that were inserted into the AST for look-behind matching, seeMarkLookBehindEntriesVisitorandRegexAST.createPrefix().- Returns:
- true if this node belongs to an inserted prefix construct, otherwise false.
-
setPrefix
-
hasEmptyGuard
public boolean hasEmptyGuard()Indicates whether this node should be allowed to match the empty string.- Returns:
- true if this node is not allowed to match the empty string
-
setEmptyGuard
public void setEmptyGuard(boolean emptyGuard) -
hasCaret
public boolean hasCaret()Subexpression contains"^". -
setHasCaret
public void setHasCaret() -
setHasCaret
public void setHasCaret(boolean hasCaret) -
hasDollar
public boolean hasDollar()Subexpression contains"$". -
setHasDollar
public void setHasDollar() -
setHasDollar
public void setHasDollar(boolean hasDollar) -
startsWithCaret
public boolean startsWithCaret()This subexpression is dominated by"^". -
setStartsWithCaret
public void setStartsWithCaret() -
setStartsWithCaret
public void setStartsWithCaret(boolean startsWithCaret) -
endsWithDollar
public boolean endsWithDollar()All paths out of this subexpression go through"$". -
setEndsWithDollar
public void setEndsWithDollar() -
setEndsWithDollar
public void setEndsWithDollar(boolean endsWithDollar) -
hasLoops
public boolean hasLoops()Subexpression containsloops. -
setHasLoops
public void setHasLoops() -
setHasLoops
public void setHasLoops(boolean hasLoops) -
hasQuantifiers
public boolean hasQuantifiers()Subexpression containsnot unrolled quantifiers. -
setHasQuantifiers
public void setHasQuantifiers() -
hasCaptureGroups
public boolean hasCaptureGroups()Subexpression containscapturing groups. -
setHasCaptureGroups
public void setHasCaptureGroups() -
hasLookAheads
public boolean hasLookAheads()Subexpression containslook-ahead assertions. -
setHasLookAheads
public void setHasLookAheads() -
hasLookBehinds
public boolean hasLookBehinds()Subexpression containslook-behind assertions. -
setHasLookBehinds
public void setHasLookBehinds() -
hasBackReferences
public boolean hasBackReferences()Subexpression containsback-references. -
setHasBackReferences
public void setHasBackReferences() -
isExpandedQuantifier
public boolean isExpandedQuantifier()Indicates whether thisRegexASTNodewas inserted into the AST as the result of expanding quantifier syntax (*, +, ?, {n,m}). E.g., if A is some term, then:- A* is expanded as (A|)*
- A*? is expanded as (|A)*
- A+ is expanded as A(A|)*
- A+? is expanded as A(|A)*
- A? is expanded as (A|)
- A?? is expanded as (|A)
- A{2,4} is expanded as AA(A(A|)|)
- A{2,4}? is expanded as AA(|A(|A))
Sequences would be marked with this flag. -
setExpandedQuantifier
public void setExpandedQuantifier(boolean expandedQuantifier) Marks thisRegexASTNodeas being inserted into the AST as part of expanding quantifier syntax (*, +, ?, {n,m}).- See Also:
-
isMandatoryUnrolledQuantifier
public boolean isMandatoryUnrolledQuantifier()Indicates whether thisRegexASTNoderepresents a mandatory copy of a quantified term after unrolling. E.g., in the expansion of A{2,4}, which is AA(A(A|)|), the first two occurrences of A are marked with this flag. -
setMandatoryUnrolledQuantifier
public void setMandatoryUnrolledQuantifier(boolean mandatoryUnrolledQuantifier) Marks thisRegexASTNodeas being inserted into the AST as part of unrolling the mandatory part of a quantified term.- See Also:
-
isQuantifierPassThroughSequence
public boolean isQuantifierPassThroughSequence()Indicates whether this node is an emptySequenceinserted as an early escape alternative when unrolling a quantifier expression. E.g., in the expansion of A{2,4}, which is AA(A(A|_)|_), the two_characters show the two empty sequences marked with this flag. -
setQuantifierPassThroughSequence
public void setQuantifierPassThroughSequence(boolean quantifierPassThroughSequence) Marks this emptySequenceas being inserted into the AST as part of unrolling the optional suffix of a quantified term.- See Also:
-
getMinPath
public int getMinPath() -
setMinPath
public void setMinPath(int n) -
incMinPath
public void incMinPath() -
incMinPath
public void incMinPath(int n) -
getMaxPath
public int getMaxPath() -
setMaxPath
public void setMaxPath(int n) -
incMaxPath
public void incMaxPath() -
incMaxPath
public void incMaxPath(int n) -
getPrefixLengthMin
public int getPrefixLengthMin() -
setPrefixLengthMin
public void setPrefixLengthMin(int prefixLengthMin) -
getPrefixLengthMax
public int getPrefixLengthMax() -
setPrefixLengthMax
public void setPrefixLengthMax(int prefixLengthMax) -
hasVariablePrefixLength
public boolean hasVariablePrefixLength() -
getSubTreeParent
Returns the subtree root node that this node is a part of. If this node is nested inside several look-around assertion nodes, returns the innermost one that contains this node. Every AST node should have a subtree parent, but nodes implicitly generated byRegexAST.getNFAAnchoredInitialState(int)andRegexAST.getNFAUnAnchoredInitialState(int)technically don't belong to the AST, so they will returnnull. -
isInLookBehindAssertion
public boolean isInLookBehindAssertion() -
isInLookAheadAssertion
public boolean isInLookAheadAssertion() -
toStringWithID
-
astNodeId
-
isBackReference
public boolean isBackReference() -
isCharacterClass
public boolean isCharacterClass() -
isGroup
public boolean isGroup() -
isGroupWithGuards
public boolean isGroupWithGuards() -
isConditionalBackReferenceGroup
public boolean isConditionalBackReferenceGroup() -
isLookAroundAssertion
public boolean isLookAroundAssertion() -
isLookAheadAssertion
public boolean isLookAheadAssertion() -
isLookBehindAssertion
public boolean isLookBehindAssertion() -
isAtomicGroup
public boolean isAtomicGroup() -
isMatchFound
public boolean isMatchFound() -
isPositionAssertion
public boolean isPositionAssertion() -
isQuantifiableTerm
public boolean isQuantifiableTerm() -
isSubexpressionCall
public boolean isSubexpressionCall() -
isRoot
public boolean isRoot() -
isSubtreeRoot
public boolean isSubtreeRoot() -
isSequence
public boolean isSequence() -
isCaret
public boolean isCaret() -
isDollar
public boolean isDollar() -
asBackReference
-
asCharacterClass
-
asGroup
-
asConditionalBackReferenceGroup
-
asLookAroundAssertion
-
asLookAheadAssertion
-
asLookBehindAssertion
-
asAtomicGroup
-
asSubtreeRootNode
-
asMatchFound
-
asPositionAssertion
-
asQuantifiableTerm
-
asSequence
-
asSubexpressionCall
-
toJson
-