diff options
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 -- |
