detect when we load a grammar with a different abstract and don't try to merge

This commit is contained in:
krangelov
2021-12-24 16:01:42 +01:00
parent 39853b3c04
commit 21d38a7b4a

View File

@@ -31,20 +31,22 @@ import System.Directory
grammar2PGF :: Options -> Maybe PGF -> SourceGrammar -> ModuleName -> Map.Map PGF2.Fun Double -> IO PGF grammar2PGF :: Options -> Maybe PGF -> SourceGrammar -> ModuleName -> Map.Map PGF2.Fun Double -> IO PGF
grammar2PGF opts mb_pgf gr am probs = do grammar2PGF opts mb_pgf gr am probs = do
let abs_name = mi2i am
pgf <- case mb_pgf of pgf <- case mb_pgf of
Nothing -> let abs_name = mi2i am Just pgf | abstractName pgf == abs_name ->
in if snd (flag optLinkTargets opts) do return pgf
then do let fname = maybe id (</>) _ | snd (flag optLinkTargets opts) ->
(flag optOutputDir opts) do let fname = maybe id (</>)
(fromMaybe abs_name (flag optName opts)<.>"ngf") (flag optOutputDir opts)
exists <- doesFileExist fname (fromMaybe abs_name (flag optName opts)<.>"ngf")
if exists exists <- doesFileExist fname
then removeFile fname if exists
else return () then removeFile fname
putStr ("(Boot image "++fname++") ") else return ()
newNGF abs_name (Just fname) putStr ("(Boot image "++fname++") ")
else newNGF abs_name Nothing newNGF abs_name (Just fname)
Just pgf -> return pgf | otherwise ->
do newNGF abs_name Nothing
pgf <- modifyPGF pgf $ do pgf <- modifyPGF pgf $ do
sequence_ [setAbstractFlag name value | (name,value) <- optionsPGF aflags] sequence_ [setAbstractFlag name value | (name,value) <- optionsPGF aflags]