From d08042be1e0ae158f124bb6848f5843a804a6544 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 6 Sep 2022 22:22:32 +0100 Subject: Assignation --- src/Compiler.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Compiler.hs') 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 -- cgit v1.2.3