title: ANTLR parsing MismatchedTokenException
body: <p>I'm trying to write a simple parser for an even simpler language that I'm writing. It's composed of postfix expressions. As of now, I'm having issues with the parser. When I run it on the input <code>2 2 * test &gt;&gt;</code> I get a MismatchedTokenException.</p>
  
  <p>Also, how would I go about implementing a recursive postfix parser?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>grammar star;
  
  options {
      language=Python;
      output=AST;
      ASTLabelType=CommonTree;
  }
  
  tokens {DECL;}
  //start
  //  :   decl ;
  //decl
  //  :   type ID -&gt; ^(DECL type ID)
  //  ;
  
  program
      :   (body)+
      ;
  
  body    :   (nested WS)*
      |   (var WS)*
      |   (get WS)*
      ;
  
  var
      :   nested ID '&gt;&gt;'
      ;
  
  get
      :   ID '&lt;&lt;'
      ;
  
  //expressions
  
  term
      :   INT
      ;
  
  expr
      :   term (term operator)*
      ;
  
  nested
      :   expr (expr operator)*
      ;
  
  operator 
      :   ('*' | '+' | '/' | '%' | '-')
      ;
  
  ID
      :   ('a'..'z' | 'A'..'Z') ('a..z' | '0'..'9' | 'A'..'Z')*
      ;
  
  INT
      :   '0'..'9'+
      ;
  
  WS
      :   (' ' | '\n' | '\t' | '\r') {$channel=HIDDEN;}
      ;
  </code></pre>