PTQ-0.0.4: src/Report.hs
-----------------------------------------------------------------------------
-- |
-- Module : Report
-- Copyright : (c) Masahiro Sakai 2007-2009
-- License : BSD3-style (see LICENSE)
--
-- Maintainer: masahiro.sakai@gmail.com
-- Stability : experimental
-- Portability : portable
module Report (report) where
import Expr
import P
import Parser
import MP
import Translation
import List (intersperse)
report :: String -> String
report s = unlines $
case parseAny s of
[] -> ["(parse error)"]
ps -> concat $ intersperse ["",sep,""] (map f ps)
f :: PAny -> [String]
f (PAny p) =
[ "Parsed:"
, " " ++ show p
, ""
, "Translation:"
, " " ++ show e
, ""
, "Translation (simplified):"
, " " ++ show e'
, ""
, "Translation (MP applied):"
, " " ++ show e''
]
where
e = translate p
e' = normalize e
e'' = normalize $ applyMP $ e'
sep :: String
sep = "------------------------------------------------------"