diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-08-13 08:14:18 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-08-13 08:14:18 +0100 |
commit | 326386322d26b633672de37f045a53f18f2336a5 (patch) | |
tree | f2f26d1b94fd79d01cfc97377a1b4e66c57ee1c1 /src | |
parent | d1fc24d2f17ca1649717c76a130db3869b6abc88 (diff) | |
download | micro-lang-hs-326386322d26b633672de37f045a53f18f2336a5.tar.gz micro-lang-hs-326386322d26b633672de37f045a53f18f2336a5.zip |
Probably better
Diffstat (limited to 'src')
-rw-r--r-- | src/Ast.hs | 4 | ||||
-rw-r--r-- | src/Compiler.hs | 6 |
2 files changed, 5 insertions, 5 deletions
@@ -25,3 +25,7 @@ data Op | Mul | Div deriving (Eq, Ord, Show) + +toFuncType :: [FuncParam] -> Maybe Type -> Type +toFuncType params rtyp = + FuncType (map (\(_, t, _) -> t) params) rtyp diff --git a/src/Compiler.hs b/src/Compiler.hs index fc4d9e6..ea97bb8 100644 --- a/src/Compiler.hs +++ b/src/Compiler.hs @@ -8,10 +8,6 @@ import System.Environment (getEnv, getEnvironment) import Text.Parsec (ParseError, SourcePos) import Text.Read (Lexeme (String)) -toFuncType :: [A.FuncParam] -> Maybe A.Type -> A.Type -toFuncType params rtyp = - A.FuncType (map (\(_, t, _) -> t) params) rtyp - type CompState = (Env, [Error]) type CompResult = Either [Error] () @@ -29,7 +25,7 @@ compile (x : xs) = do (ev, errs) <- get -- with function and parameters (nev, nerrs) <- - return $ case addSymUniq ev (ident, toFuncType params ret, pos) of + return $ case addSymUniq ev (ident, A.toFuncType params ret, pos) of Left e -> (ev, e : errs) Right fev -> foldl |