caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* camlp5 parsing question
@ 2009-10-14 15:27 Aaron Bohannon
  0 siblings, 0 replies; only message in thread
From: Aaron Bohannon @ 2009-10-14 15:27 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-10-14 15:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-14 15:27 camlp5 parsing question Aaron Bohannon

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).