caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Joel Reymont <joelr1@gmail.com>
Cc: O'Caml Mailing List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] camlp4: how do you write this rule?
Date: Thu, 12 Mar 2009 01:12:48 +0100	[thread overview]
Message-ID: <49B85380.5040903@ens-lyon.org> (raw)
In-Reply-To: <99DB26B3-CE30-4EC7-82E8-AB6BA775E309@gmail.com>

Joel Reymont wrote:
> I would like my expression rule to parse "1 + 2 points" as "Plus (1,
> Points 2)".
> 
> I currently have the following, with Points right-associative and at the
> bottom, but it doesn't work. Is this something that Camlp4 can handle?
> 
>     Thanks, Joel
> 
> expr:
>   [ ...
>   | LEFTA
>     [ e1 = expr; "Or"; e2 = expr -> Or (e1, e2)
>     | e1 = expr; "And"; e2 = expr -> And (e1, e2)
>     | e1 = expr; "Mod"; e2 = expr -> Mod (e1, e2)
>     | e1 = expr; "*"; e2 = expr -> Mul (e1, e2)
>     | e1 = expr; "/"; e2 = expr -> Div (e1, e2)
>     | "Not"; e = expr -> Not e
>     ]
>   | RIGHTA
>     [ e = expr; [ "Points"; "Point" ]; i = OPT instr -> Points (e, i) ]
>   ];

I'm sure you mean:

[ "Points" | "Point" ]



Martin

-- 
http://mjambon.com/


      reply	other threads:[~2009-03-12  0:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 23:21 Joel Reymont
2009-03-12  0:12 ` Martin Jambon [this message]

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=49B85380.5040903@ens-lyon.org \
    --to=martin.jambon@ens-lyon.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).