cue: add fallback keyword for for comprehensions
Add support for the 'fallback' keyword in for comprehensions,
distinct from 'else' used with if/try comprehensions:
- 'for ... fallback { }' - when no iterations produce results
- 'if ... else { }' - binary true/false choice
- 'try ... else { }' - success/failure handling
This provides clearer semantics: 'else' implies binary choice
while 'fallback' indicates a default when no results are produced.
Changes:
- Add FALLBACK token to lexer
- Rename ElseClause to FallbackClause in AST
- Parser validates correct keyword per clause type
- Both keywords can still be used as field labels
- Update formatter and exporter for correct output
- Gate both else and fallback clauses behind @experiment(try)
- Undo spec changes to move them to the "holding" CL
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I3682486cd94f30bcfd3eba55b3f31dcdf3507542
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1231630
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>