From 5264780e67d74eb16a4cb499072b89b57ca4a37c Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 23 Feb 2007 16:28:06 +0000 Subject: cc -table --- src/GF/API.hs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/GF/API.hs') 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]) -- cgit v1.2.3