Class RegExpTree
java.lang.Object
com.google.javascript.jscomp.regex.RegExpTree
- Direct Known Subclasses:
RegExpTree.Alternation,RegExpTree.CapturingGroup,RegExpTree.Concatenation,RegExpTree.LookaheadAssertion,RegExpTree.LookbehindAssertion,RegExpTree.NamedCaptureGroup,RegExpTree.RegExpTreeAtom,RegExpTree.Repetition
An AST for JavaScript regular expressions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents the possibilities ["foo", "bar" ] for a RegExp /foo|bar/static final classRepresents an anchor, namely ^ or $.static final classRepresents a reference to a previous group such as \1 or \2static final classRepresents a capturing group such as (asdf)static final classRepresents a set of possible characters structured as [a-zA-Z] or [^a-zA-Z]static final classRepresents a series of nodes chained one after another such as (?:...)[a-z]*(...)static final classRepresents an empty portion of a RegExp such as the middle of "||"static final classRepresents a lookahead assertion such as (?=...) or (?!...)static final classRepresents a lookbehind assertion such as(?<=...)or(?<!...)static final classRepresents a reference to a previous named groupstatic final classRepresents a named capture groupstatic classRepresents a node that never has children such as an anchor or charset.static final classRepresents a repeating item such as ...+, ...*, or ...{0,1}static final classRepresents a run of non-special characters such as "foobar"static final classRepresents a Unicode Property Escape such as in /\p{Script=Greek}/ustatic final classRepresents \b or \B -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidprotected abstract voidAppends this regular expression source to the given buffer.abstract List<? extends RegExpTree> children()The children of this node.abstract booleanTrue if the regular expression contains an anchor :^or$.abstract booleanfinal booleanTrue if the regular expression contains capturing groups.abstract inthashCode()abstract booleanTrue if the presence or absence of an"i"flag would change the meaning of this regular expression.static booleanmatchesWholeInput(RegExpTree t, String flags) True if, but not necessarily always when the, given regular expression must match the whole input or none of it.abstract intThe number of capturing groups.static RegExpTreeparseRegExp(String pattern, String flags) Parses a regular expression to an AST.abstract RegExpTreeReturns a simpler regular expression that is semantically the same assuming the given flags.final StringtoString()
-
Constructor Details
-
RegExpTree
public RegExpTree()
-
-
Method Details
-
simplify
Returns a simpler regular expression that is semantically the same assuming the given flags.- Parameters:
flags- Regular expression flags, e.g."igm".
-
isCaseSensitive
public abstract boolean isCaseSensitive()True if the presence or absence of an"i"flag would change the meaning of this regular expression. -
containsAnchor
public abstract boolean containsAnchor()True if the regular expression contains an anchor :^or$. -
hasCapturingGroup
public final boolean hasCapturingGroup()True if the regular expression contains capturing groups. -
numCapturingGroups
public abstract int numCapturingGroups()The number of capturing groups. -
children
The children of this node. -
appendSourceCode
Appends this regular expression source to the given buffer. -
appendDebugInfo
-
toString
-
equals
-
hashCode
public abstract int hashCode() -
parseRegExp
Parses a regular expression to an AST.- Parameters:
pattern- ThefooFrom/foo/i.flags- TheiFrom/foo/i.
-
matchesWholeInput
True if, but not necessarily always when the, given regular expression must match the whole input or none of it.
-