caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Aaron Bohannon <bohannon@cis.upenn.edu>
To: caml-list@yquem.inria.fr
Subject: camlp5 parsing question
Date: Wed, 14 Oct 2009 11:27:50 -0400	[thread overview]
Message-ID: <c413fcb70910140827o7022f2bcpd74b7705bd849c26@mail.gmail.com> (raw)

I don't understand why I am getting certain parse errors after
extending a grammar.  For instance, if I extend the original OCaml
grammar with these rules--

  expr: LEVEL "simple"
    [ [ "`"; "+"; "-" -> <:expr< 1 >> ]
    | [ "`"; "+"; "*" -> <:expr< 2 >> ] ];

--then when I try out the syntax, I get:

# ` + - ;;
- : int = 1
# ` + * ;;
Toplevel input:
# ` + * ;;
    ^^^
Parse error: '+' '-' expected after '`' (in [expr])

If the grammar is being left-factored according to the description in
the documentation (sec. 3.4 of
http://pauillac.inria.fr/~ddr/camlp5/doc/htmlc/grammars.html), I don't
see why these two rules should get in each other's way.  Moreover, the
base grammar defined in "pa_o.ml" seems to use rules with similarly
overlapping initial parts without any trouble.

 - Aaron


                 reply	other threads:[~2009-10-14 15:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=c413fcb70910140827o7022f2bcpd74b7705bd849c26@mail.gmail.com \
    --to=bohannon@cis.upenn.edu \
    --cc=caml-list@yquem.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).