Main-is: Main.hs
Hs-Source-Dirs: src
GHC-Options: -Wall -fno-warn-missing-signatures
- Build-Depends: base, containers, parsec >= 3
+ Build-Depends: base, containers, parsec >= 3, pretty
module HighLevel where
import TargetMapping
-import Data.Map as Map (Map, lookup, insertWithKey, empty)
+import Text.PrettyPrint
+import Data.Map as Map (Map, lookup, insertWithKey, assocs, empty)
import Data.List (foldl')
-- The top-level types
symbols :: SymbolTable,
assignments :: [Assignment],
targetMappings :: MappingTable
-} deriving Show
+}
+
+toDoc :: OFL -> Doc
+toDoc ofl = symbolDoc $$ assignmentsDoc $$ targetMappingsDoc
+ where
+ symbolDoc = text "Symbol table:"
+ $$ nest 1 (foldl' ($$) Text.PrettyPrint.empty [text $ show x | x <- assocs $ symbols ofl])
+ assignmentsDoc = text "Assignments: "
+ $$ nest 1 (foldl' ($$) Text.PrettyPrint.empty [text $ show x | x <- assignments ofl])
+ targetMappingsDoc = text "Target properties: "
+ $$ nest 1 (foldl' ($$) Text.PrettyPrint.empty [text $ show x | x <- assocs $ targetMappings ofl])
+
+instance Show OFL where
+ show ofl = renderStyle Style {mode = PageMode, lineLength=10, ribbonsPerLine=1.5 } $ toDoc ofl
-- Symbol table manipulators
addValueDeclaration :: OFL -> String -> BaseType -> [IndexType] -> OFL