title: Getting the index of an attribute in parser in antlr4
body: <p>I have a grammar which looks like</p>
  
  <pre><code>statement
       :  ME second_part
       {
             System.out.println($ME.getStartIndex());
             System.out.println($second_part.getStartIndex());
       }
       ;
  
  ME   : 'me'
       ;
  SPACES : [ \t\n\r] -&gt; channel(HIDDEN);
  </code></pre>
  
  <p>I want to get the start indices of Me and second_part. </p>
  
  <p>I am getting an error when I run the above antlr4 grammar</p>
  
  <blockquote>
    <p>System.out.println($second_part.getStartIndex());</p>
    
    <p>missing attribute access on rule reference second_part in $second_part</p>
  </blockquote>
  
  <p>How can I get starting index of second_part ?</p>