24 lines
587 B
Haskell
24 lines
587 B
Haskell
module Main where
|
|
|
|
import qualified Data.Text.IO as T
|
|
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 () -> putStrLn "success!"
|