diff --git a/src/Ast.hs b/src/Ast.hs index 6253aa6..6554290 100644 --- a/src/Ast.hs +++ b/src/Ast.hs @@ -30,6 +30,7 @@ data BinaryOperator | Subtraction | Multiplication | Division + | Modulus | BitwiseAnd | BitwiseOr | BitwiseXor diff --git a/src/Typecheck.hs b/src/Typecheck.hs index 5f1f28c..7a7ac8d 100644 --- a/src/Typecheck.hs +++ b/src/Typecheck.hs @@ -82,6 +82,12 @@ typeCheckExpression (BinaryOperation op expr1 expr2) symtab classes = TypedExpression "int" (BinaryOperation op expr1' expr2') else error "Division operation requires two operands of type int" + Modulus -> + if type1 == "int" && type2 == "int" + then + TypedExpression "int" (BinaryOperation op expr1' expr2') + else + error "Modulus operation requires two operands of type int" BitwiseAnd -> if type1 == "int" && type2 == "int" then