diff options
| author | bringert <bringert@cs.chalmers.se> | 2006-12-12 14:01:42 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2006-12-12 14:01:42 +0000 |
| commit | 0b7fef1a33db15593493b80f8a65aa96c6530f5c (patch) | |
| tree | c562a863c5de51138f8a668a6c59ee5dec1ad99d /src/GF/Speech/SRG.hs | |
| parent | 1c8e32e6415e28531604c626ce18e2d6db144393 (diff) | |
Use ebnf srg generation in PrSRGS.
Diffstat (limited to 'src/GF/Speech/SRG.hs')
| -rw-r--r-- | src/GF/Speech/SRG.hs | 25 |
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 -- |
