caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] camlp4: LIST1 construct on record patterns
Date: Sun, 13 Jan 2002 14:48:23 +0100	[thread overview]
Message-ID: <20020113144823.E24240@verdot.inria.fr> (raw)
In-Reply-To: <005401c19bf4$93d638a0$0b01a8c0@mit.edu>; from jehenrik@yahoo.com on Sun, Jan 13, 2002 at 12:38:49AM -0500

Hi,

On Sun, Jan 13, 2002 at 12:38:49AM -0500, Jeff Henrikson wrote:

>       [ [ $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

The problem is that Grammar.Entry.find cannot answer the right entry
type, since it can be any type. It is like "input_value". This is a
problem indeed to search for hidden entries. You have to know its real
type and magicify it (sorry):

  let lbl_expr_list =
    (Obj.magic (Grammar.Entry.find expr "lbl_expr_list") :
       (MLast.patt * MLast.expr) list Grammar.Entry.e)
  in
  ...

Something like that, I have not checked...

Yes, it is a little bit dirty, but I cannot export all the small
entries of the grammar.

> which doesn't tell me the meaning of test_label_eq

The entry "test_label_eq" is a hack to allow to separate the rules:
    { lbl_expr_list }
    { expr with lbl_expr_list }

The system of grammar of Camlp4 is not strong enough to separate
"lbl_expr_list" and "expr" which can start with the same tokens (it is
LL(infinity), because the first label can be A.B.C.D...lab). In
revised syntax, to avoid that problem, the "expr" must be
parenthesised.

There is some other hacks like that in the normal syntax.

The entry "test_label_eq" is written with a parser; it is created with
Grammar.Entry.of_parser and is not extensible and not visible by
Grammar.Entry.print. See the sources: camlp4/etc/pa_o.ml.

Sorry, Luke, you entered the dark side of Camlp4... :-)

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2002-01-13 13:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-13  5:38 Jeff Henrikson
2002-01-13 13:48 ` Daniel de Rauglaudre [this message]
2002-01-14  2:17   ` Jeff Henrikson
2002-01-14  2:49     ` Jeff Henrikson
2002-01-14  5:10       ` Daniel de Rauglaudre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020113144823.E24240@verdot.inria.fr \
    --to=daniel.de_rauglaudre@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).