perga/app/Main.hs

25 lines
587 B
Haskell
Raw Normal View History

2024-10-05 13:31:09 -07:00
module Main where
2024-11-15 18:39:44 -08:00
import qualified Data.Text.IO as T
2024-10-05 16:04:13 -07:00
import Parser
2024-11-15 18:39:44 -08:00
import Repl
import System.Environment
2024-10-05 16:04:13 -07:00
import System.IO
2024-11-11 14:34:55 -08:00
2024-10-05 13:31:09 -07:00
main :: IO ()
2024-10-05 16:04:13 -07:00
main = do
2024-11-15 18:39:44 -08:00
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
2024-11-17 01:57:53 -08:00
Right () -> putStrLn "success!"