Take in input/output file args

This commit is contained in:
Ethan Girouard 2024-12-09 20:19:31 -05:00
parent 37cf2fe339
commit 2819b7fc57
Signed by: eta357
GPG Key ID: 7BCDC36DFD11C146

View File

@ -6,10 +6,17 @@ import qualified Data.Text.IO as T
import Data.Text.Prettyprint.Doc (pretty)
import Text.Megaparsec (parse)
import Windows12.Parser (programP)
import System.Environment (getArgs)
main :: IO ()
main = do
test <- T.readFile "test/hello.w12"
case parse programP "test/hello.w12" test of
args <- getArgs
if length args /= 2
then putStrLn "Usage: windows12 <input file> <output file>"
else do
let [inputFile, outputFile] = args
test <- T.readFile inputFile
case parse programP inputFile test of
Left err -> print err
Right ast -> print (pretty ast)