File: test_toplevel.ml

package info (click to toggle)
js-of-ocaml 5.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 32,020 kB
  • sloc: ml: 91,250; javascript: 57,289; ansic: 315; makefile: 271; lisp: 23; sh: 6; perl: 4
file content (25 lines) | stat: -rw-r--r-- 630 bytes parent folder | download
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
let () =
  let content =
    {|
let () = print_endline "hello";;
1+1;;
1+;;
Missing_module.f;;
let y = float 1 /. float 3;;
|}
  in
  Topdirs.dir_directory "/static/cmis";
  Toploop.initialize_toplevel_env ();
  Toploop.input_name := "//toplevel//";
  let lexbuf = Lexing.from_string content in
  while true do
    try
      Location.reset ();
      let phr = !Toploop.parse_toplevel_phrase lexbuf in
      let res = Toploop.execute_phrase true Format.std_formatter phr in
      flush_all ();
      if not res then raise Exit
    with
    | End_of_file -> exit 0
    | x -> Location.report_exception Format.std_formatter x
  done