forked from GitHub/gf-core
Get GF.Speech.PrRegExp to compile.
This commit is contained in:
@@ -1,33 +1,27 @@
|
|||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
-- |
|
-- |
|
||||||
-- Module : PrSLF
|
-- Module : GF.Speech.PrRegExp
|
||||||
-- Maintainer : BB
|
|
||||||
-- Stability : (stable)
|
|
||||||
-- Portability : (portable)
|
|
||||||
--
|
--
|
||||||
-- This module prints a grammar as a regular expression.
|
-- This module prints a grammar as a regular expression.
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Speech.PrRegExp (regexpPrinter,multiRegexpPrinter) where
|
module GF.Speech.PrRegExp (regexpPrinter,multiRegexpPrinter) where
|
||||||
|
|
||||||
import GF.Conversion.Types
|
import GF.Speech.CFG
|
||||||
import GF.Formalism.Utilities
|
import GF.Speech.CFGToFA
|
||||||
import GF.Infra.Ident
|
import GF.Speech.PGFToCFG
|
||||||
import GF.Infra.Option (Options)
|
|
||||||
import GF.Speech.CFGToFiniteState
|
|
||||||
import GF.Speech.RegExp
|
import GF.Speech.RegExp
|
||||||
import GF.Compile.ShellState (StateGrammar)
|
import PGF
|
||||||
|
|
||||||
|
regexpPrinter :: PGF -> CId -> String
|
||||||
|
regexpPrinter pgf cnc = (++"\n") $ prRE $ dfa2re $ cfgToFA $ pgfToCFG pgf cnc
|
||||||
|
|
||||||
regexpPrinter :: Options -> StateGrammar -> String
|
multiRegexpPrinter :: PGF -> CId -> String
|
||||||
regexpPrinter opts s = (++"\n") $ prRE $ dfa2re $ cfgToFA opts s
|
multiRegexpPrinter pgf cnc = prREs $ mfa2res $ cfgToMFA $ pgfToCFG pgf cnc
|
||||||
|
|
||||||
multiRegexpPrinter :: Options -> StateGrammar -> String
|
prREs :: [(String,RE CFSymbol)] -> String
|
||||||
multiRegexpPrinter opts s = prREs $ mfa2res $ cfgToMFA opts s
|
|
||||||
|
|
||||||
prREs :: [(String,RE (MFALabel String))] -> String
|
|
||||||
prREs res = unlines [l ++ " = " ++ prRE (mapRE showLabel re) | (l,re) <- res]
|
prREs res = unlines [l ++ " = " ++ prRE (mapRE showLabel re) | (l,re) <- res]
|
||||||
where showLabel = symbol (\l -> "<" ++ l ++ ">") id
|
where showLabel = symbol (\l -> "<" ++ l ++ ">") id
|
||||||
|
|
||||||
mfa2res :: MFA String -> [(String,RE (MFALabel String))]
|
mfa2res :: MFA -> [(String,RE CFSymbol)]
|
||||||
mfa2res (MFA _ dfas) = [(l, minimizeRE (dfa2re dfa)) | (l,dfa) <- dfas]
|
mfa2res (MFA _ dfas) = [(l, minimizeRE (dfa2re dfa)) | (l,dfa) <- dfas]
|
||||||
|
|||||||
Reference in New Issue
Block a user