summaryrefslogtreecommitdiff
path: root/src/GF
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2007-06-26 16:51:09 +0000
committerbringert <bringert@cs.chalmers.se>2007-06-26 16:51:09 +0000
commit3b93e0ffe22f2a8b71011fb8687d5b6bee6c972d (patch)
treef2ddf2847412d4401578d10bb562b338fbb73605 /src/GF
parent99ac3f8d731e6bacdf24564cc29887faf100f4ac (diff)
Fewer redundant parantheses in JSGF and SRGS ABNF.
Diffstat (limited to 'src/GF')
-rw-r--r--src/GF/Speech/PrJSGF.hs5
-rw-r--r--src/GF/Speech/PrSRGS_ABNF.hs5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/GF/Speech/PrJSGF.hs b/src/GF/Speech/PrJSGF.hs
index efdce4d75..72910235e 100644
--- a/src/GF/Speech/PrJSGF.hs
+++ b/src/GF/Speech/PrJSGF.hs
@@ -63,12 +63,13 @@ prJSGF sisr srg@(SRG{grammarName=name,grammarLanguage=ml,
rule False cat (map prAlt rhs)
-- rule False cat (map prAlt rhs)
-- FIXME: use the probability
- prAlt (SRGAlt mp n rhs) = sep [initTag, parens (prItem sisr n rhs), finalTag]
+ prAlt (SRGAlt mp n rhs) = sep [initTag, p (prItem sisr n rhs), finalTag]
-- prAlt (SRGAlt mp n rhs) = initTag <+> prItem sisr n rhs <+> finalTag
where initTag | isEmpty t = empty
| otherwise = text "<NULL>" <+> t
where t = tag sisr (profileInitSISR n)
finalTag = tag sisr (profileFinalSISR n)
+ p = if isEmpty initTag && isEmpty finalTag then id else parens
topCatRules = [rule True (catFormId tc) (map (it tc) cs) | (tc,cs) <- srgTopCats srg]
where it i c = prCat c <+> tag sisr (topCatSISR c)
@@ -80,7 +81,7 @@ prCat :: SRGCat -> Doc
prCat c = char '<' <> text c <> char '>'
prItem :: Maybe SISRFormat -> CFTerm -> SRGItem -> Doc
-prItem sisr t = f 1
+prItem sisr t = f 0
where
f _ (REUnion []) = text "<VOID>"
f p (REUnion xs)
diff --git a/src/GF/Speech/PrSRGS_ABNF.hs b/src/GF/Speech/PrSRGS_ABNF.hs
index 34f5e7731..244a00816 100644
--- a/src/GF/Speech/PrSRGS_ABNF.hs
+++ b/src/GF/Speech/PrSRGS_ABNF.hs
@@ -70,9 +70,10 @@ prABNF sisr probs srg@(SRG{grammarName=name,grammarLanguage=ml,
comment origCat $$
rule False cat (map prAlt rhs)
-- FIXME: use the probability
- prAlt (SRGAlt mp n rhs) = sep [initTag, parens (prItem sisr n rhs), finalTag]
+ prAlt (SRGAlt mp n rhs) = sep [initTag, p (prItem sisr n rhs), finalTag]
where initTag = tag sisr (profileInitSISR n)
finalTag = tag sisr (profileFinalSISR n)
+ p = if isEmpty initTag && isEmpty finalTag then id else parens
topCatRules = [rule True (catFormId tc) (map (it tc) cs) | (tc,cs) <- srgTopCats srg]
where it i c = prCat c <+> tag sisr (topCatSISR c)
@@ -84,7 +85,7 @@ prCat :: SRGCat -> Doc
prCat c = char '$' <> text c
prItem :: Maybe SISRFormat -> CFTerm -> SRGItem -> Doc
-prItem sisr t = f 1
+prItem sisr t = f 0
where
f _ (REUnion []) = text "$VOID"
f p (REUnion xs)