Merge branch 'main' of github.com:bachelor-group-66-systemf/churf

This commit is contained in:
Rakarake 2023-05-08 19:29:32 +02:00
commit 283f8ccf83
4 changed files with 86 additions and 50 deletions

View file

@ -320,7 +320,7 @@ emitECased t e cases = do
emit $ Label lbl_failPos
emitCases rt ty label stackPtr vs (Branch (PEnum (Ident "True$Bool"), t) exp) = do
emitCases rt ty label stackPtr vs (Branch (PLit $ LInt 1, t) exp)
emitCases rt ty label stackPtr vs (Branch (PEnum (Ident "False$Bool"), _) exp) = do
emitCases rt ty label stackPtr vs (Branch (PEnum (Ident "False$Bool"), t) exp) = do
emitCases rt ty label stackPtr vs (Branch (PLit (LInt 0), t) exp)
emitCases rt ty label stackPtr vs br@(Branch (PEnum consId, _) exp) = do
emit $ Comment "Penum"

View file

@ -58,6 +58,7 @@ flags =
[ Option ['d'] ["debug"] (NoArg enableDebug) "Print debug messages."
, Option ['t'] ["type-checker"] (ReqArg chooseTypechecker "bi/hm") "Choose type checker. Possible options are bi and hm"
, Option ['m'] ["disable-gc"] (NoArg disableGC) "Disables the garbage collector and uses malloc instead."
, Option ['p'] ["disable-prelude"] (NoArg disablePrelude) "Do not include the prelude"
, Option [] ["help"] (NoArg enableHelp) "Print this help message"
]
@ -68,6 +69,7 @@ initOpts =
, debug = False
, gc = True
, typechecker = Nothing
, preludeOpt = True
}
enableHelp :: Options -> Options
@ -79,6 +81,9 @@ enableDebug opts = opts{debug = True}
disableGC :: Options -> Options
disableGC opts = opts{gc = False}
disablePrelude :: Options -> Options
disablePrelude opts = opts{preludeOpt = False}
chooseTypechecker :: String -> Options -> Options
chooseTypechecker s options = options{typechecker = tc}
where
@ -92,6 +97,7 @@ data Options = Options
, debug :: Bool
, gc :: Bool
, typechecker :: Maybe TypeChecker
, preludeOpt :: Bool
}
main' :: Options -> String -> IO ()
@ -184,4 +190,10 @@ prelude =
".- : Int -> Int -> Int"
, ".- x y = 0"
, "\n"
, ".== : Int -> Int -> Bool"
, ".== a b = case a < b of"
, " False => case b < a of"
, " False => True"
, " _ => False"
, " False => False"
]