From 947d1cf5647024df882d7b327b23cbe0770a124c Mon Sep 17 00:00:00 2001 From: bringert Date: Wed, 20 Dec 2006 21:43:41 +0000 Subject: [PATCH] JSGF pretty printing tweaks. --- src/GF/Speech/PrJSGF.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/GF/Speech/PrJSGF.hs b/src/GF/Speech/PrJSGF.hs index 6d123df5f..ffb5d6630 100644 --- a/src/GF/Speech/PrJSGF.hs +++ b/src/GF/Speech/PrJSGF.hs @@ -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