add modulus to AST and Typecheck
This commit is contained in:
parent
1d5463582f
commit
20184c5e26
@ -30,6 +30,7 @@ data BinaryOperator
|
||||
| Subtraction
|
||||
| Multiplication
|
||||
| Division
|
||||
| Modulus
|
||||
| BitwiseAnd
|
||||
| BitwiseOr
|
||||
| BitwiseXor
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user