diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-11-24 13:05:11 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-11-26 23:44:25 +0100 |
| commit | f7b36cb81d96817d1c69ffe9025b88112de7400c (patch) | |
| tree | c3846bafd78045b3dfff5c021ed82443868590b3 /src | |
| parent | 0c9799b887e967a55857377dad0d64ad625b47c9 (diff) | |
| download | elna-f7b36cb81d96817d1c69ffe9025b88112de7400c.tar.gz | |
Implement the while loop
Diffstat (limited to 'src')
| -rw-r--r-- | src/Main.hs | 9 |
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) |
