public final class RegexASTBuilder extends Object
| Constructor and Description |
|---|
RegexASTBuilder(RegexLanguage language,
RegexSource source,
RegexFlags flags,
CompilationBuffer compilationBuffer) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBackReference(int groupNumber) |
void |
addBackReference(Token.BackReference token)
Adds a new
BackReference to the current Sequence. |
void |
addCaret() |
void |
addCharClass(CodePointSet charSet) |
void |
addCharClass(CodePointSet charSet,
boolean wasSingleChar) |
void |
addCharClass(Token.CharacterClass token)
Adds a new
CharacterClass to the current Sequence. |
void |
addCopy(Token token,
Group sourceGroup)
Adds a copy of
sourceGroup to the current Sequence. |
void |
addDeadNode()
Adds a dead node (an empty character class) to the current
Sequence. |
void |
addDollar() |
void |
addPositionAssertion(Token token)
Adds a new
PositionAssertion to the current Sequence. |
void |
addQuantifier(Token.Quantifier quantifier)
Adds a quantifier to the current
Term. |
void |
addSubexpressionCall(int groupNumber) |
boolean |
curGroupIsRoot()
Indicates whether the builder is currently in the root group or in some nested group.
|
Group |
getCurGroup()
Returns the current
Group. |
Sequence |
getCurSequence()
|
Term |
getCurTerm()
|
void |
nextSequence()
|
void |
popGroup() |
void |
popGroup(Token token)
Close and leave the current group.
|
RegexAST |
popRootGroup()
This is the build method of this Builder.
|
void |
pushAtomicGroup() |
void |
pushAtomicGroup(Token token) |
void |
pushCaptureGroup() |
void |
pushCaptureGroup(Token token)
Creates and enters a new capture group.
|
void |
pushGroup() |
void |
pushGroup(Token token)
Creates and enters a new non-capturing group.
|
void |
pushLookAheadAssertion(boolean negate) |
void |
pushLookAheadAssertion(Token token,
boolean negate)
Creates and enters a new look-ahead assertion.
|
void |
pushLookBehindAssertion(boolean negate) |
void |
pushLookBehindAssertion(Token token,
boolean negate)
Creates and enters a new look-behind assertion.
|
void |
pushRootGroup()
This should be called first after creating a new
RegexASTBuilder. |
void |
pushRootGroup(boolean rootCapture)
Like
RegexASTBuilder.pushRootGroup(), but allows creating a non-capturing root group. |
void |
removeCurTerm()
|
void |
replaceCurTermWithDeadNode()
Replaces the current
Term with a dead node. |
void |
wrapCurTermInAtomicGroup()
Wraps the current
Term in an atomic group. |
void |
wrapCurTermInGroup()
Wraps the current
Term in a non-capturing group. |
public RegexASTBuilder(RegexLanguage language, RegexSource source, RegexFlags flags, CompilationBuffer compilationBuffer)
public Group getCurGroup()
Group. Any new Terms will be added to its last
Sequence (the one returned by RegexASTBuilder.curSequence).public Sequence getCurSequence()
public Term getCurTerm()
public boolean curGroupIsRoot()
true if the builder is in the root grouppublic void pushRootGroup()
RegexASTBuilder. This will create
and enter the root capture group (group number 0).public void pushRootGroup(boolean rootCapture)
RegexASTBuilder.pushRootGroup(), but allows creating a non-capturing root group. This is useful
for building intermediate ASTs that are then pasted into other ASTs.public RegexAST popRootGroup()
RegexASTBuilder instance.public void pushGroup(Token token)
RegexASTBuilder.popGroup(com.oracle.truffle.regex.tregex.parser.Token).token - a Token whose source section should be included in the group's source
sections, or null if nonepublic void pushGroup()
public void pushCaptureGroup(Token token)
RegexASTBuilder.popGroup(com.oracle.truffle.regex.tregex.parser.Token).token - a Token whose source section should be included in the group's source
sections, or null if nonepublic void pushCaptureGroup()
public void pushLookAheadAssertion(Token token, boolean negate)
RegexASTBuilder.popGroup(com.oracle.truffle.regex.tregex.parser.Token).token - a Token whose source section should be included in the assertion's
source sections, or null if nonenegate - true if the look-ahead assertion is to be negativepublic void pushLookAheadAssertion(boolean negate)
public void pushLookBehindAssertion(Token token, boolean negate)
RegexASTBuilder.popGroup(com.oracle.truffle.regex.tregex.parser.Token).token - a Token whose source section should be included in the assertion's
source sections, or null if nonenegate - true if the look-behind assertion is to be negativepublic void pushLookBehindAssertion(boolean negate)
public void pushAtomicGroup(Token token)
public void pushAtomicGroup()
public void popGroup(Token token)
RegexASTBuilder.pushGroup(Token), RegexASTBuilder.pushCaptureGroup(Token),
RegexASTBuilder.pushLookAheadAssertion(Token, boolean) or
RegexASTBuilder.pushLookBehindAssertion(Token, boolean).token - a Token whose source section should be included in the group's or
assertion's source sections, or null if nonepublic void popGroup()
public void nextSequence()
public void addCharClass(Token.CharacterClass token)
CharacterClass to the current Sequence.token - aside from the source sections, the token most importantly contains the set of
code points to be included in the character class and a flag indicating whether it
corresponds to a single character in the regex (i.e. a literal or an escaped
character)public void addCharClass(CodePointSet charSet, boolean wasSingleChar)
public void addCharClass(CodePointSet charSet)
public void addBackReference(Token.BackReference token)
BackReference to the current Sequence.token - aside from the source sections, this contains the number of the group being
referencedpublic void addBackReference(int groupNumber)
public void addSubexpressionCall(int groupNumber)
public void addPositionAssertion(Token token)
PositionAssertion to the current Sequence.token - aside from the source sections, the kind of this token indicates whether this is
the ^ assertion or the $ assertionpublic void addCaret()
public void addDollar()
public void addQuantifier(Token.Quantifier quantifier)
Term.quantifier - this token contains a specification of the quantifier's semantics, along
with the source section datapublic void addCopy(Token token, Group sourceGroup)
sourceGroup to the current Sequence.token - a token indicating which source sections should be attributed to the copied
groupsourceGroup - the Group to be copiedpublic void removeCurTerm()
public void addDeadNode()
Sequence.public void replaceCurTermWithDeadNode()
Term with a dead node.public void wrapCurTermInGroup()
Term in a non-capturing group.public void wrapCurTermInAtomicGroup()
Term in an atomic group. This can be useful when implementing
possessive quantifiers.