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
public abstract class RegExpTree extends java.lang.ObjectAn AST for JavaScript regular expressions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRegExpTree.AlternationRepresents the possibilities ["foo", "bar" ] for a RegExp /foo|bar/static classRegExpTree.AnchorRepresents an anchor, namely ^ or $.static classRegExpTree.BackReferenceRepresents a reference to a previous group such as \1 or \2static classRegExpTree.CapturingGroupRepresents a capturing group such as (asdf)static classRegExpTree.CharsetRepresents a set of possible characters structured as [a-zA-Z] or [^a-zA-Z]static classRegExpTree.ConcatenationRepresents a series of nodes chained one after another such as (?:...)[a-z]*(...)static classRegExpTree.EmptyRepresents an empty portion of a RegExp such as the middle of "||"static classRegExpTree.LookaheadAssertionRepresents a lookahead assertion such as (?=...) or (?!...)static classRegExpTree.LookbehindAssertionRepresents a lookbehind assertion such as(?<=...)or(?<!...)static classRegExpTree.NamedBackReferenceRepresents a reference to a previous named groupstatic classRegExpTree.NamedCaptureGroupRepresents a named capture groupstatic classRegExpTree.RegExpTreeAtomRepresents a node that never has children such as an anchor or charset.static classRegExpTree.RepetitionRepresents a repeating item such as ...+, ...*, or ...{0,1}static classRegExpTree.TextRepresents a run of non-special characters such as "foobar"static classRegExpTree.UnicodePropertyEscapeRepresents a Unicode Property Escape such as in /\p{Script=Greek}/ustatic classRegExpTree.WordBoundaryRepresents \b or \B
-
Constructor Summary
Constructors Constructor Description RegExpTree()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidappendDebugInfo(java.lang.StringBuilder sb)protected abstract voidappendSourceCode(java.lang.StringBuilder sb)Appends this regular expression source to the given buffer.abstract java.util.List<? extends RegExpTree>children()The children of this node.abstract booleancontainsAnchor()True if the regular expression contains an anchor :^or$.abstract booleanequals(java.lang.Object o)booleanhasCapturingGroup()True if the regular expression contains capturing groups.abstract inthashCode()abstract booleanisCaseSensitive()True if the presence or absence of an"i"flag would change the meaning of this regular expression.static booleanmatchesWholeInput(RegExpTree t, java.lang.String flags)True if, but not necessarily always when the, given regular expression must match the whole input or none of it.abstract intnumCapturingGroups()The number of capturing groups.static RegExpTreeparseRegExp(java.lang.String pattern, java.lang.String flags)Parses a regular expression to an AST.abstract RegExpTreesimplify(java.lang.String flags)Returns a simpler regular expression that is semantically the same assuming the given flags.java.lang.StringtoString()
-
-
-
Method Detail
-
simplify
public abstract RegExpTree simplify(java.lang.String flags)
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
public abstract java.util.List<? extends RegExpTree> children()
The children of this node.
-
appendSourceCode
protected abstract void appendSourceCode(java.lang.StringBuilder sb)
Appends this regular expression source to the given buffer.
-
appendDebugInfo
protected abstract void appendDebugInfo(java.lang.StringBuilder sb)
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public abstract boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public abstract int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
parseRegExp
public static RegExpTree parseRegExp(java.lang.String pattern, java.lang.String flags)
Parses a regular expression to an AST.- Parameters:
pattern- ThefooFrom/foo/i.flags- TheiFrom/foo/i.
-
matchesWholeInput
public static boolean matchesWholeInput(RegExpTree t, java.lang.String flags)
True if, but not necessarily always when the, given regular expression must match the whole input or none of it.
-
-