title: Understanding lexer rule resolution in ANTLR4
body: <p>I'm reading the ANTLR4 defenitive guide and now I'm at the section about lexer rule resolution. Here is what's written in this section:</p>
  
  <pre><code>grammar KeywordTest;
  enumDef : 'enum' '{' ... '}';
  ...
  FOR: 'for'
  ...
  ID:[a-zA-Z]; // does not match 'enum' or 'for'
  </code></pre>
  
  <blockquote>
    <p>Rule ID could also match kewords such as <code>enum</code> or <code>for</code>, which means
    there's more than one rule that could match the same
    string. [...] <strong>Literals such as <code>'enum'</code> become lexical rules and go</strong>
    <strong>immediately after the parser rules but before the explicit lexical</strong>
    <strong>rules.</strong></p>
  </blockquote>
  
  <p>What does it mean and how does it help us to resolve the potential ambiguities? I would say that a declaration like</p>
  
  <pre><code>ENUM_KEYWORD: 'enum'
  </code></pre>
  
  <p>which <code>ATNLR4</code> might use internally would be decalred right after the rule <code>enumDef: 'enum' '{' ... '}</code> and will look as follows:</p>
  
  <pre><code>enumDef: ENUM_KEYWORD '{' ... '}
  ENUM_KEYWORD: 'enum'
  </code></pre>
  
  <p>Is that exactly how ANTLR4 does things?</p>