module FPPrac.Trees.ParseTree
( ParseTree(..)
, showTree
, showTreeList
, exampleTree
) where
import EventLoop.Output.Single (outSingle)
import EventLoop.Output
import EventLoop.CommonTypes
import FPPrac.Trees.GeneralTree
data ParseTree = ParseNode String [ParseTree]
deriving (Show, Eq)
instance GeneralizeTree ParseTree where
generalizeTree (ParseNode str children) = GeneralTreeBox content children'WithLines
where
content = [GeneralNodeText (0,0,0) str]
children'WithLines = zip (repeat line) (map generalizeTree children)
line = GeneralLine (125,125,125)
exampleTree = ParseNode "z"
[ ParseNode "aaa"
[ ParseNode "bbb"
[ ParseNode "ccc" [],
ParseNode "ddd" []
],
ParseNode ""
[ParseNode "fff" [],
ParseNode "ggg" [],
ParseNode "hhh" []
],
ParseNode "iii"
[ParseNode "" []
]
],
ParseNode "kkk"
[ParseNode "lll" [],
ParseNode "mmm"
[ParseNode "nnn"
[ParseNode "q" [],
ParseNode "r" []
],
ParseNode "ooo" [],
ParseNode "ppp" []
]
]
]