Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] camlp4: LIST1 construct on record patterns
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jeff Henrikson <jehenrik@y...>
Subject: [Caml-list] camlp4: LIST1 construct on record patterns
In camlp4, I don't seem to be able to break apart a record pattern in any way.  I must not understand how to use LIST1 properly:

let try_extend _ =
  let cons = "Bogus" in
  let test_label_eq = Grammar.Entry.find expr "test_label_eq" in
  let lbl_expr_list = Grammar.Entry.find expr "lbl_expr_list" in
    expr: LEVEL "simple"
    [ [ $cons$; "{"; memb = LIST1 lbl_expr_list SEP ";" ; "}" ->
          <:expr<{$list:memb$}>> ] ]

try_extend "junk";;

      [ [ $cons$; "{"; memb = LIST1 reenter SEP ";" ; "}" ->
            <:expr<{$list:memb$}>> ] ]
This expression has type Obj.t list but is here used with type
  (MLast.patt * MLast.expr) list

Isn't an Obj.t a completely opaque meaningless entity?

Substituting test_label_eq for lbl_expr_list makes no difference.  I got those identifiers by running:

Grammar.Entry.print expr;;

which doesn't tell me the meaning of test_label_eq, and

Grammar.Entry.print (Grammar.Entry.find expr "test_label_eq");;

doesn't tell me anything either.  Do I just have to go read the source code to know their meaning?  I would have except I guess it
doesn't come default now that camlp4 is part of ocaml.

Jeff Henrikson

Bug reports:  FAQ:
To unsubscribe, mail  Archives: