mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-18 07:32:51 -06:00
Transfer compiler: don't load the same module twice.
This commit is contained in:
@@ -11,6 +11,7 @@ import Transfer.SyntaxToCore
|
|||||||
|
|
||||||
import Transfer.PathUtil
|
import Transfer.PathUtil
|
||||||
|
|
||||||
|
import Data.List
|
||||||
import System.Directory
|
import System.Directory
|
||||||
|
|
||||||
|
|
||||||
@@ -33,16 +34,18 @@ compile m = return (printTree $ declsToCore m)
|
|||||||
loadModule :: [FilePath] -- ^ directories to look for imported modules in
|
loadModule :: [FilePath] -- ^ directories to look for imported modules in
|
||||||
-> FilePath -- ^ source module file
|
-> FilePath -- ^ source module file
|
||||||
-> IO [Decl]
|
-> IO [Decl]
|
||||||
loadModule path f =
|
loadModule = loadModule_ []
|
||||||
|
where
|
||||||
|
loadModule_ ms path f =
|
||||||
do
|
do
|
||||||
s <- readFile f
|
s <- readFile f
|
||||||
Module is ds <- case pModule (myLLexer s) of
|
Module is ds <- case pModule (myLLexer s) of
|
||||||
Bad e -> fail $ "Parse error in " ++ f ++ ": " ++ e
|
Bad e -> fail $ "Parse error in " ++ f ++ ": " ++ e
|
||||||
Ok m -> return m
|
Ok m -> return m
|
||||||
let deps = [ i | Import (Ident i) <- is ]
|
let load = [ i | Import (Ident i) <- is ] \\ ms
|
||||||
let path' = directoryOf f : path
|
let path' = directoryOf f : path
|
||||||
files <- mapM (findFile path' . (++".tr")) deps
|
files <- mapM (findFile path' . (++".tr")) load
|
||||||
dss <- mapM (loadModule path) files
|
dss <- mapM (loadModule_ (load++ms) path) files
|
||||||
return $ concat (dss++[ds])
|
return $ concat (dss++[ds])
|
||||||
|
|
||||||
myLLexer :: String -> [Token]
|
myLLexer :: String -> [Token]
|
||||||
|
|||||||
Reference in New Issue
Block a user