summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Speech/JSGF.hs
diff options
context:
space:
mode:
authorbjorn <bjorn@bringert.net>2008-06-16 15:49:17 +0000
committerbjorn <bjorn@bringert.net>2008-06-16 15:49:17 +0000
commit10d58953694a3d66067eaf24deaaab1afd922b80 (patch)
treec86ee3cb9e0c4fb785a4ae7dbc9fcd459a3d50c2 /src-3.0/GF/Speech/JSGF.hs
parentea31c1e63ba137b943f7fd5e0ffe91cd64673875 (diff)
Fix handling of external categories in SRG generation.
Diffstat (limited to 'src-3.0/GF/Speech/JSGF.hs')
-rw-r--r--src-3.0/GF/Speech/JSGF.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src-3.0/GF/Speech/JSGF.hs b/src-3.0/GF/Speech/JSGF.hs
index 53a40ffd4..d49646152 100644
--- a/src-3.0/GF/Speech/JSGF.hs
+++ b/src-3.0/GF/Speech/JSGF.hs
@@ -44,8 +44,10 @@ prJSGF sisr srg
comment "Generated by GF" $$
text ("grammar " ++ srgName srg ++ ";")
lang = maybe empty text (srgLanguage srg)
- mainCat = rule True "MAIN" [prCat (srgStartCat srg)]
- prRule (SRGRule cat rhs) = rule (isExternalCat srg cat) cat (map prAlt rhs)
+ mainCat = rule True "MAIN" [prCat (externalCat (srgStartCat srg))]
+ prRule (SRGRule cat rhs)
+ | isExternalCat srg cat = rule True (externalCat cat) (map prAlt rhs)
+ | otherwise = rule False cat (map prAlt rhs)
prAlt (SRGAlt mp n rhs) = sep [initTag, p (prItem sisr n rhs), finalTag]
where initTag | isEmpty t = empty
| otherwise = text "<NULL>" <+> t
@@ -53,8 +55,8 @@ prJSGF sisr srg
finalTag = tag sisr (profileFinalSISR n)
p = if isEmpty initTag && isEmpty finalTag then id else parens
-catFormId :: String -> String
-catFormId = (++ "_cat")
+externalCat :: Cat -> Cat
+externalCat c = c ++ "_cat"
prCat :: Cat -> Doc
prCat c = char '<' <> text c <> char '>'