title: Mismatched input error in simple antlr4 grammar
body: <p>I'm trying to parse a simple subset of SQL using antlr4.</p>
  
  <p>My grammar looks like this:</p>
  
  <pre><code>grammar Query;
  query : select;
  select : 'select' colname (','  colname)* 'from' tablename;
  colname : COLNAME;
  tablename : TABLENAME;
  COLNAME: [a-z]+ ;
  TABLENAME : [a-z]+;
  WS : [ \t\n\r]+ -&gt; skip ; // skip spaces, tabs, newlines
  </code></pre>
  
  <p>I am testing this with a simple java application as follows:</p>
  
  <pre><code>import java.io.ByteArrayInputStream;
  import java.io.InputStream;
  
  import org.antlr.v4.runtime.*;
  import org.antlr.v4.runtime.tree.*;
  
  public class Test {
      public static void main(String[] args) throws Exception {
          // create a CharStream that reads from standard input
  
          InputStream is = new ByteArrayInputStream("select one,two ,three from table".getBytes());
  
          ANTLRInputStream input = new ANTLRInputStream(is);
  
          // create a lexer that feeds off of input CharStream
          QueryLexer lexer = new QueryLexer(input);
  
  
          // create a buffer of tokens pulled from the lexer
          CommonTokenStream tokens = new CommonTokenStream(lexer);
  
          // create a parser that feeds off the tokens buffer
          QueryParser parser = new QueryParser(tokens);
  
          ParseTree tree = parser.query(); // begin parsing at init rule
  
          System.out.println(tree.toStringTree(parser)); // print LISP-style tree
  
      }
  }
  </code></pre>
  
  <p>The output I get is as follows:</p>
  
  <pre><code>line 1:27 mismatched input 'table' expecting TABLENAME
  (query (select select (colname one) , (colname two) , (colname three) from (tablename table)))
  </code></pre>
  
  <p>What I don't understand is why the parser seems to be picking up "table" as the tablename in the parser tree, but yet I'm also getting an error thrown. What am I missing?</p>
  
  <p>Thanks</p>
  
  <p>Andrew</p>