module Program(T, parse, fromString, toString, exec) where
import Parser hiding (T)
import qualified Statement
import qualified Dictionary
import Prelude hiding (return, fail)
newtype T = Program [Statement.T] deriving Show

prg = (iter Statement.parse) >-> buildPrg
buildPrg = Program

str :: T -> String
--str pr = show pr --=> Working but UGLY
str pr = ((foldl (++) "Program:\n") . map Statement.toString) stmts
    where Program stmts = pr

instance Parse T where
  parse = prg
  toString = str

exec' pr input = Statement.exec p Dictionary.empty input
    where Program p = pr
exec = exec'
