import Data.Complex
import Text.PrettyPrint
import Data.Map (Map)
-import Data.List (foldl', intersperse)
+import Data.List (foldl', intersperse, intercalate)
import qualified Data.Map as Map
type SymbolTable = Map String SymbolType
toDoc ofl2 = vcat [symbolDoc, assignmentsDoc]
where
symbolDoc = text "Symbol table:"
- $$ nest 1 (vcat [text $ show x | x <- Map.assocs $ symbols ofl2])
+ $$ nest 1 (vcat [symAssocToDoc x | x <- Map.assocs $ symbols ofl2])
assignmentsDoc = text "Assignments: "
$$ nest 1 (vcat $ map toDoc $ assignments ofl2)
+ symAssocToDoc (name, ValueTag baseType indexTypes) = text $
+ (show baseType) ++ " " ++ name ++ case indexTypes of
+ [] -> ""
+ nonNil -> "[" ++ (intercalate ", " (map TopLevel.toOFLString nonNil)) ++ "]"
+ symAssocToDoc (name, IndexTag indexType quant) =
+ text $ TopLevel.toOFLString indexType ++ " " ++ name ++ " (" ++ show quant ++ ")"
emptyOFL2 :: OFL2
emptyOFL2 = OFL2 {
import OFC.TargetMapping
import OFC.Common
import Text.PrettyPrint
-import Data.List (foldl', intersperse)
+import Data.List (foldl', intersperse, intercalate)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
toDoc ofl = vcat [symbolDoc, assignmentsDoc, targetMappingsDoc, outputFunctionDoc]
where
symbolDoc = text "Symbol table:"
- $$ nest 1 (vcat [text $ show x | x <- Map.assocs $ symbols ofl])
+ $$ nest 1 (vcat [symAssocToDoc x | x <- Map.assocs $ symbols ofl])
assignmentsDoc = text "Assignments: "
$$ nest 1 (vcat $ map toDoc $ assignments ofl)
targetMappingsDoc = text "Target properties: "
$$ nest 1 (vcat [text $ show x | x <- Map.assocs $ targetMappings ofl])
outputFunctionDoc = text "OutputFunction:"
$$ nest 1 (text $ show $ outputFunction ofl)
+ symAssocToDoc (name, ValueTag baseType indexTypes) = text $
+ (toOFLString baseType) ++ " " ++ name ++ case indexTypes of
+ [] -> ""
+ nonNil -> "[" ++ (intercalate ", " (map toOFLString nonNil)) ++ "]"
+ symAssocToDoc (name, IndexTag indexType) = text $ toOFLString indexType ++ " " ++ name
-- Symbol table manipulators
addValueDeclaration :: OFL -> String -> BaseType -> [IndexType] -> OFL