aboutsummaryrefslogtreecommitdiff
path: root/discocaml/main.ml
blob: 2cc97b5d5df68e301d04bf7b78740c171447c82e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)