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 opts mb_pgf gr am probs = do
let abs_name = mi2i am
pgf <- case mb_pgf of
Nothing -> let abs_name = mi2i am
in if snd (flag optLinkTargets opts)
then do let fname = maybe id (</>)
(flag optOutputDir opts)
(fromMaybe abs_name (flag optName opts)<.>"ngf")
exists <- doesFileExist fname
if exists
then removeFile fname
else return ()
putStr ("(Boot image "++fname++") ")
newNGF abs_name (Just fname)
else newNGF abs_name Nothing
Just pgf -> return pgf
Just pgf | abstractName pgf == abs_name ->
do return pgf
_ | snd (flag optLinkTargets opts) ->
do let fname = maybe id (</>)
(flag optOutputDir opts)
(fromMaybe abs_name (flag optName opts)<.>"ngf")
exists <- doesFileExist fname
if exists
then removeFile fname
else return ()
putStr ("(Boot image "++fname++") ")
newNGF abs_name (Just fname)
| otherwise ->
do newNGF abs_name Nothing
pgf <- modifyPGF pgf $ do
sequence_ [setAbstractFlag name value | (name,value) <- optionsPGF aflags]