summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbringert <unknown>2005-02-07 08:39:00 +0000
committerbringert <unknown>2005-02-07 08:39:00 +0000
commitcec6ea60bd8f5330a8084dd21f0998ac934bab1e (patch)
tree3984a50b7db636f6b45f88189e29986496e84160
parenta19fce9abb86a6a60c133f1ed42d02012b319193 (diff)
Convert tokens to lower case when printing GSL.
-rw-r--r--src/GF/Speech/PrGSL.hs32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/GF/Speech/PrGSL.hs b/src/GF/Speech/PrGSL.hs
index 5b2439341..21e4b21e5 100644
--- a/src/GF/Speech/PrGSL.hs
+++ b/src/GF/Speech/PrGSL.hs
@@ -1,7 +1,7 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : PrGSL
+-- Maintainer : Bjorn Bringert (bringert@cs.chalmers.se)
-- Stability : (stable)
-- Portability : (portable)
--
@@ -9,26 +9,10 @@
-- > CVS $Author $
-- > CVS $Revision $
--
--- (Description of the module)
+-- This module prints a CFG as a Nuance GSL 2.0 grammar.
+--
-----------------------------------------------------------------------------
-{-
- **************************************************************
- GF Module
-
- Description : This module prints a CFG as a Nuance GSL 2.0
- grammar.
-
- Author : Björn Bringert (bringert@cs.chalmers.se)
-
- License : GPL (GNU General Public License)
-
- Created : September 13, 2004
-
- Modified : October 1, 2004
- **************************************************************
--}
-
-- FIXME: remove / warn / fail if there are int / string literal
-- categories in the grammar
@@ -42,7 +26,7 @@ import GrammarTypes
import PrintParser
import Option
-import Data.Char (toUpper)
+import Data.Char (toUpper,toLower)
gslPrinter :: Ident -- ^ Grammar name
-> Options -> CFGrammar -> String
@@ -64,7 +48,7 @@ prGSL (SRG{grammarName=name,startCat=start,origStartCat=origStart,rules=rs})
prAlt rhs = wrap "(" (unwordsS (map prSymbol rhs')) ")"
where rhs' = rmPunct rhs
prSymbol (Cat c) = prCat c
- prSymbol (Tok t) = wrap "\"" (prtS t) "\""
+ prSymbol (Tok t) = wrap "\"" (showString (showToken t)) "\""
-- GSL requires an upper case letter in category names
prCat c = showString (firstToUpper c)
@@ -77,6 +61,10 @@ rmPunct [] = []
rmPunct (Tok t:ss) | all isPunct (prt t) = rmPunct ss
rmPunct (s:ss) = s : rmPunct ss
+-- Nuance does not like upper case characters in tokens
+showToken :: Token -> String
+showToken t = map toLower (prt t)
+
isPunct :: Char -> Bool
isPunct c = c `elem` "-_.;.,?!()[]{}"