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