summaryrefslogtreecommitdiff
path: root/src/GF/Speech/SRG.hs
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2006-12-12 14:01:42 +0000
committerbringert <bringert@cs.chalmers.se>2006-12-12 14:01:42 +0000
commit0b7fef1a33db15593493b80f8a65aa96c6530f5c (patch)
treec562a863c5de51138f8a668a6c59ee5dec1ad99d /src/GF/Speech/SRG.hs
parent1c8e32e6415e28531604c626ce18e2d6db144393 (diff)
Use ebnf srg generation in PrSRGS.
Diffstat (limited to 'src/GF/Speech/SRG.hs')
-rw-r--r--src/GF/Speech/SRG.hs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/GF/Speech/SRG.hs b/src/GF/Speech/SRG.hs
index b55475f1f..9082fa1f4 100644
--- a/src/GF/Speech/SRG.hs
+++ b/src/GF/Speech/SRG.hs
@@ -22,7 +22,10 @@ module GF.Speech.SRG (SRG(..), SRGRule(..), SRGAlt(..),
SRGCat, SRGNT,
makeSimpleSRG, makeSRG
, lookupFM_, prtS
- , topDownFilter) where
+ , topDownFilter
+ , EBnfSRGAlt(..), EBnfSRGItem(..)
+ , ebnfSRGAlts
+ ) where
import GF.Data.Operations
import GF.Data.Utilities
@@ -164,6 +167,26 @@ allSRGCats :: SRG -> [String]
allSRGCats SRG { rules = rs } = [c | SRGRule c _ _ <- rs]
--
+-- * Size-optimized EBNF SRGs
+--
+
+data EBnfSRGAlt = EBnfSRGAlt (Maybe Double) Name EBnfSRGItem
+ deriving (Eq,Show)
+
+data EBnfSRGItem =
+ EBnfOneOf [EBnfSRGItem]
+ | EBnfSeq [EBnfSRGItem]
+ | EBnfSymbol (Symbol SRGNT Token)
+ deriving (Eq,Show)
+
+ebnfSRGAlts :: [SRGAlt] -> [EBnfSRGAlt]
+ebnfSRGAlts alts = [EBnfSRGAlt p n (ebnfSRGItem sss)
+ | ((p,n),sss) <- buildMultiMap [((p,n),ss) | SRGAlt p n ss <- alts]]
+
+ebnfSRGItem :: [[Symbol SRGNT Token]] -> EBnfSRGItem
+ebnfSRGItem sss = EBnfOneOf (map (EBnfSeq . map EBnfSymbol) sss)
+
+--
-- * Utilities for building and printing SRGs
--