title: How to ignore the next X tokens in antlr?
body: <p>I'm trying to model a language using the ANLTR syntax. A feature is "the next X parameters can be defaulted". Syntactically, it looks like the following:
  Consider a </p>
  
  <pre><code>f(a=1, b=2, c=3, d=4, e=5)
  </code></pre>
  
  <p>f is a function with 5 parameters a, b, c, d and e with respectively the default values 1, 2, 3, 4, 5. The language allows the user to "default the next X parameters" by specifying like so:</p>
  
  <pre><code>f(2, 3#, 10)
  </code></pre>
  
  <p>Function f here is called with a=2, b/c/d=default and e=10. As such, it is equivalent to</p>
  
  <pre><code>f(2, 2, 3, 4, 10)
  </code></pre>
  
  <p>Is there a feature in ANTLR4 where I can "skip the next X parser tree elements"? The syntactical ANTRL4 model would look something like</p>
  
  <pre><code>INT: [0-9]+;
  DEFAULT: INT'*';
  STRING; // shortened
  
  parameter: INT | DEFAULT_VALUE ((INT | DEFAULT_VALUE) ',')*
  functionCall: STRING '(' parameter* ')'
  </code></pre>
  
  <p>When I'm parsing the functionCall tokens, I'd like to parse the value of DEFAULT_VALUE and then simply skip parsing the next DEFAULT_VALUE.INT() tokens.</p>
  
  <p>The resulting tree then would look something like</p>
  
  <ul>
  <li>functioncall
  
  <ul>
  <li>parameter1 (2)</li>
  <li>parameter5 (10)</li>
  </ul></li>
  </ul>
  
  <p>instead of </p>
  
  <ul>
  <li>functioncall
  
  <ul>
  <li>parameter1 (2)</li>
  <li>DEFAULT_VALUE(3)</li>
  <li>parameter5 (10)</li>
  </ul></li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li>functioncall
  
  <ul>
  <li>parameter1 (2)</li>
  <li>parameter2 (2)</li>
  <li>parameter3 (3)</li>
  <li>parameter4 (4)</li>
  <li>parameter5 (10)</li>
  </ul></li>
  </ul>
  
  <p>Another solution is to simply model the DEFAULT_VALUE. In the parser tree, I can then just ignore the next function parameters. However, this solution will lead to an enormous amount of extra code in the conversion from the parser tree model into the object model. </p>