summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-07-08 12:43:07 +0000
committeraarne <aarne@cs.chalmers.se>2007-07-08 12:43:07 +0000
commitba7061166978e74bc0b0930c5d1db695aa125bda (patch)
tree5ac85a97284c0dc14f199c882cdc9d1dee18cd65 /src
parent08f5f513d7c4134e048f53cce789cd878c093f16 (diff)
peb's forest patch
Diffstat (limited to 'src')
-rw-r--r--src/GF/Formalism/Utilities.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/GF/Formalism/Utilities.hs b/src/GF/Formalism/Utilities.hs
index 0d303b175..633064692 100644
--- a/src/GF/Formalism/Utilities.hs
+++ b/src/GF/Formalism/Utilities.hs
@@ -258,6 +258,21 @@ chart2forests :: (Ord n, Ord e) =>
-- In essence, the result is a map from 'n' to forest daughters
-- simplest implementation
+
+chart2forests chart isMeta = concatMap (edge2forests [])
+ where edge2forests edges edge
+ | isMeta edge = [FMeta]
+ | edge `elem` edges = []
+ | otherwise = map (item2forest (edge:edges)) $ chart ? edge
+ item2forest edges (SMeta) = FMeta
+ item2forest edges (SNode name children) =
+ FNode name $ children >>= mapM (edge2forests edges)
+ item2forest edges (SString s) = FString s
+ item2forest edges (SInt n) = FInt n
+ item2forest edges (SFloat f) = FFloat f
+
+{- -before AR inserted peb's patch 8/7/2007, this was:
+
chart2forests chart isMeta = concatMap edge2forests
where edge2forests edge = if isMeta edge then [FMeta]
else map item2forest $ chart ? edge
@@ -267,6 +282,7 @@ chart2forests chart isMeta = concatMap edge2forests
item2forest (SInt n) = FInt n
item2forest (SFloat f) = FFloat f
+-}
{-
-- more intelligent(?) implementation,