30 lines
800 B
Haskell
30 lines
800 B
Haskell
module Main where
|
|
|
|
import Check
|
|
import qualified Data.Text.IO as T
|
|
import Expr
|
|
import Parser
|
|
import Repl
|
|
import System.Environment
|
|
import System.IO
|
|
|
|
main :: IO ()
|
|
main = do
|
|
args <- getArgs
|
|
case args of
|
|
[] -> repl
|
|
[file] -> handleFile file
|
|
_ -> putStrLn "usage './perga' for repl and './perga <filename>' to get input from a file"
|
|
|
|
handleFile :: String -> IO ()
|
|
handleFile fileName =
|
|
do
|
|
fileH <- openFile fileName ReadMode
|
|
input <- T.hGetContents fileH
|
|
case pAll input of
|
|
Left err -> putStrLn err
|
|
Right expr -> case findType [] expr of
|
|
Left err -> print err
|
|
Right ty -> do
|
|
putStrLn $ "expr:\t" ++ prettyS expr
|
|
putStrLn $ "type:\t" ++ prettyS ty
|