Commit 1cb27884 authored by Pietro Abate's avatar Pietro Abate

add help for sub-directive debug

parent 25b12781
......@@ -71,12 +71,25 @@ let directive_help ppf =
#env;; dump current environment
#reinit_ns;; reinitialize namespace processing
#help;; shows this help message
#print_type <type>;;
#print_type <type>;; dump internal representation of <type>
#debug ;;
#silent;; turn off outputs from the toplevel
#verbose;; turn on outputs from the toplevel
#builtins;; shows embedded OCaml values
"
let directive_help_debug ppf =
Format.fprintf ppf
"Debug sub-directives:
#debug sybtype <type> <type> ;; check if t1 < t2 for all substitutions
#debug typed <expr> ;; dump typed internal representation
#debug lambda <expr> ;; dump lambda internal representation
#debug accept <???> ;;
#debug sample <???> ;;
#debug filter <???> ;;
#debug compile <???> ;;
"
let rec print_exn ppf = function
| Location (loc, w, exn) ->
Cduce_loc.print_loc ppf (loc,w);
......@@ -175,7 +188,6 @@ let rec print_exn ppf = function
(* raise exn *)
Format.fprintf ppf "%a@." print_protect (Printexc.to_string exn)
let eval_quiet tenv cenv e =
let (e,_) = Typer.type_expr tenv e in
Compile.compile_eval_expr cenv e
......@@ -258,8 +270,8 @@ let directive ppf tenv cenv = function
Format.fprintf ppf "%a@." Types.Print.pp_noname (Types.descr t)
| `Reinit_ns ->
Typer.set_ns_table_for_printer tenv
| `Help ->
directive_help ppf
| `Help (Some "debug") -> directive_help_debug ppf
| `Help _ -> directive_help ppf
| `Dump pexpr ->
Value.dump_xml ppf (eval_quiet tenv cenv pexpr);
flush_ppf ppf
......
......@@ -33,7 +33,7 @@ and toplevel_directive =
[ `Quit
| `Env
| `Reinit_ns
| `Help
| `Help of string option
| `Dump of pexpr
| `Print_type of ppat
| `Debug of debug_directive
......
......@@ -179,7 +179,8 @@ EXTEND Gram
[ mk _loc (Directive (`Print_type t)) ]
| "#"; IDENT "dump_value"; e = expr -> [ mk _loc (Directive (`Dump e)) ]
| "#"; IDENT "reinit_ns" -> [ mk _loc (Directive `Reinit_ns) ]
| "#"; IDENT "help" -> [ mk _loc (Directive `Help) ]
| "#"; IDENT "help" -> [ mk _loc (Directive (`Help None)) ]
| "#"; IDENT "help"; "debug" -> [ mk _loc (Directive (`Help (Some "debug"))) ]
| "#"; IDENT "builtins" -> [ mk _loc (Directive `Builtins) ]
| "include"; s = STRING ->
protect_op "File inclusion";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment