title: antlr - preserve line number and position in tree grammar?
body: <p>Is there an easy way to add line number information to created nodes in the tree grammar?</p>
  
  <p>e.g. parser grammar</p>
  
  <pre><code>rule: a '+' b -&gt; ^(PLUS a b);
  </code></pre>
  
  <p>tree grammar:</p>
  
  <pre><code>rule: ^(PLUS a b) { print_message_with_line_number_of(a); };
  </code></pre>
  
  <p>I tried looking into a.start.token, etc., but the ones I looked at were nulls.</p>