Introduce a match-case construct to Ion's grammar (#351)
* [WIP] Add a rudimentary match statement to the language * Parsing a match construct now correctly resumes on new line Before, parsing a match construct would depend on all parts of the match statement being in one piece, it can now accept it over multiple invocations of `on_command` * Match statement now forwards all conditions * Most errors are copy / paste errors * Finish comment, remove useless continue * case values are now unquoted string literals * Added example for match * case expressions are now arbitrary commands The values in case branches can now be arbitrary commands that work off set intersection (for now). For example, the case: ``` case @(seq 0 10) ``` would match any number from 0 to 10. Additionally, alternation can be done through an array, like so: ``` match $filetype case ["image/jpeg" "image/png"] ... end end ``` * Remove XXX referencing shorthand
Showing
- examples/match.ion 59 additions, 0 deletionsexamples/match.ion
- examples/match.out 17 additions, 0 deletionsexamples/match.out
- src/parser/grammar.rustpeg 21 additions, 1 deletionsrc/parser/grammar.rustpeg
- src/shell/flow.rs 88 additions, 3 deletionssrc/shell/flow.rs
- src/shell/flow_control.rs 125 additions, 2 deletionssrc/shell/flow_control.rs
Loading
Please register or sign in to comment