-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInit.hs
More file actions
38 lines (32 loc) · 990 Bytes
/
Init.hs
File metadata and controls
38 lines (32 loc) · 990 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
27
28
29
30
31
32
33
34
35
36
37
38
-- automatically generated by BNF Converter
module Main where
import Control.Monad (when)
import System.Environment (getArgs, getProgName)
import System.Exit (exitFailure, exitSuccess)
import System.IO (hGetContents, stdin)
import EvaluateProgram
import LexDeclaration
import ParDeclaration
import ErrM
import TypeChecker (checkProgramTypesIO)
usage = do
putStrLn "provide an input file name as an argument"
exitFailure
main :: IO ()
main = do
args <- getArgs
input <-
case args of
[] -> usage
(fileName:_) -> readFile fileName
case pProgram (myLexer input) of
Bad s -> do
putStrLn "\nParse Failed...\n"
putStrLn "Tokens:"
putStrLn s
exitFailure
Ok tree -> do
correctTypes <- checkProgramTypesIO tree
if correctTypes
then runProgramIO tree
else exitFailure