diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-09-06 22:22:32 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-09-06 22:22:32 +0100 |
commit | d08042be1e0ae158f124bb6848f5843a804a6544 (patch) | |
tree | 71ffa63234c13f3bf7d31fe3c0a3876839cae2e8 /src/Compiler.hs | |
parent | f8dfbfc1604aea626a6502b9f6d06ea1299a0cdb (diff) | |
download | micro-lang-hs-d08042be1e0ae158f124bb6848f5843a804a6544.tar.gz micro-lang-hs-d08042be1e0ae158f124bb6848f5843a804a6544.zip |
Assignation
Diffstat (limited to 'src/Compiler.hs')
-rw-r--r-- | src/Compiler.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Compiler.hs b/src/Compiler.hs index 38b5227..ce68c16 100644 --- a/src/Compiler.hs +++ b/src/Compiler.hs @@ -110,7 +110,18 @@ compile x = do (A.Module name pos) -> return $ Right Nothing (A.Num _ _) -> return $ Right $ Just $ A.Type "u8" -- TODO: placeholder (A.Bool' _ _) -> return $ Right $ Just $ A.Type "bool" - (A.BinOp _ a b) -> do + (A.BinOp A.Assign pos a@(A.Variable _ _) b) -> do + l <- compile a + case l of + Right tl -> do + tr <- typecheckVal b $ tl + case tr of + Just err -> addError $ Error TypeError err pos + Nothing -> return $ Right $ tl + _ -> return $ Right Nothing -- error resolving left + (A.BinOp A.Assign pos _ _) -> + addError $ Error InvalidTarget "invalid assignment target" pos + (A.BinOp _ _ a b) -> do l <- compile a r <- compile b return $ l -- TODO: placeholder |