From 1cdb8d8f6c328037b8f1b9446a497e0e94861f19 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Wed, 17 Jan 2024 09:16:47 -0600 Subject: Start of discocaml. --- discocaml/main.ml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 discocaml/main.ml (limited to 'discocaml/main.ml') diff --git a/discocaml/main.ml b/discocaml/main.ml new file mode 100644 index 0000000..2cc97b5 --- /dev/null +++ b/discocaml/main.ml @@ -0,0 +1,27 @@ +(* +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.use_file buf + +let () = + parse ~path:"main.ml" "let () = print_endline ((\"Hello, world!\") )" + |> List.iter (Pprintast.toplevel_phrase Format.std_formatter) -- cgit v1.2.3