Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (21 sloc) 790 Bytes

Dynamic Old Syntax

Deprecation Warning: this tutorial describes technology that is considered obsolete. It's been replaced by [extensions points and ppx rewriters](http://caml.inria.fr/pub/docs/manual-ocaml-{{! get LATEST_OCAML_VERSION_MAIN !}}/extn.html#sec243)

dynamic_old_syntax.ml:

(* #load "camlp4orf.cma" *)
type t1 = A | B
type t2 = Foo of string * t1
open Pcaml
let foo = Entry.mk gram "foo"
let bar = Entry.mk gram "bar"
let () =
  EXTEND
    GLOBAL: foo bar;
    foo: [ [ "foo"; i = LIDENT; b = bar -> Foo(i, b) ] ];
    bar: [ [ "?" -> A | "." -> B ] ];
  END;;
Entry.parse foo (Stream.of_string "foo x?") = Foo("x", A);;
DELETE_RULE foo: "foo"; LIDENT; bar END;;