forked from GitHub/gf-core
When printing CFGM, only include the top-level modules
This commit is contained in:
@@ -7,16 +7,21 @@ import GFC
|
|||||||
import Modules
|
import Modules
|
||||||
import qualified ConvertGrammar as Cnv
|
import qualified ConvertGrammar as Cnv
|
||||||
import qualified PrintParser as Prt
|
import qualified PrintParser as Prt
|
||||||
|
import ErrM
|
||||||
|
|
||||||
import List (intersperse)
|
import List (intersperse)
|
||||||
import Maybe (listToMaybe, fromMaybe)
|
import Maybe (listToMaybe, maybe)
|
||||||
|
|
||||||
-- FIXME: fix warning about bad -printer= value
|
-- FIXME: fix warning about bad -printer= value
|
||||||
|
|
||||||
prCanonAsCFGM :: CanonGrammar -> String
|
prCanonAsCFGM :: CanonGrammar -> String
|
||||||
prCanonAsCFGM gr = unlines $ map (uncurry (prLangAsCFGM gr)) xs
|
prCanonAsCFGM gr = unlines $ map (uncurry (prLangAsCFGM gr)) xs
|
||||||
where
|
where
|
||||||
xs = [(i,getFlag fs "startcat") | (i,ModMod (Module{mtype=MTConcrete _,flags=fs})) <- modules gr]
|
cncs = maybe [] (allConcretes gr) (greatestAbstract gr)
|
||||||
|
cncms = map (\i -> (i,fromOk (lookupModule gr i))) cncs
|
||||||
|
fromOk (Ok x) = x
|
||||||
|
fromOk (Bad y) = error y
|
||||||
|
xs = [(i,getFlag fs "startcat") | (i,ModMod (Module{flags=fs})) <- cncms]
|
||||||
|
|
||||||
-- FIXME: need to look in abstract module too
|
-- FIXME: need to look in abstract module too
|
||||||
getFlag :: [Flag] -> String -> Maybe String
|
getFlag :: [Flag] -> String -> Maybe String
|
||||||
|
|||||||
Reference in New Issue
Block a user