| 127 | |
| 128 | /** A whole `when` as tokens: scenarios joined by OR, each its guards joined by AND. Empty when unconditional. */ |
| 129 | export function whenTokens(when: string): WordToken[] { |
| 130 | if (!when) return []; |
| 131 | return joinWith( |
| 132 | splitTop(when, ' || ').map((scenario) => joinWith(distinct(splitTop(scenario, ' && ')).map(clauseTokens), 'AND')), |
| 133 | 'OR' |
| 134 | ); |
| 135 | } |
| 136 | |
| 137 | /** {@link whenTokens} led by WHEN, or `always` when there is nothing to say. */ |
| 138 | export function conditionTokens(when: string): WordToken[] { |