Fix for let rec, currently not implemented
This commit is contained in:
@ -29,6 +29,14 @@ let () =
|
||||
()
|
||||
in
|
||||
|
||||
let evalb = Clap.flag
|
||||
~description: "Optional flag for evaluating the generated risc code."
|
||||
~section: values
|
||||
~set_long: "eval"
|
||||
~set_short: 'e'
|
||||
false
|
||||
in
|
||||
|
||||
let output = Clap.optional_string
|
||||
~description: "Output file. If not specified output is printed on stdout."
|
||||
~placeholder: "FILENAME"
|
||||
@ -63,26 +71,32 @@ let () =
|
||||
exit (-1)
|
||||
in
|
||||
let ty_program =
|
||||
match TypeChecker.typecheck_polymorphic program with
|
||||
match TypeChecker.typecheck_polymorphic_unbound program with
|
||||
| Ok ty -> ty
|
||||
| Error (`AbsentAssignment msg)
|
||||
| Error (`WrongTypeSpecification msg)
|
||||
| Error (`RecusrionsNotImplemented msg)
|
||||
| Error (`WrongType msg) ->
|
||||
Printf.fprintf stderr "%s\n" msg;
|
||||
exit (-1)
|
||||
in
|
||||
let return_value =
|
||||
match Semantics.reduce program inval with
|
||||
Ok o -> o
|
||||
| Error (`AbsentAssignment msg)
|
||||
| Error (`DivisionByZero msg)
|
||||
| Error (`WrongType msg) ->
|
||||
Printf.fprintf stderr "%s\n" msg;
|
||||
exit (-1)
|
||||
if evalb then
|
||||
match Semantics.reduce program inval with
|
||||
Ok o -> Some o
|
||||
| Error (`AbsentAssignment msg)
|
||||
| Error (`DivisionByZero msg)
|
||||
| Error (`WrongType msg) ->
|
||||
Printf.fprintf stderr "%s\n" msg;
|
||||
exit (-1)
|
||||
else
|
||||
None
|
||||
in
|
||||
|
||||
Printf.fprintf outch "Type of the program: %s\n" (Types.pp_type_f ty_program);
|
||||
Printf.fprintf outch "%d\n" return_value
|
||||
match return_value with
|
||||
| Some v -> Printf.fprintf outch "%d\n" v
|
||||
| None -> ()
|
||||
in
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user