diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-03-02 12:56:36 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-03-02 12:56:36 +0100 |
commit | 2863e31d34d0131d2dd3cc1f4df6c399c23187c9 (patch) | |
tree | 7067d295dca3c7b77d3ed398d0bb0b7cdca98b28 /src/LambdaCube/Compiler.hs | |
parent | 66255f38134ea5af170d37affc5582744d50bc7d (diff) |
first version of parse only
Diffstat (limited to 'src/LambdaCube/Compiler.hs')
-rw-r--r-- | src/LambdaCube/Compiler.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/LambdaCube/Compiler.hs b/src/LambdaCube/Compiler.hs index 4f0aba11..56d3db8a 100644 --- a/src/LambdaCube/Compiler.hs +++ b/src/LambdaCube/Compiler.hs | |||
@@ -16,7 +16,7 @@ module LambdaCube.Compiler | |||
16 | , MM, runMM | 16 | , MM, runMM |
17 | , catchErr | 17 | , catchErr |
18 | , ioFetch, decideFilePath | 18 | , ioFetch, decideFilePath |
19 | , getDef, compileMain, preCompile | 19 | , getDef, compileMain, parseModule, preCompile |
20 | , removeFromCache | 20 | , removeFromCache |
21 | 21 | ||
22 | , compilePipeline | 22 | , compilePipeline |
@@ -239,6 +239,12 @@ compileMain :: [FilePath] -> IR.Backend -> MName -> IO (Either String IR.Pipelin | |||
239 | compileMain path backend fname | 239 | compileMain path backend fname |
240 | = fmap snd $ runMM (ioFetch path) $ compilePipeline' (const ()) backend fname | 240 | = fmap snd $ runMM (ioFetch path) $ compilePipeline' (const ()) backend fname |
241 | 241 | ||
242 | parseModule :: [FilePath] -> MName -> IO (Either String String) | ||
243 | parseModule path fname = runMM (ioFetch path) $ loadModule snd Nothing (Left fname) <&> \case | ||
244 | Left err -> Left err | ||
245 | Right (fname, (src, Left err)) -> Left err | ||
246 | Right (fname, (src, Right (pm, infos, _))) -> Right $ pPrintStmts infos | ||
247 | |||
242 | -- used by the compiler-service of the online editor | 248 | -- used by the compiler-service of the online editor |
243 | preCompile :: (MonadMask m, MonadIO m) => [FilePath] -> [FilePath] -> Backend -> FilePath -> IO (String -> m (Either String IR.Pipeline, (Infos, String))) | 249 | preCompile :: (MonadMask m, MonadIO m) => [FilePath] -> [FilePath] -> Backend -> FilePath -> IO (String -> m (Either String IR.Pipeline, (Infos, String))) |
244 | preCompile paths paths' backend mod = do | 250 | preCompile paths paths' backend mod = do |
@@ -256,4 +262,7 @@ preCompile paths paths' backend mod = do | |||
256 | Left "Main" -> return $ Right ("./Main.lc", "Main", return src) | 262 | Left "Main" -> return $ Right ("./Main.lc", "Main", return src) |
257 | n -> ioFetch paths' imp n | 263 | n -> ioFetch paths' imp n |
258 | where | 264 | where |
259 | ex = second (unlines . map ((++"\n") . removeEscs . ppShow)) | 265 | ex = second pPrintStmts |
266 | |||
267 | pPrintStmts = unlines . map ((++"\n") . removeEscs . ppShow) | ||
268 | |||