summaryrefslogtreecommitdiff
path: root/ocaml-binary-annot/camlp4/test/fixtures/pr4314gram4.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml-binary-annot/camlp4/test/fixtures/pr4314gram4.ml')
-rw-r--r--ocaml-binary-annot/camlp4/test/fixtures/pr4314gram4.ml36
1 files changed, 36 insertions, 0 deletions
diff --git a/ocaml-binary-annot/camlp4/test/fixtures/pr4314gram4.ml b/ocaml-binary-annot/camlp4/test/fixtures/pr4314gram4.ml
new file mode 100644
index 0000000000..1c6712e242
--- /dev/null
+++ b/ocaml-binary-annot/camlp4/test/fixtures/pr4314gram4.ml
@@ -0,0 +1,36 @@
+open Camlp4.PreCast ;
+module G = Camlp4.PreCast.Gram ;
+
+value exp = G.Entry.mk "exp" ;
+value prog = G.Entry.mk "prog" ;
+
+EXTEND G
+exp:
+[ "apply"
+ [ e1 = SELF; e2 = exp LEVEL "simple"; e3 = exp LEVEL "simple" ->
+ let p = Loc.dump in
+ let () =
+ Format.eprintf "e1: %a,@.e2: %a,@.e3: %a,@._loc: %a@."
+ p e1 p e2 p e3 p _loc
+ in
+ _loc
+ ]
+| "simple"
+ [ _ = LIDENT -> _loc ]
+];
+prog: [[ e = exp; `EOI -> e ]];
+END ;
+
+(* and the following function: *)
+
+value parse_string entry s =
+try
+ G.parse_string entry (Loc.mk "<string>") s
+with [ Loc.Exc_located loc exn ->
+begin
+ print_endline (Loc.to_string loc);
+ print_endline (Printexc.to_string exn);
+ failwith "Syntax Error"
+end ] ;
+
+parse_string prog "f x y";