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

Method parseRightParen

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

Source from the content-addressed store, hash-verified

1303
1304 // parseRightParen handles a ')' in the input.
1305 private void parseRightParen() throws PatternSyntaxException {
1306 concat();
1307 if (swapVerticalBar()) {
1308 pop(); // pop vertical bar
1309 }
1310 alternate();
1311
1312 int n = stack.size();
1313 if (n < 2) {
1314 throw new PatternSyntaxException(ERR_INTERNAL_ERROR, "stack underflow");
1315 }
1316 Regexp re1 = pop();
1317 Regexp re2 = pop();
1318 if (re2.op != Regexp.Op.LEFT_PAREN) {
1319 throw new PatternSyntaxException(ERR_MISSING_PAREN, wholeRegexp);
1320 }
1321 // Restore flags at time of paren.
1322 this.flags = re2.flags;
1323 if (re2.cap == 0) {
1324 // Just for grouping.
1325 push(re1);
1326 } else {
1327 re2.op = Regexp.Op.CAPTURE;
1328 re2.subs = new Regexp[] {re1};
1329 push(re2);
1330 }
1331 }
1332
1333 // parseEscape parses an escape sequence at the beginning of s
1334 // and returns the rune.

Callers 1

parseInternalMethod · 0.95

Calls 5

concatMethod · 0.95
swapVerticalBarMethod · 0.95
popMethod · 0.95
alternateMethod · 0.95
pushMethod · 0.95

Tested by

no test coverage detected