1
0
forked from GitHub/gf-core

Added "bnf" output format for debugging.

This commit is contained in:
bjorn
2008-06-03 19:32:42 +00:00
parent c974ce4345
commit 5dea982489
4 changed files with 7 additions and 1 deletions

View File

@@ -7,6 +7,8 @@ import PGF.Raw.Convert (fromPGF)
import GF.Compile.GFCCtoHaskell
import GF.Compile.GFCCtoJS
import GF.Infra.Option
import GF.Speech.CFG
import GF.Speech.PGFToCFG
import GF.Speech.SRGS
import GF.Text.UTF8
@@ -22,6 +24,7 @@ prPGF fmt gr name = case fmt of
FmtJavaScript -> pgf2js gr
FmtHaskell -> grammar2haskell gr name
FmtHaskell_GADT -> grammar2haskellGADT gr name
FmtBNF -> prCFG $ pgfToCFG gr (outputConcr gr)
FmtSRGS_XML -> srgsXmlPrinter Nothing gr (outputConcr gr)
-- | Get the name of the concrete syntax to generate output from.

View File

@@ -82,6 +82,7 @@ data OutputFormat = FmtPGF
| FmtJavaScript
| FmtHaskell
| FmtHaskell_GADT
| FmtBNF
| FmtSRGS_XML
| FmtSRGS_ABNF
| FmtJSGF
@@ -418,6 +419,7 @@ outputFormats =
("js", FmtJavaScript),
("haskell", FmtHaskell),
("haskell_gadt", FmtHaskell_GADT),
("bnf", FmtBNF),
("srgs", FmtSRGS_XML),
("srgs_xml", FmtSRGS_XML),
("srgs_abnf", FmtSRGS_ABNF),

View File

@@ -270,7 +270,7 @@ countRules = length . allRules
prCFG :: CFG -> String
prCFG = unlines . map prRule . allRules
where
prRule r = lhsCat r ++ " --> " ++ unwords (map prSym (ruleRhs r))
prRule r = lhsCat r ++ " ::= " ++ unwords (map prSym (ruleRhs r))
prSym = symbol id (\t -> "\""++ t ++"\"")
--

View File

@@ -45,6 +45,7 @@ fmtExtension FmtPGF = "pgf"
fmtExtension FmtJavaScript = "js"
fmtExtension FmtHaskell = "hs"
fmtExtension FmtHaskell_GADT = "hs"
fmtExtension FmtBNF = "bnf"
fmtExtension FmtSRGS_XML = "grxml"
writeOutputFile :: FilePath -> String -> IOE ()