summaryrefslogtreecommitdiffstats
path: root/toplevel
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2014-04-16 16:51:37 +0000
committerAlain Frisch <alain@frisch.fr>2014-04-16 16:51:37 +0000
commit26a8bc20a79d7b817444b51c81bf6653ecb57651 (patch)
treedc7110cbe5cefd7c2a70734c8aaaff9f3f7b9a27 /toplevel
parent8106136bb3ea4840a63ccdf8b217f0d0efbb5192 (diff)
Support for toplevel primitives with multiple arguments.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14616 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'toplevel')
-rw-r--r--toplevel/toploop.ml12
-rw-r--r--toplevel/toploop.mli1
2 files changed, 8 insertions, 5 deletions
diff --git a/toplevel/toploop.ml b/toplevel/toploop.ml
index 503a11e5e..2dea9cf02 100644
--- a/toplevel/toploop.ml
+++ b/toplevel/toploop.ml
@@ -28,6 +28,7 @@ type directive_fun =
| Directive_int of (int -> unit)
| Directive_ident of (Longident.t -> unit)
| Directive_bool of (bool -> unit)
+ | Directive_generic of (Parsetree.directive_argument list -> unit)
(* The table of toplevel value bindings and its accessors *)
@@ -282,11 +283,12 @@ let execute_phrase print_outcome ppf phr =
| Ptop_dir(dir_name, dir_arg) ->
try
match (Hashtbl.find directive_table dir_name, dir_arg) with
- | (Directive_none f, Pdir_none) -> f (); true
- | (Directive_string f, Pdir_string s) -> f s; true
- | (Directive_int f, Pdir_int n) -> f n; true
- | (Directive_ident f, Pdir_ident lid) -> f lid; true
- | (Directive_bool f, Pdir_bool b) -> f b; true
+ | (Directive_none f, []) -> f (); true
+ | (Directive_string f, [Pdir_string s]) -> f s; true
+ | (Directive_int f, [Pdir_int n]) -> f n; true
+ | (Directive_ident f, [Pdir_ident lid]) -> f lid; true
+ | (Directive_bool f, [Pdir_bool b]) -> f b; true
+ | (Directive_generic f, l) -> f l; true
| (_, _) ->
fprintf ppf "Wrong type of argument for directive `%s'.@." dir_name;
false
diff --git a/toplevel/toploop.mli b/toplevel/toploop.mli
index 324857a83..b364a088e 100644
--- a/toplevel/toploop.mli
+++ b/toplevel/toploop.mli
@@ -39,6 +39,7 @@ type directive_fun =
| Directive_int of (int -> unit)
| Directive_ident of (Longident.t -> unit)
| Directive_bool of (bool -> unit)
+ | Directive_generic of (Parsetree.directive_argument list -> unit)
val directive_table : (string, directive_fun) Hashtbl.t
(* Table of known directives, with their execution function *)