From 5c2ce87cde2dee9f6af65ed5e63ee7d9f072f399 Mon Sep 17 00:00:00 2001 From: krasimir Date: Sat, 7 Feb 2009 23:31:22 +0000 Subject: PMCFG pretty printer --- src/GF/Compile/Export.hs | 1 + src/GF/Compile/PGFPretty.hs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/GF/Compile') diff --git a/src/GF/Compile/Export.hs b/src/GF/Compile/Export.hs index 921e48846..051889b59 100644 --- a/src/GF/Compile/Export.hs +++ b/src/GF/Compile/Export.hs @@ -30,6 +30,7 @@ exportPGF :: Options exportPGF opts fmt pgf = case fmt of FmtPGFPretty -> multi "txt" prPGFPretty + FmtPMCFGPretty -> single "pmcfg" prPMCFGPretty FmtJavaScript -> multi "js" pgf2js FmtHaskell -> multi "hs" (grammar2haskell opts name) FmtProlog -> multi "pl" grammar2prolog diff --git a/src/GF/Compile/PGFPretty.hs b/src/GF/Compile/PGFPretty.hs index 7069414fb..b6d8f514b 100644 --- a/src/GF/Compile/PGFPretty.hs +++ b/src/GF/Compile/PGFPretty.hs @@ -1,10 +1,11 @@ -- | Print a part of a PGF grammar on the human-readable format used in -- the paper "PGF: A Portable Run-Time Format for Type-Theoretical Grammars". -module GF.Compile.PGFPretty (prPGFPretty) where +module GF.Compile.PGFPretty (prPGFPretty, prPMCFGPretty) where import PGF.CId import PGF.Data import PGF.Macros +import PGF.PMCFG import GF.Data.Operations @@ -16,6 +17,13 @@ import Text.PrettyPrint.HughesPJ prPGFPretty :: PGF -> String prPGFPretty pgf = render $ prAbs (abstract pgf) $$ prAll (prCnc (abstract pgf)) (concretes pgf) +prPMCFGPretty :: PGF -> CId -> String +prPMCFGPretty pgf lang = render $ + case lookParser pgf lang of + Nothing -> empty + Just pinfo -> text "language" <+> text (prCId lang) $$ ppPMCFG pinfo + + prAbs :: Abstr -> Doc prAbs a = prAll prCat (cats a) $$ prAll prFun (funs a) -- cgit v1.2.3