From 6bd9a9faafe5ab5bcf21e55d4fd2efbfd649c248 Mon Sep 17 00:00:00 2001 From: bringert Date: Wed, 27 Jun 2007 14:25:39 +0000 Subject: [PATCH] Use shorter lines and paragraph-filling in SRGS, JSGF and GSL printing. --- src/GF/Speech/PrGSL.hs | 6 +++--- src/GF/Speech/PrJSGF.hs | 8 ++++---- src/GF/Speech/PrSRGS_ABNF.hs | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/GF/Speech/PrGSL.hs b/src/GF/Speech/PrGSL.hs index f1fb9013c..4d2dfe5c6 100644 --- a/src/GF/Speech/PrGSL.hs +++ b/src/GF/Speech/PrGSL.hs @@ -35,7 +35,7 @@ import Data.List (partition) import Text.PrettyPrint.HughesPJ width :: Int -width = 80 +width = 75 gslPrinter :: Options -> StateGrammar -> String gslPrinter opts s = renderStyle st $ prGSL $ makeSimpleSRG opts s @@ -63,13 +63,13 @@ prItem = f f (REUnion xs) = (if null es then empty else text "?") <> union (map f nes) where (es,nes) = partition isEpsilon xs f (REConcat [x]) = f x - f (REConcat xs) = text "(" <> sep (map f xs) <> text ")" + f (REConcat xs) = text "(" <> fsep (map f xs) <> text ")" f (RERepeat x) = text "*" <> f x f (RESymbol s) = prSymbol s union :: [Doc] -> Doc union [x] = x -union xs = text "[" <> sep xs <> text "]" +union xs = text "[" <> fsep xs <> text "]" prSymbol :: Symbol SRGNT Token -> Doc prSymbol (Cat (c,_)) = prCat c diff --git a/src/GF/Speech/PrJSGF.hs b/src/GF/Speech/PrJSGF.hs index ec1305b5d..037a4f4e2 100644 --- a/src/GF/Speech/PrJSGF.hs +++ b/src/GF/Speech/PrJSGF.hs @@ -39,7 +39,7 @@ import Text.PrettyPrint.HughesPJ import Debug.Trace width :: Int -width = 80 +width = 75 jsgfPrinter :: Maybe SISRFormat -> Options @@ -92,7 +92,7 @@ prItem sisr t = f 0 | otherwise = (if p >= 1 then parens else id) (alts (map (f 1) xs)) where (es,nes) = partition isEpsilon xs f _ (REConcat []) = text "" - f p (REConcat xs) = (if p >= 3 then parens else id) (hsep (map (f 2) xs)) + f p (REConcat xs) = (if p >= 3 then parens else id) (fsep (map (f 2) xs)) f p (RERepeat x) = f 3 x <> char '*' f _ (RESymbol s) = prSymbol sisr t s @@ -125,10 +125,10 @@ comment :: String -> Doc comment s = text "//" <+> text s alts :: [Doc] -> Doc -alts = sep . prepunctuate (text "| ") +alts = fsep . prepunctuate (text "| ") rule :: Bool -> SRGCat -> [Doc] -> Doc -rule pub c xs = sep [p <+> prCat c <+> char '=', nest 2 (alts xs) <+> char ';'] +rule pub c xs = p <+> prCat c <+> char '=' <+> nest 2 (alts xs) <+> char ';' where p = if pub then text "public" else empty -- Pretty-printing utilities diff --git a/src/GF/Speech/PrSRGS_ABNF.hs b/src/GF/Speech/PrSRGS_ABNF.hs index cc81e5d72..abb84c5dc 100644 --- a/src/GF/Speech/PrSRGS_ABNF.hs +++ b/src/GF/Speech/PrSRGS_ABNF.hs @@ -40,7 +40,7 @@ import Text.PrettyPrint.HughesPJ import Debug.Trace width :: Int -width = 80 +width = 75 srgsAbnfPrinter :: Maybe SISRFormat -> Bool -- ^ Include probabilities @@ -97,7 +97,7 @@ prItem sisr t = f 0 | otherwise = (if p >= 1 then parens else id) (alts (map (f 1) xs)) where (es,nes) = partition isEpsilon xs f _ (REConcat []) = text "$NULL" - f p (REConcat xs) = (if p >= 3 then parens else id) (hsep (map (f 2) xs)) + f p (REConcat xs) = (if p >= 3 then parens else id) (fsep (map (f 2) xs)) f p (RERepeat x) = f 3 x <> text "<0->" f _ (RESymbol s) = prSymbol sisr t s @@ -124,10 +124,10 @@ comment :: String -> Doc comment s = text "//" <+> text s alts :: [Doc] -> Doc -alts = sep . prepunctuate (text "| ") +alts = fsep . prepunctuate (text "| ") rule :: Bool -> SRGCat -> [Doc] -> Doc -rule pub c xs = sep [p <+> prCat c <+> char '=', nest 2 (alts xs) <+> char ';'] +rule pub c xs = p <+> prCat c <+> char '=' <+> nest 2 (alts xs) <+> char ';' where p = if pub then text "public" else empty meta :: String -> String -> Doc