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

Method alt

java/com/google/re2j/Compiler.java:103–118  ·  view source on GitHub ↗
(Frag f1, Frag f2)

Source from the content-addressed store, hash-verified

101
102 // Given fragments for a and b, returns fragment for a|b.
103 private Frag alt(Frag f1, Frag f2) {
104 // alt of failure is other
105 if (f1.i == 0) {
106 return f2;
107 }
108 if (f2.i == 0) {
109 return f1;
110 }
111 Frag f = newInst(Inst.ALT);
112 Inst i = prog.getInst(f.i);
113 i.out = f1.i;
114 i.arg = f2.i;
115 f.out = prog.append(f1.out, f2.out);
116 f.nullable = f1.nullable || f2.nullable;
117 return f;
118 }
119
120 // loop returns the fragment for the main loop of a plus or star.
121 // For plus, it can be used directly. with f1.i as the entry.

Callers 1

compileMethod · 0.95

Calls 3

newInstMethod · 0.95
getInstMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected