modern-compiler-ml/tiger/chap1/slp.sml

21 lines
533 B
Standard ML
Raw Normal View History

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"]))