diff options
Diffstat (limited to 'discocaml/discocaml.ml')
-rw-r--r-- | discocaml/discocaml.ml | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/discocaml/discocaml.ml b/discocaml/discocaml.ml index 2140fa5..f11a81b 100644 --- a/discocaml/discocaml.ml +++ b/discocaml/discocaml.ml @@ -1,3 +1,5 @@ +open Ast + type command = [ `Parse | `DrawTree | `RunCBN | `RunCBV | `StepCBN | `StepCBV ] let command_of_yojson = function @@ -31,21 +33,21 @@ let handle_request { expr; command } : response = try let buf = Lexing.from_string expr in let expr = Parse.expression buf in - let expr = Ast.expr_of_parsetree expr in + let expr = expr_of_parsetree expr in - let expr_response (expr : Ast.expr) : response = + let expr_response (expr : expr ast) : response = let buf = Buffer.create 16 in (let fmt = Format.formatter_of_buffer buf in - Pprintast.expression fmt (Ast.parsetree_of_expr expr); + Pprintast.expression fmt (parsetree_of_expr expr); Format.pp_print_flush fmt ()); let has_redex = Option.is_some (Eval.find_redex_cbn expr) in `Expr { expr = Buffer.contents buf; has_redex } in - let step_with (find_redex : Ast.expr -> Eval.path option) (expr : Ast.expr) - : Ast.expr = + let step_with (find_redex : expr ast -> expr index option) (expr : expr ast) + : expr ast = match find_redex expr with - | Some path -> Eval.reduce expr path + | Some i -> Eval.reduce expr i | None -> failwith "no redex" in |