Skip to content

Translating Modern Compiler Implementation in ML #1221

Answered by stylewarning
lee-thomp asked this question in Help!
Discussion options

You must be logged in to vote

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.

(coalton-toplevel
  (define-type Ident
    (Ident String))

  (define-type BinOp
    Plus
    Minus
    Times
    Div)

  (define-type Stm
    (CompoundStm Stm Stm)
    (AssignStm Ident Exp)
    (PrintStm (List Exp)))

  (define-type Exp
    (IdExp Ident)
    (NumExp Integer)
    (OpExp Exp BinOp Exp)
    (ESeqExp Stm Exp)))

I would love to see "Modern Compiler Implementation in Coalton"! 😊

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by lee-thomp
Comment options

You must be logged in to vote
1 reply
@stylewarning
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help!
Labels
None yet
2 participants