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

Method alternate

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

Source from the content-addressed store, hash-verified

274 // alternate replaces the top of the stack (above the topmost '(') with its
275 // alternation.
276 private Regexp alternate() {
277 // Scan down to find pseudo-operator (.
278 // There are no | above (.
279 Regexp[] subs = popToPseudo();
280
281 // Make sure top class is clean.
282 // All the others already are (see swapVerticalBar).
283 if (subs.length > 0) {
284 cleanAlt(subs[subs.length - 1]);
285 }
286
287 // Empty alternate is special case
288 // (shouldn't happen but easy to handle).
289 if (subs.length == 0) {
290 return push(newRegexp(Regexp.Op.NO_MATCH));
291 }
292
293 return push(collapse(subs, Regexp.Op.ALTERNATE));
294 }
295
296 // cleanAlt cleans re for eventual inclusion in an alternation.
297 private void cleanAlt(Regexp re) {

Callers 2

parseInternalMethod · 0.95
parseRightParenMethod · 0.95

Calls 5

popToPseudoMethod · 0.95
cleanAltMethod · 0.95
pushMethod · 0.95
newRegexpMethod · 0.95
collapseMethod · 0.95

Tested by

no test coverage detected