Appearance
| 1 | namespace Source is | |
| 2 | class LOCATION_STACK is | |
| 3 | // A null entry stands for no position at all, for a value built | |
| 4 | // where the one it stands in for was built without one. | |
| 5 | _stack: Collections.STACK[LOCATION?] | |
| 6 | ||
| 7 | init() is | |
| 8 | _stack = Collections.STACK[LOCATION?]() | |
| 9 | si | |
| 10 | ||
| 11 | is_empty: bool => _stack.count == 0 | |
| 12 | ||
| 13 | current: LOCATION? => | |
| 14 | if _stack.count > 0 then | |
| 15 | _stack.peek() | |
| 16 | else | |
| 17 | null | |
| 18 | fi | |
| 19 | ||
| 20 | push(location: LOCATION?) is | |
| 21 | _stack.push(location) | |
| 22 | si | |
| 23 | ||
| 24 | pop() is | |
| 25 | assert _stack.count > 0 | |
| 26 | _stack.pop() | |
| 27 | si | |
| 28 | si | |
| 29 | si |