summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Grammar/PrGrammar.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-05-26 14:50:17 +0000
committeraarne <aarne@cs.chalmers.se>2008-05-26 14:50:17 +0000
commitd4e0caa05339f4a141f85f9a61d634f89037146b (patch)
tree2de6f7bf5d49439511e971e393a6f42b0d2bc88e /src-3.0/GF/Grammar/PrGrammar.hs
parent7d0da72db1bf4da1cd5404c56e55e55d0a4cb98c (diff)
printing options for source GF terms defined in API and used in cc command
Diffstat (limited to 'src-3.0/GF/Grammar/PrGrammar.hs')
-rw-r--r--src-3.0/GF/Grammar/PrGrammar.hs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src-3.0/GF/Grammar/PrGrammar.hs b/src-3.0/GF/Grammar/PrGrammar.hs
index 734aa13ca..027abe9f3 100644
--- a/src-3.0/GF/Grammar/PrGrammar.hs
+++ b/src-3.0/GF/Grammar/PrGrammar.hs
@@ -30,7 +30,8 @@ module GF.Grammar.PrGrammar (Print(..),
prConstrs, prConstraints,
prMetaSubst, prEnv, prMSubst,
prExp, prOperSignature,
- lookupIdent, lookupIdentInfo
+ lookupIdent, lookupIdentInfo,
+ prTermTabular
) where
import GF.Data.Operations
@@ -89,6 +90,12 @@ instance Print Ident where
instance Print Patt where
prt = pprintTree . trp
+ prt_ = prt . unqual where
+ unqual p = case p of
+ PP _ c [] -> PV c --- to remove curlies
+ PP _ c ps -> PC c (map unqual ps)
+ PC c ps -> PC c (map unqual ps)
+ _ -> p ---- records
instance Print Label where
prt = pprintTree . trLabel
@@ -247,3 +254,20 @@ lookupIdent c t = case lookupTree prt c t of
lookupIdentInfo :: Module Ident a -> Ident -> Err a
lookupIdentInfo mo i = lookupIdent i (jments mo)
+
+
+--- printing cc command output AR 26/5/2008
+
+prTermTabular :: Term -> [(String,String)]
+prTermTabular = pr where
+ pr t = case t of
+ R rs ->
+ [(prt_ lab +++ "." +++ path, str) | (lab,(_,val)) <- rs, (path,str) <- pr val]
+ T _ cs ->
+ [(prt_ lab +++"=>" +++ path, str) | (lab, val) <- cs, (path,str) <- pr val]
+ _ -> [([],ps t)]
+ ps t = case t of
+ K s -> s
+ C s u -> ps s +++ ps u
+ FV ts -> unwords (intersperse "/" (map ps ts))
+ _ -> prt_ t