caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jake Donham <jake@donham.org>
To: Joel Reymont <joelr1@gmail.com>
Cc: "O'Caml Mailing List" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] camlp4 grammar and LIST1
Date: Tue, 10 Mar 2009 16:01:43 -0700	[thread overview]
Message-ID: <c7e4e9f0903101601i4d5c580dl9427dd98e2e4adbf@mail.gmail.com> (raw)
In-Reply-To: <C682AD11-2C6D-4356-AFB5-1E34D1FA3239@gmail.com>

On Tue, Mar 10, 2009 at 3:07 PM, Joel Reymont <joelr1@gmail.com> wrote:
> I have it like this at the moment. Are you saying it won't work?

Here's an example of what I'm talking about:

  open Camlp4.PreCast
  let bar = Gram.Entry.mk "bar"
  let baz = Gram.Entry.mk "baz"
  let bar_or_baz = Gram.Entry.mk "bar_or_baz"
  ;;
  EXTEND Gram
  bar : [[ LIST0 "quux"; "bar" -> () ]];
  baz : [[ LIST0 "quux"; "baz" -> () ]];
  bar_or_baz : [[ bar | baz ]];
  END
  ;;
  Gram.parse_string bar_or_baz Loc.ghost "quux quux baz"

The given string does not parse because we've already committed to the
bar branch.

However, several variations I tried did not show this behavior (e.g.
only one quux in the string). I think there are some special cases,
although they are not documented anywhere I have found. An approach
that works for me is to think "recursive descent" and always give
rules that check at least one token before branching to another rule.

Jake


  reply	other threads:[~2009-03-10 23:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-10 18:41 Joel Reymont
2009-03-10 21:48 ` [Caml-list] " Jake Donham
2009-03-10 22:07   ` Joel Reymont
2009-03-10 23:01     ` Jake Donham [this message]
2009-03-10 23:36       ` Joel Reymont

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=c7e4e9f0903101601i4d5c580dl9427dd98e2e4adbf@mail.gmail.com \
    --to=jake@donham.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=joelr1@gmail.com \
    /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).