-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.hs
More file actions
26 lines (24 loc) · 865 Bytes
/
Main.hs
File metadata and controls
26 lines (24 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Main where
import Text.ParserCombinators.Parsec hiding (spaces)
import System.Environment
import System.Process
import Carrie.Parser.CarrieParser
import Carrie.Parser.CarrieStructs
import Carrie.Compiler.CarrieCompiler
testMain :: IO ()
testMain = do
fileInput <- readFile "test.car"
case parse mainParser "" fileInput of
Left err -> putStrLn $ show err
Right val -> putStrLn $ show val
main :: IO ()
main = do
fileName <- fmap head getArgs
fileInput <- readFile fileName
let p = case parse mainParser "" fileInput of
Left err -> [CrError "Something went wrong! Check your code!"]
Right val -> val
writeFile "main.rs" ""
appendFile "main.rs" (concat $ map compile p)
runCommand "rustc main.rs"
putStrLn "Compiling has finished! (main.rs has been created)"