title: ANTLR: Why the invalid input could match the grammar definition
body: <p>I've written a very simple grammar definition for a calculation expression: </p>
  
  <pre><code>grammar SimpleCalc;
  
  options {
      output=AST;
  }
  
  tokens {
      PLUS  = '+' ;
      MINUS = '-' ;
      MULT = '*' ;
      DIV = '/' ;
  }
  
  /*------------------------------------------------------------------
   * LEXER RULES
   *------------------------------------------------------------------*/
  
  ID  : ('a'..'z' | 'A' .. 'Z' | '0' .. '9')+ ;
  
  WHITESPACE : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+    { Skip(); } ;
  
  /*------------------------------------------------------------------
   * PARSER RULES
   *------------------------------------------------------------------*/
  
  start: expr EOF;
  
  expr : multExpr ((PLUS | MINUS)^ multExpr)*;
  
  multExpr : atom ((MULT | DIV)^ atom )*;
  
  atom : ID
       | '(' expr ')' -&gt; expr;
  </code></pre>
  
  <p>I've tried the invalid expression <code>ABC &amp;* DEF</code> by <code>start</code> but it passed. It looks like the <code>&amp;</code> charactor is ignored. What's the problem here?</p>