modern-compiler-ml/tiger/chap1/slp.sml
jmug 33d8bac511 Add the tiger source code bundle from the book site
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
2024-12-18 15:18:45 -08:00

20 lines
533 B
Standard ML

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
val prog =
CompoundStm(AssignStm("a",OpExp(NumExp 5, Plus, NumExp 3)),
CompoundStm(AssignStm("b",
EseqExp(PrintStm[IdExp"a",OpExp(IdExp"a", Minus,NumExp 1)],
OpExp(NumExp 10, Times, IdExp"a"))),
PrintStm[IdExp "b"]))