Compleating assignment for interpreter, modified grammars, fixed tests

This commit is contained in:
elvis
2024-11-16 15:40:00 +01:00
parent 40055899c9
commit 9e599cc018
24 changed files with 593 additions and 1238 deletions

View File

@ -5,7 +5,7 @@ Random.self_init ()
let (let*) = Result.bind
let rec evaluate_type (program: t_exp) (context: ftype VariableMap.t) : (ftype, error) result =
let rec evaluate_type (program: t_exp) (context: ftype VariableMap.t) : (ftype, [> typechecking_error]) result =
match program with
Integer _ -> Ok IntegerType
| Boolean _ -> Ok BooleanType
@ -150,7 +150,7 @@ let rec evaluate_type (program: t_exp) (context: ftype VariableMap.t) : (ftype,
| _ -> Error (`WrongTypeSpecification
"Specification of function is not a function type.")
let typecheck (program: t_exp) : (ftype, error) result =
let typecheck (program: t_exp) : (ftype, [> typechecking_error]) result =
let* typeprogram = evaluate_type program VariableMap.empty in
match typeprogram with
FunctionType (IntegerType, IntegerType) -> (