summaryrefslogtreecommitdiff
path: root/Main.hs
blob: 3fc7aebe72dec8635d7475072463c47015404893 (plain)
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
module Main where

import System.Environment
import System.Exit

import Compiler
import Lower
import Optimiser
import Parser
import VM


usage :: IO ()
usage = do
    progname <- getProgName
    putStrLn $ "Usage: " ++ progname ++ " [filename.lisp]"

main :: IO ()
main = do
    clargs <- getArgs
    source <- case clargs of
        [] -> getContents
        [fname] -> readFile fname
        _ -> usage >> exitFailure

    prog <- parseProgram source >>= either (die . show) return
    irprog <- either die return (compileProgram prog)
    let opt = optimise irprog
    print opt
    -- vmRun opt
    let asmprog = lowerIR opt
    print asmprog