Add initial typechecker for AST #2
@ -30,6 +30,7 @@ data BinaryOperator
|
|||||||
| Subtraction
|
| Subtraction
|
||||||
| Multiplication
|
| Multiplication
|
||||||
| Division
|
| Division
|
||||||
|
| Modulus
|
||||||
| BitwiseAnd
|
| BitwiseAnd
|
||||||
| BitwiseOr
|
| BitwiseOr
|
||||||
| BitwiseXor
|
| BitwiseXor
|
||||||
|
@ -82,6 +82,12 @@ typeCheckExpression (BinaryOperation op expr1 expr2) symtab classes =
|
|||||||
TypedExpression "int" (BinaryOperation op expr1' expr2')
|
TypedExpression "int" (BinaryOperation op expr1' expr2')
|
||||||
else
|
else
|
||||||
error "Division operation requires two operands of type int"
|
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 ->
|
BitwiseAnd ->
|
||||||
if type1 == "int" && type2 == "int"
|
if type1 == "int" && type2 == "int"
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user