title: ANTLR4 parsing error: no viable alternative at input
body: <p>I have a grammar which is obviously erroneous as parsing a simple file generates strange error messages. </p>
  
  <p>I simplified the following grammar as much as I could without altering the error (if you remove <code>'this'</code> the tree gui output of ANTLRWorks colors the token <code>int</code> of the sample file differently although the structure seems to be equal).</p>
  
  <pre><code>grammar DepClsJ_no_java_debug;
  
  module   : ( methodDecl )* ;
  
  methodDecl   : pathType Identifier '()' block ;
  
  pathType   : Identifier | 'this' ;
  
  block   : '{'
      ( localDecl ';'  )*
      ( statement  )*
      ( expr  )?
      '}'   ;
  
  localDecl   : pathType Identifier ( '=' expr )?;
  
  statement   : block | expr ';' ;
  
  expr   : dotExpr ( '=' dotExpr  )* ;    dotExpr   : Identifier ( '.' Identifier )* ;
  
  Identifier   : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ;
  </code></pre>
  
  <p>Demo code:</p>
  
  <pre><code>void main() {
      a = c;
      int b;
  }
  </code></pre>
  
  <p>ANTLRWorks 2 gives me the following error messages:</p>
  
  <pre><code>line 3:8 no viable alternative at input 'intb'
  line 3:9 mismatched input ';' expecting '()'
  </code></pre>