summaryrefslogtreecommitdiff
path: root/ocaml-binary-annot/camlp4/test/fixtures/gram-tree3.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml-binary-annot/camlp4/test/fixtures/gram-tree3.ml')
-rw-r--r--ocaml-binary-annot/camlp4/test/fixtures/gram-tree3.ml23
1 files changed, 23 insertions, 0 deletions
diff --git a/ocaml-binary-annot/camlp4/test/fixtures/gram-tree3.ml b/ocaml-binary-annot/camlp4/test/fixtures/gram-tree3.ml
new file mode 100644
index 0000000000..06af8dd278
--- /dev/null
+++ b/ocaml-binary-annot/camlp4/test/fixtures/gram-tree3.ml
@@ -0,0 +1,23 @@
+open Camlp4.PreCast;
+module G = MakeGram Lexer;
+type t = [ A of t and t | B of string ];
+value main = G.Entry.mk "main";
+(* value rec length x acc =
+ match x with
+ [ A x y -> length x (length y acc)
+ | B _ -> succ acc ]; *)
+value length _ _ = -1;
+EXTEND G
+ GLOBAL: main;
+ main:
+ [ RIGHTA
+ [ x = SELF; y = SELF -> A x y
+ | i = ident -> B i ] ];
+ ident:
+ [ [ `LIDENT s -> s ] ];
+END;
+try
+ let f = Sys.argv.(1) in
+ Format.printf "%d@."
+ (length (G.parse main (Loc.mk f) (Stream.of_channel (open_in f))) 0)
+with e -> Format.eprintf "error: %a@." Camlp4.ErrorHandler.print e;