module Data.Cfg.FreeCfg (
FreeCfg(..),
toFreeCfg
) where
import Data.Cfg.Cfg(Cfg(..), Vs)
import qualified Data.Set as S
data FreeCfg t nt = FreeCfg {
nonterminals' :: S.Set nt,
terminals' :: S.Set t,
productionRules' :: nt -> S.Set (Vs t nt),
startSymbol' :: nt
}
instance Cfg FreeCfg t nt where
nonterminals = nonterminals'
terminals = terminals'
productionRules = productionRules'
startSymbol = startSymbol'
toFreeCfg :: Cfg cfg t nt => cfg t nt -> FreeCfg t nt
toFreeCfg cfg = FreeCfg {
nonterminals' = nonterminals cfg,
terminals' = terminals cfg,
productionRules' = productionRules cfg,
startSymbol' = startSymbol cfg
}