rustmatic
rustmatic copied to clipboard
Start case statement
Should have been a simple --amend. Seriously messed up :slightly_smiling_face:
No test yet..
Started thinking about the implementation here. I guess each case branch is sort of a conditional branch where the expression is ("case in branch-list?"). But even though there are similarities, Case should maybe have it's own struct to keep these separate?
I would keep them separate. Abstract syntax trees are meant to be a pretty accurate representation of the source code at a syntactic level. A good guideline would be to keep enough information so some hypothetical pretty-printer could walk the AST and generate roughly the same source code.
At later steps in the compilation process (i.e. "MIR" in rustc
) you'll make these sorts of simplifications. For example, converting all loops, conditionals, and switch statements into a simpler compare and branch (e.g. if condition == true then goto block_1
).