Translating Modern Compiler Implementation in ML #1221
-
How would I go about translating the following from Figure 1.4 of "Modern Compiler Implementation in ML" into Coalton? I'm stuck on the mutual recursion of type id = string
datatype binop = Plus | Minus | Times | Div
datatype stm = CompoundStm of stm * stm
| AssignStm of id * exp
| PrintStm of exp list
and exp = IdExp of id
| NumExp of int
| OpExp of exp * binop * exp
| EseqExp of stm * exp |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The only thing that's not directly supported are type aliases. That's a feature being designed right now. So you'd either need to just use a dedicated type for that, or don't use it at all. In this example, I'll just make a new type called
I would love to see "Modern Compiler Implementation in Coalton"! 😊 |
Beta Was this translation helpful? Give feedback.
-
Ah okay I found the source of my issue. I'd actually translated it exactly as you described before posting my message. I'd managed to catch the issue where Replacing |
Beta Was this translation helpful? Give feedback.
The only thing that's not directly supported are type aliases. That's a feature being designed right now. So you'd either need to just use a dedicated type for that, or don't use it at all.
In this example, I'll just make a new type called
Ident
. A translation would look something like this.I would love to see "Modern Compiler Implementation in Coalton"! 😊