()
| 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) { |
no test coverage detected