some more printing

This commit is contained in:
aarne
2004-04-19 15:33:45 +00:00
parent fa07ada6ab
commit 2e0c510285
7 changed files with 21 additions and 11 deletions

View File

@@ -22,7 +22,7 @@ import CF
import CFIdent import CFIdent
---import UseGrammar ---import UseGrammar
import PPrCF import PPrCF
import List (intersperse) import List (intersperse,nub)
header :: String header :: String
header = unlines ["#ABNF 1.0 ISO-8859-1;\n", header = unlines ["#ABNF 1.0 ISO-8859-1;\n",
@@ -38,7 +38,7 @@ prSRGC :: [CFCat] -> CF -> String
prSRGC [] _ = [] prSRGC [] _ = []
prSRGC (c:cs) cf = "$" ++ prCFCat c ++ " = " ++ items ++ ";\n"++ prSRGC cs cf prSRGC (c:cs) cf = "$" ++ prCFCat c ++ " = " ++ items ++ ";\n"++ prSRGC cs cf
where items = concat $ intersperse " | " $ where items = concat $ intersperse " | " $
map f $ map valItemsCF (rulesForCFCat cf c) map f $ nub $ map valItemsCF (rulesForCFCat cf c)
f [] = "$NULL" f [] = "$NULL"
f xs = unwords $ map prSRGItem xs f xs = unwords $ map prSRGItem xs

View File

@@ -14,7 +14,12 @@ import Operations
import Monad import Monad
-- a decompiler. AR 12/6/2003 -- a decompiler. AR 12/6/2003 -- 19/4/2004
canon2sourceGrammar :: CanonGrammar -> Err G.SourceGrammar
canon2sourceGrammar gr = do
ms' <- mapM canon2sourceModule $ M.modules gr
return $ M.MGrammar ms'
canon2sourceModule :: CanonModule -> Err G.SourceModule canon2sourceModule :: CanonModule -> Err G.SourceModule
canon2sourceModule (i,mi) = do canon2sourceModule (i,mi) = do

View File

@@ -210,9 +210,7 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = case comm of
| oElem showAll opts -> returnArg (AString txtHelpFile) sa | oElem showAll opts -> returnArg (AString txtHelpFile) sa
| otherwise -> returnArg (AString txtHelpFileSummary) sa | otherwise -> returnArg (AString txtHelpFileSummary) sa
CPrintGrammar CPrintGrammar -> returnArg (AString (optPrintGrammar opts gro)) sa
| oElem showOld opts -> returnArg (AString $ printGrammarOld (canModules st)) sa
| otherwise -> returnArg (AString (optPrintGrammar opts gro)) sa
CPrintGlobalOptions -> justOutput (putStrLn $ prShellStateInfo st) sa CPrintGlobalOptions -> justOutput (putStrLn $ prShellStateInfo st) sa
CPrintInformation c -> justOutput (useIOE () $ showInformation opts st c) sa CPrintInformation c -> justOutput (useIOE () $ showInformation opts st c) sa
CPrintLanguages -> justOutput CPrintLanguages -> justOutput

View File

@@ -19,10 +19,11 @@ import Option
import CF import CF
import CFIdent import CFIdent
---- import CFtoGrammar import CanonToGrammar
import PPrCF import PPrCF
import PrLBNF import PrLBNF
import PrGrammar import PrGrammar
import PrOld
import MkGFC import MkGFC
import CFtoSRG import CFtoSRG
@@ -145,7 +146,9 @@ customGrammarPrinter =
customData "Grammar printers, selected by option -printer=x" $ customData "Grammar printers, selected by option -printer=x" $
[ [
(strCI "gfc", prCanon . stateGrammarST) -- DEFAULT (strCI "gfc", prCanon . stateGrammarST) -- DEFAULT
,(strCI "gf", err id prGrammar . canon2sourceGrammar . stateGrammarST)
,(strCI "cf", prCF . stateCF) ,(strCI "cf", prCF . stateCF)
,(strCI "old", printGrammarOld . stateGrammarST)
,(strCI "srg", prSRG . stateCF) ,(strCI "srg", prSRG . stateCF)
,(strCI "lbnf", prLBNF . stateCF) ,(strCI "lbnf", prLBNF . stateCF)
,(strCI "morpho", prMorpho . stateMorpho) ,(strCI "morpho", prMorpho . stateMorpho)

View File

@@ -347,8 +347,10 @@ q, quit: q
-parser=earley Earley algorithm -parser=earley Earley algorithm
-parser=chart bottom-up chart parser -parser=chart bottom-up chart parser
-printer: format in which the grammar is printed. The default is gf. -printer: format in which the grammar is printed. The default is gfc.
-printer=gfc GFC grammar
-printer=gf GF grammar -printer=gf GF grammar
-printer=old old GF grammar
-printer=cf context-free grammar -printer=cf context-free grammar
*-printer=happy source file for Happy parser generator *-printer=happy source file for Happy parser generator
-printer=srg speech recognition grammar -printer=srg speech recognition grammar

View File

@@ -360,11 +360,13 @@ txtHelpFile =
"\n -parser=earley Earley algorithm" ++ "\n -parser=earley Earley algorithm" ++
"\n -parser=chart bottom-up chart parser" ++ "\n -parser=chart bottom-up chart parser" ++
"\n" ++ "\n" ++
"\n-printer: format in which the grammar is printed. The default is gf." ++ "\n-printer: format in which the grammar is printed. The default is gfc." ++
"\n -printer=gfc GFC grammar" ++
"\n -printer=gf GF grammar" ++ "\n -printer=gf GF grammar" ++
"\n -printer=old old GF grammar" ++
"\n -printer=cf context-free grammar" ++ "\n -printer=cf context-free grammar" ++
"\n *-printer=happy source file for Happy parser generator" ++ "\n *-printer=happy source file for Happy parser generator" ++
"\n *-printer=srg speech recognition grammar" ++ "\n -printer=srg speech recognition grammar" ++
"\n *-printer=haskell abstract syntax in Haskell, with transl to/from GF" ++ "\n *-printer=haskell abstract syntax in Haskell, with transl to/from GF" ++
"\n -printer=morpho full-form lexicon, long format" ++ "\n -printer=morpho full-form lexicon, long format" ++
"\n *-printer=latex LaTeX file (for the tg command)" ++ "\n *-printer=latex LaTeX file (for the tg command)" ++

View File

@@ -1 +1 @@
module Today where today = "Fri Apr 16 18:06:59 CEST 2004" module Today where today = "Mon Apr 19 17:59:02 CEST 2004"