title: Antlr4 - matching an identifier as a single token
body: <pre><code>BLOCK_COMMENT : '/*' .*? '*/' -&gt; skip;
  EOL_COMMENT : '//' ~[\r\n]* -&gt; skip;
  WS: [ \n\t\r]+ -&gt; skip;
  
  program: usingDirectives? EOF;
  
  usingDirectives: usingDirective+;
  
  usingDirective: USING
          fullyQualifiedType
          (usingAlias | USING_ALL)?
          END;
  
  USING: 'using';
  
  fullyQualifiedType: identifier (DOT identifier)*;
  
  identifier: (LETTER | UNDERSCORE)
          (LETTER | DIGIT | UNDERSCORE)*;
  
  DOT: '.';
  
  usingAlias: AS identifier;
  
  USING_ALL: '.*';
  
  AS: 'as';
  
  END: ';';
  
  LETTER: [a-zA-Z];
  
  DIGIT: [0-9];
  
  UNDERSCORE: '_';
  </code></pre>
  
  <p>This is my grammar.</p>
  
  <pre><code>using IO.Console.Print as Print;
  using IO.Console; // same as using IO.Console as Console;
  using IO.Console.*;
  </code></pre>
  
  <p>This is my test data.</p>
  
  <p>The grammar works as intended, but each letter in an identifier becomes a single token, which is a bit useless.</p>
  
  <p>If I try to make identifier a lexer rule (IDENTIFIER), then I get the following error, when running the test:</p>
  
  <pre><code>line 1:23 extraneous input 'as' expecting {'.', '.*', 'as', ';'}
  </code></pre>
  
  <p>Even if I try to have IDENTIFIER be only [a-zA-Z], without subrules, the same happens.</p>
  
  <p>If it matters, I'm using Python3 as the target language.
  Please point out any other rookie mistakes as well, as this is my first project using Antlr. Thanks!</p>