<?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="2005/05/22765a7e8cfebbfa69bc0fc8128b8eee"
  from="John Skaller &lt;skaller@u...&gt;"
  author="John Skaller"
  date="2005-05-27T12:28:37"
  subject="Re: [Caml-list] Limitations on $n in ocamlyacc?"
  prev="2005/05/ecd76077d2f949effe289b3db4889044"
  next="2005/05/ec338a887ac5c965576076298f0bdb53"
  prev-in-thread="2005/05/1d9ec1b1385ff9e7fb265275c209bcd6"
  prev-thread="2005/05/b111d712efd43c4ff0ff229a8cb48558"
  next-thread="2005/05/914619567bc8ad4d6f0aea607a19afb2"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Limitations on $n in ocamlyacc?">
<msg 
  url="2005/05/9c8744a0f1459ca572a789671f250752"
  from="Alex Baretta &lt;alex@b...&gt;"
  author="Alex Baretta"
  date="2005-05-27T08:24:26"
  subject="Limitations on $n in ocamlyacc?">
<msg 
  url="2005/05/1d9ec1b1385ff9e7fb265275c209bcd6"
  from="Alex Baretta &lt;alex@b...&gt;"
  author="Alex Baretta"
  date="2005-05-27T09:02:54"
  subject="Re: [Caml-list] Limitations on $n in ocamlyacc?">
</msg>
<msg 
  url="2005/05/22765a7e8cfebbfa69bc0fc8128b8eee"
  from="John Skaller &lt;skaller@u...&gt;"
  author="John Skaller"
  date="2005-05-27T12:28:37"
  subject="Re: [Caml-list] Limitations on $n in ocamlyacc?">
</msg>
</msg>
</thread>

<contents>
On Fri, 2005-05-27 at 10:24 +0200, Alex Baretta wrote:
&gt; What is the limit on the number of token values accessible with the $n
&gt; notation in ocamlyacc semantic actions? I'm asking because I'm
&gt; consistently getting ocamlyacc errors like the following, which I can't
&gt; make sense of.
&gt; 
&gt; ocamlyacc: e - line 96 of "xcaml_dictionary_yacc.mly", $5 is unbound

This is because the symbol has no argument:

%token FRED
p: FRED { $1 } 

will give this error, but

%token&lt;int&gt; JOE

q: JOE { $1 } 

makes non-terminal q of type int, the type of JOE's argument.

It is equivalent to:

type token = 
 | FRED
 | JOE of int

then

match (x:token) with 
| FRED ?a -&gt; .. (* ERROR -- FRED is a constant constructor *)
| JOE ?a -&gt; .. (* OK -- JOE is a nonconstant constructor *)

-- 
John Skaller, skaller at users.sf.net
PO Box 401 Glebe, NSW 2037, Australia Ph:61-2-96600850 
Download Felix here: http://felix.sf.net

</contents>

</message>

