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 14:48:14 -0700	[thread overview]
Message-ID: <c7e4e9f0903101448u550ea4b2q6bc82c7dc303d693@mail.gmail.com> (raw)
In-Reply-To: <6485A041-8698-471F-9D9C-BF3DFF0D3018@gmail.com>

On Tue, Mar 10, 2009 at 11:41 AM, Joel Reymont <joelr1@gmail.com> wrote:
>  inputDeclarations:
>  [
>    [ "Input"; ":";
>      l = LIST1 inputDeclaration SEP "," -> l
>    ]
>  ];
>
> Is it always necessary to write [ x = inputDeclaration -> x ] instead of
> just inputDeclaration?

I don't think this is ever necessary (although in the back of my mind
I have a fuzzy recollection that somewhere in the docs / wiki it says
that it is). I can't say why you got a type error one way but not the
other.

For debugging types, you might find it helpful to look at the output
of the preprocessing step, which has various type annotations.

> By the same token, can I shorten the gramar below to just [ openStatement |
> closedStatement ]?
>
>  statement: [ [ s = openStatement -> s | s = closedStatement -> s ] ];

Syntactically it is fine but I don't think this is going to do what
you want. Camlp4 parsers aren't backtracking; you have to distinguish
openStatement from closedStatement by parsing a token. Otherwise
you'll always follow the openStatement branch, then get a parse error
if the stream wasn't actually parseable as an openStatement. (I think
this is correct but it has been a few months since I worked on a
grammar, sorry if I remembered it wrong.)

Jake


  reply	other threads:[~2009-03-10 21:48 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 ` Jake Donham [this message]
2009-03-10 22:07   ` [Caml-list] " Joel Reymont
2009-03-10 23:01     ` Jake Donham
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=c7e4e9f0903101448u550ea4b2q6bc82c7dc303d693@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).