From f7b36cb81d96817d1c69ffe9025b88112de7400c Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 24 Nov 2024 13:05:11 +0100 Subject: Implement the while loop --- src/Main.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') 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) -- cgit v1.2.3