1
0
forked from GitHub/gf-core

JSGF pretty printing tweaks.

This commit is contained in:
bringert
2006-12-20 21:43:41 +00:00
parent 01bb00deea
commit 947d1cf564

View File

@@ -52,13 +52,13 @@ prJSGF srg@(SRG{grammarName=name,startCat=start,origStartCat=origStart,rules=rs}
header = text "#JSGF V1.0 UTF-8;" $$
comment ("JSGF speech recognition grammar for " ++ name) $$
comment "Generated by GF" $$
text ("grammar " ++ name ++ ";")
text ("grammar " ++ name ++ ";") $$ emptyLine
mainCat = comment ("Start category: " ++ origStart) $$
rule True "MAIN" [prCat start]
rule True "MAIN" [prCat start] $$ emptyLine
prRule (SRGRule cat origCat rhs) =
comment origCat $$
-- rule False cat (map prAlt (ebnfSRGAlts rhs))
rule False cat (map prAlt rhs) $$ text ""
rule False cat (map prAlt rhs) $$ emptyLine
-- FIXME: use the probability
-- prAlt (EBnfSRGAlt mp n rhs) = tag sisr (profileInitSISR n) . showChar ' '. prItem sisr rhs
prAlt (SRGAlt mp n rhs) = initTag <+> prItem sisr n rhs <+> finalTag
@@ -120,6 +120,9 @@ isPunct c = c `elem` "-_.;.,?!"
comment :: String -> Doc
comment s = text "//" <+> text s
emptyLine :: Doc
emptyLine = text ""
prepunctuate :: Doc -> [Doc] -> [Doc]
prepunctuate _ [] = []
prepunctuate p (x:xs) = x : map (p <>) xs