Commit 23dedde4 authored by Björn Peemöller 's avatar Björn Peemöller

Removed dependency to Curry.Base.Messages

parent e4928e3e
......@@ -9,15 +9,16 @@ module Base.Messages
, MonadIO (..), CYIO, CYT, left, right, runEitherCYIO
) where
import Control.Monad (unless, when)
import Control.Monad.IO.Class
import Control.Monad.Trans.Either
import Data.List (sort)
import System.IO (hFlush, hPutStrLn, stderr, stdout)
import System.Exit (exitFailure)
import Curry.Base.Message hiding (warn)
import CompilerOpts (Options (..), WarnOpts (..), Verbosity (..))
import Control.Monad (unless, when)
import Control.Monad.IO.Class (MonadIO(..))
import Control.Monad.Trans.Either (EitherT, left, right, runEitherT)
import Data.List (sort)
import System.IO (hFlush, hPutStrLn, stderr, stdout)
import System.Exit (exitFailure)
import Curry.Base.Message ( Message, message, posMessage, ppMessage
, ppMessages, ppWarning, ppError)
import CompilerOpts (Options (..), WarnOpts (..), Verbosity (..))
type CYT m a = EitherT [Message] m a
......
......@@ -24,7 +24,6 @@ import Data.List (isSuffixOf, nub)
import qualified Data.Map as Map (Map, empty, insert, lookup, toList)
import Curry.Base.Ident
import Curry.Base.Message (runMsg)
import Curry.Base.Pretty
import Curry.Files.Filenames
import Curry.Files.PathUtils
......@@ -133,9 +132,9 @@ readHeader fn = do
case mbFile of
Nothing -> left [errMissingFile fn]
Just src -> do
case runMsg $ parseHeader fn src of
Left err -> left [err]
Right (hdr, _) -> return $ patchModuleId fn hdr
case parseHeader fn src of
Left err -> left [err]
Right hdr -> return $ patchModuleId fn hdr
-- If we want to compile the program instead of generating Makefile
-- dependencies, the environment has to be sorted topologically. Note
......
......@@ -20,7 +20,6 @@ import Data.Maybe (fromMaybe, isJust)
import System.FilePath ((</>), dropFileName, takeBaseName)
import Curry.Base.Ident (QualIdent (..), unqualify)
import Curry.Base.Message
import Curry.Base.Pretty (text)
import Curry.Files.PathUtils (readModule, lookupCurryFile)
import Curry.Syntax (Module, lexSource)
......@@ -33,8 +32,8 @@ import CurryBuilder (buildCurry)
import Modules (loadAndCheckModule)
import Transformations (qual)
--- translate source file into HTML file with syntaxcoloring
--- @param sourcefilename
-- translate source file into HTML file with syntaxcoloring
-- @param sourcefilename
source2html :: Options -> FilePath -> CYIO ()
source2html opts f = do
let baseName = takeBaseName f
......@@ -44,18 +43,18 @@ source2html opts f = do
program <- filename2program opts (fromMaybe f srcFile)
liftIO $ writeFile outFile (program2html baseName program)
--- @param importpaths
--- @param filename
--- @return program
-- @param importpaths
-- @param filename
-- @return program
filename2program :: Options -> String -> CYIO [Code]
filename2program opts f = do
mbModule <- liftIO $ readModule f
case mbModule of
Nothing -> left [message $ text $ "Missing file: " ++ f]
Just src -> do
case runMsg (lexSource f src) of
Left e -> left [e]
Right (toks, _) -> do
case lexSource f src of
Left err -> left [err]
Right toks -> do
typed <- fullParse opts f src
return (genProgram typed toks)
......
......@@ -29,7 +29,6 @@ import qualified Control.Monad.State as S (StateT, execStateT, gets, modify)
import qualified Data.Map as M (insert, member)
import Curry.Base.Ident
import Curry.Base.Message (runMsg)
import Curry.Base.Position
import Curry.Base.Pretty
import Curry.Files.PathUtils
......@@ -107,9 +106,9 @@ compileInterface ctxt (p, m) fn = do
mbSrc <- liftIO $ readModule fn
case mbSrc of
Nothing -> report $ errInterfaceNotFound p m
Just src -> case runMsg $ parseInterface fn src of
Just src -> case parseInterface fn src of
Left err -> report err
Right (intf@(Interface n is _), _) ->
Right intf@(Interface n is _) ->
if (m /= n)
then report $ errWrongInterface (first fn) m n
else do
......
......@@ -32,7 +32,6 @@ import System.IO
import System.Process (system)
import Curry.Base.Ident
import Curry.Base.Message (runMsg)
import Curry.Base.Position
import Curry.Base.Pretty
import Curry.ExtendedFlat.InterfaceEquivalence (eqInterface)
......@@ -108,14 +107,14 @@ parseModule opts fn = do
case mbSrc of
Nothing -> left [message $ text $ "Missing file: " ++ fn]
Just src -> do
case runMsg (CS.unlit fn src) of
Left err -> left [err]
Right (ul, _) -> do
case CS.unlit fn src of
Left err -> left [err]
Right ul -> do
prepd <- preprocess (optPrepOpts opts) fn ul
-- parse module
case runMsg (CS.parseModule fn prepd) of
Left err -> left [err]
Right (parsed, _) -> right parsed
case CS.parseModule fn prepd of
Left err -> left [err]
Right parsed -> right parsed
preprocess :: PrepOpts -> FilePath -> String -> CYIO String
preprocess opts fn src
......@@ -301,9 +300,9 @@ matchInterface :: FilePath -> CS.Interface -> IO Bool
matchInterface ifn i = do
hdl <- openFile ifn ReadMode
src <- hGetContents hdl
case runMsg (CS.parseInterface ifn src) of
Left _ -> hClose hdl >> return False
Right (i', _) -> return (i `intfEquiv` fixInterface i')
case CS.parseInterface ifn src of
Left _ -> hClose hdl >> return False
Right i' -> return (i `intfEquiv` fixInterface i')
writeFlat :: Options -> FilePath -> CompilerEnv -> ModuleSummary -> IL.Module
-> IO ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment