<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/10/05e52ba550a618e67da7434c75334d50"
  from="Aaron Bohannon &lt;bohannon@c...&gt;"
  author="Aaron Bohannon"
  date="2009-10-14T15:27:52"
  subject="camlp5 parsing question"
  prev="2009/10/67acf39883f97441f08e61ecd49a77e2"
  next="2009/10/e6a0f61ca2697ada7ca7010f2e8abae2"
  prev-thread="2009/10/67acf39883f97441f08e61ecd49a77e2"
  next-thread="2009/10/4bc02bd6c5fd4b979222038aa6a6188c"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="camlp5 parsing question">
<msg 
  url="2009/10/05e52ba550a618e67da7434c75334d50"
  from="Aaron Bohannon &lt;bohannon@c...&gt;"
  author="Aaron Bohannon"
  date="2009-10-14T15:27:52"
  subject="camlp5 parsing question">
</msg>
</thread>

<contents>
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"
    [ [ "`"; "+"; "-" -&gt; &lt;:expr&lt; 1 &gt;&gt; ]
    | [ "`"; "+"; "*" -&gt; &lt;:expr&lt; 2 &gt;&gt; ] ];

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

</contents>

</message>

