mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 03:09:33 -06:00
PMCFG pretty printer
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user