summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 81e5976..0d1387f 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -25,6 +25,7 @@ import Control.Exception (IOException, catch)
-- 3 - Parse error.
-- 4 - Name analysis error.
-- 5 - Type error.
+-- 6 - Register allocation error.
main :: IO ()
main = execParser commandLine >>= withCommandLine
@@ -45,9 +46,9 @@ main = execParser commandLine >>= withCommandLine
| Just typeError <- typeAnalysis symbolTable program =
printAndExit 5 typeError
| otherwise =
- let instructions = generateRiscV
- $ allocate riscVConfiguration
- $ glue symbolTable program
- in elfObject output $ riscv32Elf instructions
+ let makeObject = elfObject output . riscv32Elf . generateRiscV
+ in either (printAndExit 6) makeObject
+ $ allocate riscVConfiguration
+ $ glue symbolTable program
printAndExit :: Show b => forall a. Int -> b -> IO a
printAndExit failureCode e = print e >> exitWith (ExitFailure failureCode)