title: Lexer to handle lines with line number prefix
body: <p>I'm writing a parser for a language that looks like the following:</p>
  
  <pre><code>L00&lt;&lt;identifier&gt;&gt;
  L10&lt;&lt;keyword&gt;&gt;
  L250&lt;&lt;identifier&gt;&gt;
  &lt;&lt;identifier&gt;&gt;
  </code></pre>
  
  <p>That is, each line may or may not start with a line number of the form <code>Lxxx..</code> ('L' followed by one or more digits) followed by an identifer or a keyword.  Identifiers are standard <code>[a-zA-Z_][a-zA-Z0-9_]*</code> and the number of digits following the <code>L</code> is not fixed.  Spaces between the line number and following identifer/keyword are optional (and not present in most cases).</p>
  
  <p>My current lexer looks like:</p>
  
  <pre><code>// Parser rules
  commands      : command*;
  command       : LINE_NUM? keyword NEWLINE
                | LINE_NUM? IDENTIFIER NEWLINE;
  keyword       : KEYWORD_A | KEYWORD_B | ... ;
  
  // Lexer rules
  fragment INT  : [0-9]+;
  LINE_NUM      : 'L' INT;
  KEYWORD_A     : 'someKeyword';
  KEYWORD_B     : 'reservedWord';
  ...
  IDENTIFIER    : [a-zA-Z_][a-zA-Z0-9_]*
  </code></pre>
  
  <p>However this results in all lines beginning with a <code>LINE_NUM</code> token to be tokenized as <code>IDENTIFIER</code>s.</p>
  
  <p>Is there a way to properly tokenize this input using an ANTLR grammar?</p>