aboutsummaryrefslogtreecommitdiff
path: root/src/Compiler.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-09-06 22:22:32 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-09-06 22:22:32 +0100
commitd08042be1e0ae158f124bb6848f5843a804a6544 (patch)
tree71ffa63234c13f3bf7d31fe3c0a3876839cae2e8 /src/Compiler.hs
parentf8dfbfc1604aea626a6502b9f6d06ea1299a0cdb (diff)
downloadmicro-lang-hs-d08042be1e0ae158f124bb6848f5843a804a6544.tar.gz
micro-lang-hs-d08042be1e0ae158f124bb6848f5843a804a6544.zip
Assignation
Diffstat (limited to 'src/Compiler.hs')
-rw-r--r--src/Compiler.hs13
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