summaryrefslogtreecommitdiff
path: root/src/GF/API.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-02-23 16:28:06 +0000
committeraarne <aarne@cs.chalmers.se>2007-02-23 16:28:06 +0000
commit5264780e67d74eb16a4cb499072b89b57ca4a37c (patch)
tree25925ff4bf8532101f180400f68045be3932d7ed /src/GF/API.hs
parent1d803dff1056e8cc04e9ef3998a7107b952b99c1 (diff)
cc -table
Diffstat (limited to 'src/GF/API.hs')
-rw-r--r--src/GF/API.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/GF/API.hs b/src/GF/API.hs
index 9eb60ef19..f7bd5fc9c 100644
--- a/src/GF/API.hs
+++ b/src/GF/API.hs
@@ -434,3 +434,24 @@ nonLiteralsToUTF8 ('"':cs) = '"' : l ++ nonLiteralsToUTF8 rs
takeStringLit (c:cs) = (c:xs,ys)
where (xs,ys) = takeStringLit cs
nonLiteralsToUTF8 (c:cs) = encodeUTF8 [c] ++ nonLiteralsToUTF8 cs
+
+
+printParadigm :: G.Term -> String
+printParadigm term =
+ if hasTable term then
+ (unlines . map prBranch . branches . head . tables) term
+ else
+ prt term
+ where
+ tables t = case t of
+ G.R rs -> concatMap (tables . snd . snd) rs
+ G.T _ cs -> [cs]
+ _ -> []
+ hasTable t = not $ null $ tables t
+ branches cs = [(p:ps,s) |
+ (p,t) <- cs,
+ let ts = tables t,
+ (ps,s) <- if null ts then [([],t)]
+ else concatMap branches ts
+ ]
+ prBranch (ps,s) = unwords (map prt ps ++ [prt s])