title: Rule variables in ANTLR4
body: <p>I'm trying to convert my grammar from v3 to v4 and having some trouble.</p>
  
  <p>In v3 I have rules like this:</p>
  
  <pre><code>dataspec[DataLayout layout] returns [DataExtractor extractor]
      @init {
          DataExtractorBuilder builder = new DataExtractorBuilder(layout);
      }
      @after {
          extractor = builder.create();
      }
      : first=expr { builder.addAll(first); } (COMMA next=expr { builder.addAll(next); })* 
      ;
  
  expr returns [List&lt;ValueExtractor&gt; ext]
      ...
  </code></pre>
  
  <p>However, with rules in v4 returning these custom context objects instead of what I explicitly told them to return, things are all messed up. What's the v4 way to do this?</p>