MCPcopy Create free account
hub / github.com/google/re2j / parseInternal

Method parseInternal

java/com/google/re2j/Parser.java:792–986  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

790 }
791
792 private Regexp parseInternal() throws PatternSyntaxException {
793 if ((flags & RE2.LITERAL) != 0) {
794 // Trivial parser for literal string.
795 return literalRegexp(wholeRegexp, flags);
796 }
797
798 // Otherwise, must do real work.
799 int lastRepeatPos = -1, min = -1, max = -1;
800 StringIterator t = new StringIterator(wholeRegexp);
801 while (t.more()) {
802 int repeatPos = -1;
803 bigswitch:
804 switch (t.peek()) {
805 default:
806 literal(t.pop());
807 break;
808
809 case '(':
810 if ((flags & RE2.PERL_X) != 0 && t.lookingAt("(?")) {
811 // Flag changes and non-capturing groups.
812 parsePerlFlags(t);
813 break;
814 }
815 op(Regexp.Op.LEFT_PAREN).cap = ++numCap;
816 t.skip(1); // '('
817 break;
818
819 case '|':
820 parseVerticalBar();
821 t.skip(1); // '|'
822 break;
823
824 case ')':
825 parseRightParen();
826 t.skip(1); // ')'
827 break;
828
829 case '^':
830 if ((flags & RE2.ONE_LINE) != 0) {
831 op(Regexp.Op.BEGIN_TEXT);
832 } else {
833 op(Regexp.Op.BEGIN_LINE);
834 }
835 t.skip(1); // '^'
836 break;
837
838 case '$':
839 if ((flags & RE2.ONE_LINE) != 0) {
840 op(Regexp.Op.END_TEXT).flags |= RE2.WAS_DOLLAR;
841 } else {
842 op(Regexp.Op.END_LINE);
843 }
844 t.skip(1); // '$'
845 break;
846
847 case '.':
848 if ((flags & RE2.DOT_NL) != 0) {
849 op(Regexp.Op.ANY_CHAR);

Callers 1

parseMethod · 0.80

Calls 15

literalRegexpMethod · 0.95
moreMethod · 0.95
peekMethod · 0.95
literalMethod · 0.95
popMethod · 0.95
lookingAtMethod · 0.95
parsePerlFlagsMethod · 0.95
opMethod · 0.95
skipMethod · 0.95
parseVerticalBarMethod · 0.95
parseRightParenMethod · 0.95
parseClassMethod · 0.95

Tested by

no test coverage detected