added file suffix and check
This commit is contained in:
parent
ac43af8110
commit
d49e2401bf
2 changed files with 42 additions and 25 deletions
65
src/Main.hs
65
src/Main.hs
|
|
@ -2,38 +2,53 @@
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Codegen.Codegen (generateCode)
|
import Codegen.Codegen (generateCode)
|
||||||
import Data.Bool (bool)
|
import Data.Bool (bool)
|
||||||
import GHC.IO.Handle.Text (hPutStrLn)
|
import GHC.IO.Handle.Text (hPutStrLn)
|
||||||
import Grammar.ErrM (Err)
|
import Grammar.ErrM (Err)
|
||||||
import Grammar.Par (myLexer, pProgram)
|
import Grammar.Par (myLexer, pProgram)
|
||||||
import Grammar.Print (printTree)
|
import Grammar.Print (printTree)
|
||||||
|
|
||||||
import Monomorphizer.Monomorphizer (monomorphize)
|
import Monomorphizer.Monomorphizer (monomorphize)
|
||||||
|
|
||||||
import Control.Monad (when)
|
import Control.Monad (when)
|
||||||
import Data.List.Extra (isSuffixOf)
|
import Data.List.Extra (isSuffixOf)
|
||||||
|
|
||||||
import Compiler (compile)
|
import Compiler (compile)
|
||||||
import Renamer.Renamer (rename)
|
import Renamer.Renamer (rename)
|
||||||
import System.Directory (createDirectory, doesPathExist,
|
import System.Directory (
|
||||||
getDirectoryContents,
|
createDirectory,
|
||||||
removeDirectoryRecursive,
|
doesPathExist,
|
||||||
setCurrentDirectory)
|
getDirectoryContents,
|
||||||
import System.Environment (getArgs)
|
removeDirectoryRecursive,
|
||||||
import System.Exit (ExitCode, exitFailure,
|
setCurrentDirectory,
|
||||||
exitSuccess)
|
)
|
||||||
import System.IO (stderr)
|
import System.Environment (getArgs)
|
||||||
import System.Process.Extra (readCreateProcess, shell,
|
import System.Exit (
|
||||||
spawnCommand, waitForProcess)
|
ExitCode,
|
||||||
import TypeChecker.TypeChecker (typecheck)
|
exitFailure,
|
||||||
|
exitSuccess,
|
||||||
|
)
|
||||||
|
import System.IO (stderr)
|
||||||
|
import System.Process.Extra (
|
||||||
|
readCreateProcess,
|
||||||
|
shell,
|
||||||
|
spawnCommand,
|
||||||
|
waitForProcess,
|
||||||
|
)
|
||||||
|
import TypeChecker.TypeChecker (typecheck)
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main =
|
main =
|
||||||
getArgs >>= \case
|
getArgs >>= \case
|
||||||
[] -> print "Required file path missing"
|
[] -> putStrLn "Required file path missing"
|
||||||
("-d" : s : _) -> main' True s
|
["-d", s] -> do
|
||||||
(s : _) -> main' False s
|
when (".crf" `isSuffixOf` s) (main' True s)
|
||||||
|
putStrLn $ "File '" ++ s ++ "' is not a churf file"
|
||||||
|
[s] -> do
|
||||||
|
when (".crf" `isSuffixOf` s) (main' False s)
|
||||||
|
putStrLn $ "File '" ++ s ++ "' is not a churf file"
|
||||||
|
xs -> putStrLn $ "Can't process: " ++ unwords xs
|
||||||
|
|
||||||
main' :: Bool -> String -> IO ()
|
main' :: Bool -> String -> IO ()
|
||||||
main' debug s = do
|
main' debug s = do
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,5 @@ bind ma f = case ma of {
|
||||||
Nothing => Nothing ;
|
Nothing => Nothing ;
|
||||||
Just a => f a ;
|
Just a => f a ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue