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

Method cleanAlt

java/com/google/re2j/Parser.java:297–312  ·  view source on GitHub ↗
(Regexp re)

Source from the content-addressed store, hash-verified

295
296 // cleanAlt cleans re for eventual inclusion in an alternation.
297 private void cleanAlt(Regexp re) {
298 if (re.op == Regexp.Op.CHAR_CLASS) {
299 re.runes = new CharClass(re.runes).cleanClass().toArray();
300 if (re.runes.length == 2 && re.runes[0] == 0 && re.runes[1] == Unicode.MAX_RUNE) {
301 re.runes = null;
302 re.op = Regexp.Op.ANY_CHAR;
303 } else if (re.runes.length == 4
304 && re.runes[0] == 0
305 && re.runes[1] == '\n' - 1
306 && re.runes[2] == '\n' + 1
307 && re.runes[3] == Unicode.MAX_RUNE) {
308 re.runes = null;
309 re.op = Regexp.Op.ANY_CHAR_NOT_NL;
310 }
311 }
312 }
313
314 // collapse returns the result of applying op to subs[start:end].
315 // If (sub contains op nodes, they all get hoisted up

Callers 3

alternateMethod · 0.95
factorMethod · 0.95
swapVerticalBarMethod · 0.95

Calls 2

toArrayMethod · 0.80
cleanClassMethod · 0.80

Tested by

no test coverage detected