title: extraneous input error using ANTLR4
body: <p>I am an ANTLR newbie and struggling with some of the errors that I am getting. Below I have included the grammar that I am using, The input file and the error that I am getting.    </p>
  
  <p><strong>My Antlr Grammar file is as follows:</strong></p>
  
  <pre><code>grammar Simple;
  
  @header
  {
  package simple;
  }
  </code></pre>
  
  <p>PARSER</p>
  
  <pre><code>program :
          anylinebefore+
          processline
          anylineafter+
          'MSEND' NEWLINE
           '.' EOF
          ;
  
  anylinebefore:  CH* NEWLINE | commentline;
  
  anylineafter:  statement | commentline;
  
  statement: movestatement ; 
  
  movestatement : 'MOVE' arg ('to' | 'TO')  ID '.' NEWLINE ;
  
  arg : ID|STRING;
  
  processline:  PROCESSLITERAL  NEWLINE; 
  
  commentline:  '!' CH* NEWLINE;
  </code></pre>
  
  <p>LEXER</p>
  
  <pre><code>WS     : [ \t]+ -&gt; skip ;
  STRING  :  '\'' (~['])* '\'';
  ID     : ('a'..'z'|'A'..'Z')+;
  INT    : '0'..'9'+;
  TO     : ('to' | 'TO');
  CH      :       [\u0000-\uFFFE];
  PROCESSLITERAL  :  'PROCESS SOURCE FOLLOWS';
  NEWLINE   : '\r'? '\n'  ;
  </code></pre>
  
  <p>My input file is as follows:</p>
  
  <pre><code>MODIFY   
           PROCESS SOURCE FOLLOWS  
  MOVE 'WSFRED' TO AGRPASSEDTWO.   
           MSEND    
           .
  </code></pre>
  
  <p>The error that I get is:</p>
  
  <pre><code>showtree:
       [java] line 1:0 extraneous input 'MODIFY' expecting {'!', CH, NEWLINE}
  </code></pre>
  
  <p>I don't understand why this isn't matching <strong>anylinebefore</strong> in the grammar
  Any help would be appreciated.</p>