mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-11 12:12:51 -06:00
GF shell: create a PGF also when the -retain flag is used
The commands available in the shell after import -retain are now a superset of the commands available after import without -retain. The PGF is created lazily, so there should be no performance penalty if the PGF isn't needed. If there are errors, they won't be reported until a command that uses the PGF is entered.
This commit is contained in:
@@ -355,15 +355,21 @@ importInEnv :: GFEnv -> Options -> [FilePath] -> SIO GFEnv
|
||||
importInEnv gfenv opts files
|
||||
| flag optRetainResource opts =
|
||||
do src <- importSource (grammar gfenv) opts files
|
||||
return $ gfenv {grammar = src}
|
||||
pgf <- lazySIO importPGF -- duplicates some work, better to link src
|
||||
return $ gfenv {grammar = src, commandenv = mkCommandEnv pgf}
|
||||
| otherwise =
|
||||
do let opts' = addOptions (setOptimization OptCSE False) opts
|
||||
pgf0 = multigrammar (commandenv gfenv)
|
||||
pgf1 <- importGrammar pgf0 opts' files
|
||||
if (verbAtLeast opts Normal)
|
||||
then putStrLnFlush $ unwords $ "\nLanguages:" : map showCId (languages pgf1)
|
||||
else done
|
||||
do pgf1 <- importPGF
|
||||
return $ gfenv { commandenv = mkCommandEnv pgf1 }
|
||||
where
|
||||
importPGF =
|
||||
do let opts' = addOptions (setOptimization OptCSE False) opts
|
||||
pgf0 = multigrammar (commandenv gfenv)
|
||||
pgf1 <- importGrammar pgf0 opts' files
|
||||
if (verbAtLeast opts Normal)
|
||||
then putStrLnFlush $
|
||||
unwords $ "\nLanguages:" : map showCId (languages pgf1)
|
||||
else done
|
||||
return pgf1
|
||||
|
||||
tryGetLine = do
|
||||
res <- try getLine
|
||||
|
||||
Reference in New Issue
Block a user