title: Running Antlr4 parser with lexer grammar gets token recognition errors
body: <p>I'm trying to create a grammar to parse Solr queries (only mildly relevant and you don't need to know anything about solr to answer the question -- just know more than I do about antlr 4.7).  I'm basing it on the QueryParser.jj file from solr 6.  I looked for an existing one, but there doesn't seem to be one that isn't old and out-of-date.</p>
  
  <p>I'm stuck because when I try to run the parser I get "token recognition error"s.</p>
  
  <p>The lexer I created uses lexer modes which, as I understand it means I need to have a separate lexer grammar file. So, I have a parser and a lexer file.</p>
  
  <p>I whittled it down to a simple example to show I'm seeing.  Maybe someone can tell me what I'm doing wrong.  Here's the parser (Junk.g4):</p>
  
  <pre><code>grammar Junk;
  
  options {
    language = Java;
    tokenVocab=JLexer;
  }
  
  term : TERM '\r\n'; 
  </code></pre>
  
  <p>I can't use an import because of the lexer modes in the lexer file I'm trying to create (the tokens in the modes become "undefined" if I use an import).  That's why I reference the lexer file with the tokenVocab parameter (as shown in the XML example in github).</p>
  
  <p>Here's the lexer (JLexer.g4):</p>
  
  <pre><code>lexer grammar JLexer;
  
  TERM : TERM_START_CHAR TERM_CHAR* ;
  
  TERM_START_CHAR : [abc] ;  
  TERM_CHAR : [efg] ; 
  WS  : [ \t\n\r\u3000]+ -&gt; skip;
  </code></pre>
  
  <p>If I copy the lexer code into the parser, then things work as expected (e.g., "aeee" is a term).  Also, if I run the lexer file with grun (specifying tokens as the target), then the string parses as a TERM (as expected).</p>
  
  <p>If I run the parser ("grun Junk term -tokens"), then I get:</p>
  
  <pre><code>line 1:0 token recognition error at: 'a'
  line 1:1 token recognition error at: 'e'
  line 1:2 token recognition error at: 'e'
  line 1:3 token recognition error at: 'e'
  [@0,4:5='\r\n',&lt;'
  '&gt;,1:4]
  </code></pre>
  
  <p>I "compile" the lexer first, then "compile" the parser and then javac the resulting java files.  I do this in a batch file, so I'm pretty confident that I'm doing this every time.</p>
  
  <p>I don't understand what I'm doing wrong.  Is it the way I'm running grun?  Any suggestions would be appreciated.</p>