-- Identifiers are synonyms for strings type Id = String -- Binary operators data Binop = Plus | Minus | Times | Div deriving (Eq,Show) -- Statements data Stm = CompoundStm Stm Stm | AssignStm Id Exp | PrintStm [Exp] deriving (Eq,Show) -- Expressions data Exp = IdExp Id | NumExp Int | OpExp Exp Binop Exp | EseqExp Stm Exp deriving (Eq,Show) -- Representation of the program -- "a := 5+3 ; b := (print(a,a-1),10*a); print(b)" -- as a derivation tree: 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"]))