title: ANTLR4 error handling and ErrorNode behavior
body: <p>I have a grammar which i have simplified below to describe the issue that im facing:</p>
  
  <pre><code>eval: exp;
  exp: operand ('*'|'/') operand
      | operand ('+'|'-') operand
      | operand;
  
  operand: (function|VARIABLE);
  function: FUNCTION_NAME body? ')';
  
  body: attribute (','attribute)*;
  
  attribute: VARIABLE|function;
  FUNCTION_NAME: [a-zA-Z0-9.]+'(';
  VARIABLE: [a-zA-Z0-9._]+;
  </code></pre>
  
  <p>So basically my intention is to parse input such as:</p>
  
  <pre><code>a + min(b, c, min(d, e)) - max(f, m)
  a
  a + b
  </code></pre>
  
  <p>If the input is correct the parsing is done perfectly however the issue that im facing is related to incorrect input. For two very similar cases the AS trees constructed by the ANTLR parser are completely different. </p>
  
  <ol>
  <li><code>a + min(b, c, )</code> it creates a nice AS tree and indicates that a method parameter is missing after the second comma of <code>min</code> function.</li>
  <li><code>min(a, b, )</code> i would suspect the same output as the previous case however the parser cannot put the tokens together and are marked all as <code>ErrorNode</code>. </li>
  </ol>
  
  <p>Can anyone explain why this behavior of ANTLR parser and how does the presence/absence of an operator alter the behavior of the parser in such way?</p>