title: ANTLR: get error line number when parsing a multi-line text
body: <p>I have the following C function to catch recognition errors thrown by ANTLR:</p>
  
  <pre><code>void recognition(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *list)
  {
      pANTLR3_PARSER parser;
      pANTLR3_EXCEPTION exception;
  
  
      parser = (pANTLR3_PARSER) (recognizer-&gt;super);
      exception = recognizer-&gt;state-&gt;exception;
  
      printf("%d\n", exception-&gt;line);   // ALWAYS PRINTS 1 (WHICH IS WRONG)
  }
  </code></pre>
  
  <p>If one parses (with ANTLR) a multi-line text that has a typo in the first line, the <code>recognition</code> function will print "1" (which is correct). However, if the typo occurs after the first line (i.e. >= 2), the <code>recognition</code> function always prints "1" (which is wrong).</p>
  
  <p>The question is: how can one print the correct line number where the parsing error is (suggestion: do I have to update the grammar to increment a specific ANTLR counter every time that it parses a new-line token)?</p>