Appearance
| 1 | namespace Syntax.Process is | |
| 2 | // Detects whether a loop body contains a `break` that targets | |
| 3 | // *this* loop — used to decide whether an unconditional `do` | |
| 4 | // loop can complete at all. Nested `do` / `for` loops are not | |
| 5 | // descended into, so a `break` inside a nested loop (which | |
| 6 | // targets that inner loop) is not counted. | |
| 7 | // | |
| 8 | // A `Visitor` whose default per-node visits are no-ops and whose | |
| 9 | // default `pre` returns false, so only the nested-loop `pre` | |
| 10 | // overrides and `visit(BREAK)` are needed. | |
| 11 | class LOOP_BREAK_FINDER: Visitor is | |
| 12 | found: bool public; | |
| 13 | ||
| 14 | init() is | |
| 15 | super.init(); | |
| 16 | si | |
| 17 | ||
| 18 | pre(`do: Trees.Statements.DO) -> bool => true; | |
| 19 | ||
| 20 | pre(`for: Trees.Statements.FOR) -> bool => true; | |
| 21 | ||
| 22 | visit(`break: Trees.Statements.BREAK) is | |
| 23 | found = true; | |
| 24 | si | |
| 25 | si | |
| 26 | si |