Class Parser
java.lang.Object
com.google.re2j.Parser
A parser of regular expression patterns.
The only public entry point is
parse(String pattern, int flags).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[][]private static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate intprivate Regexpprivate intprivate final Parser.Stackprivate final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Regexpprivate voidprivate Regexpprivate Regexpconcat()private static int[]concatRunes(int[] x, int[] y) private Regexp[]private static booleanisCharClass(Regexp re) private static booleanisValidCaptureName(String name) private static RegexpleadingRegexp(Regexp re) private voidliteral(int r) private static RegexpliteralRegexp(String s, int flags) private static booleanprivate booleanmaybeConcat(int r, int flags) private static voidmergeCharClass(Regexp dst, Regexp src) private static intminFoldRune(int r) private RegexpnewLiteral(int r, int flags) private Regexpprivate Regexp(package private) static RegexpParse regular expression patternpatternwith mode flagsflags.private voidprivate static intparseClassChar(Parser.StringIterator t, int wholeClassPos) private static intprivate static intprivate Regexpprivate booleanprivate booleanprivate voidprivate static intprivate voidprivate booleanprivate voidprivate Regexppop()private Regexp[]private Regexpprivate RegexpremoveLeadingRegexp(Regexp re, boolean reuse) private RegexpremoveLeadingString(Regexp re, int n) private voidrepeat(Regexp.Op op, int min, int max, int beforePos, Parser.StringIterator t, int lastRepeatPos) private void(package private) static Regexp[]/ Utilitiesprivate booleanprivate static Parser.Pair<int[][], int[][]> unicodeTable(String name)
-
Field Details
-
ERR_INTERNAL_ERROR
- See Also:
-
ERR_INVALID_CHAR_CLASS
- See Also:
-
ERR_INVALID_CHAR_RANGE
- See Also:
-
ERR_INVALID_ESCAPE
- See Also:
-
ERR_INVALID_NAMED_CAPTURE
- See Also:
-
ERR_INVALID_PERL_OP
- See Also:
-
ERR_INVALID_REPEAT_OP
- See Also:
-
ERR_INVALID_REPEAT_SIZE
- See Also:
-
ERR_MISSING_BRACKET
- See Also:
-
ERR_MISSING_PAREN
- See Also:
-
ERR_MISSING_REPEAT_ARGUMENT
- See Also:
-
ERR_TRAILING_BACKSLASH
- See Also:
-
ERR_DUPLICATE_NAMED_CAPTURE
- See Also:
-
wholeRegexp
-
flags
private int flags -
stack
-
free
-
numCap
private int numCap -
namedGroups
-
ANY_TABLE
private static final int[][] ANY_TABLE
-
-
Constructor Details
-
Parser
Parser(String wholeRegexp, int flags)
-
-
Method Details
-
newRegexp
-
reuse
-
pop
-
popToPseudo
-
push
-
maybeConcat
private boolean maybeConcat(int r, int flags) -
newLiteral
-
minFoldRune
private static int minFoldRune(int r) -
literal
private void literal(int r) -
op
-
repeat
private void repeat(Regexp.Op op, int min, int max, int beforePos, Parser.StringIterator t, int lastRepeatPos) throws PatternSyntaxException - Throws:
PatternSyntaxException
-
concat
-
alternate
-
cleanAlt
-
collapse
-
factor
-
removeLeadingString
-
leadingRegexp
-
removeLeadingRegexp
-
literalRegexp
-
parse
Parse regular expression patternpatternwith mode flagsflags.- Throws:
PatternSyntaxException
-
parseInternal
- Throws:
PatternSyntaxException
-
parseRepeat
- Throws:
PatternSyntaxException
-
parsePerlFlags
- Throws:
PatternSyntaxException
-
isValidCaptureName
-
parseInt
-
isCharClass
-
matchRune
-
parseVerticalBar
private void parseVerticalBar() -
mergeCharClass
-
swapVerticalBar
private boolean swapVerticalBar() -
parseRightParen
- Throws:
PatternSyntaxException
-
parseEscape
- Throws:
PatternSyntaxException
-
parseClassChar
private static int parseClassChar(Parser.StringIterator t, int wholeClassPos) throws PatternSyntaxException - Throws:
PatternSyntaxException
-
parsePerlClassEscape
-
parseNamedClass
private boolean parseNamedClass(Parser.StringIterator t, CharClass cc) throws PatternSyntaxException - Throws:
PatternSyntaxException
-
unicodeTable
-
parseUnicodeClass
private boolean parseUnicodeClass(Parser.StringIterator t, CharClass cc) throws PatternSyntaxException - Throws:
PatternSyntaxException
-
parseClass
- Throws:
PatternSyntaxException
-
subarray
-
concatRunes
private static int[] concatRunes(int[] x, int[] y)
-