Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (20 sloc) 796 Bytes

Static 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)

static_old_syntax.ml:

type t1 = A | B
type t2 = Foo of string * t1
module Gram = Grammar.GMake(...)
let foo = Gram.Entry.mk "foo"
let bar = Gram.Entry.mk "bar"
let () =
  GEXTEND Gram
    GLOBAL: foo bor;
    foo: [ [ "foo"; i = LIDENT; b = bar -> Foo(i, b) ] ];
    bar: [ [ "?" -> A | "." -> B ] ];
  END;;
Gram.Entry.parse foo (Stream.of_string "foo x?") = Foo("x", A);;
GDELETE_RULE Gram foo: "foo"; LIDENT; bar END