title: Debug parser by printing useful information
body: <p>I would like to parse a set of expressions, for instance:<code>X[3]</code>, <code>X[-3]</code>, <code>XY[-2]</code>, <code>X[4]Y[2]</code>, etc.</p>
  
  <p>In my <code>parser.mly</code>, <code>index</code> (which is inside <code>[]</code>) is defined as follows:</p>
  
  <pre><code>index:
  | INTEGER { $1 }
  | MINUS INTEGER { 0 - $2 }
  </code></pre>
  
  <p>The token <code>INTEGER</code>, <code>MINUS</code> etc. are defined in lexer as normal.</p>
  
  <p>I try to parse an example, it fails. However, if I comment <code>| MINUS INTEGER { 0 - $2 }</code>, it works well. So the problem is certainly related to that. To debug, I want to get more information, in other words I want to know what is considered to be <code>MINUS INTEGER</code>. I tried to add print:</p>
  
  <pre><code>index:
  | INTEGER { $1 }
  | MINUS INTEGER { Printf.printf "%n" $2; 0 - $2 }
  </code></pre>
  
  <p>But nothing is printed while parsing.</p>
  
  <p>Could anyone tell me how to print information or debug that?</p>