title: In antlr4 lexer, How to have a rule that catches all remaining "words" as Unknown token?
body: <p>I have an antlr4 lexer grammar. It has many rules for words, but I also want it to create an Unknown token for any word that it can not match by other rules. I have something like this:</p>
  
  <pre><code>Whitespace : [ \t\n\r]+ -&gt; skip;
  Punctuation : [.,:;?!];
  // Other rules here
  Unknown : .+? ; 
  </code></pre>
  
  <p>Now generated matcher catches '~' as unknown but creates 3 '~' Unknown tokens for input '~~~' instead of a single '~~~' token. What should I do to tell lexer to generate word tokens for unknown consecutive characters. I also tried "Unknown: . ;" and "Unknown : .+ ;" with no results.</p>
  
  <p><strong>EDIT:</strong> In current antlr versions .+? now catches remaining words, so this problem seems to be resolved.</p>