From c3efede502f0f9ba3b03195ac8f30fff0376c8ab Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Thu, 18 Jan 2024 12:40:28 -0600 Subject: Libify ocaml, add buttons to interaction. --- discocaml/main.ml | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) (limited to 'discocaml/main.ml') diff --git a/discocaml/main.ml b/discocaml/main.ml index d9895f1..1f325e2 100644 --- a/discocaml/main.ml +++ b/discocaml/main.ml @@ -1,44 +1,4 @@ -type command = [ `Roundtrip ] - -let command_of_yojson = function - | `String "Roundtrip" -> Ok `Roundtrip - | _ -> Error "invalid command" - -type request = { expr : string; command : command } -[@@deriving of_yojson { exn = true }] - -type response = [ `Error of string ] [@@deriving to_yojson { exn = true }] - -(* -type position = [%import: Lexing.position] [@@deriving show] - -type location = [%import: (Location.t[@with Lexing.position := position])] -[@@deriving show] - -type constant = [%import: Parsetree.constant] [@@deriving show] -type expression_desc = [%import: Parsetree.expression_desc] [@@deriving show] -type expression = [%import: Parsetree.expression] [@@deriving show] - -type structure_item_desc = [%import: Parsetree.structure_item_desc] -[@@deriving show] - -type structure_item = [%import: Parsetree.structure_item] [@@deriving show] -type structure = [%import: Parsetree.structure] [@@deriving show] -type toplevel_phrase = [%import: Parsetree.toplevel_phrase] [@@deriving show] - -let parse ~path (src : string) = - let buf = Lexing.from_string src in - buf.lex_start_p <- { buf.lex_start_p with pos_fname = path }; - buf.lex_curr_p <- { buf.lex_curr_p with pos_fname = path }; - Parse.expression buf - -let () = - parse ~path:"main.ml" " print_endline ((\"Hello, world!\") )" - |> Format.fprintf Format.std_formatter "\n%a\n" Pprintast.expression -*) - -let handle_request { expr; command } : response = - match command with `Roundtrip -> `Error ("TODO: " ^ expr) +open Discocaml let () = Yojson.Safe.from_channel stdin -- cgit v1.2.3