title: Why isn't antlr 4 breaking my tokens up as expected?
body: <p>So I am fairly new to ANTLR 4.  I have stripped down the grammar as much as I can to show the problem: </p>
  
  <pre><code>grammar DumbGrammar;
  
  equation
     : expression (AND expression)*
     ;
  
  expression
     : ID
     ;
  
  
  ID : LETTER(LETTER|DIGIT)* ;
  
  AND: 'and';
  
  LETTER: [a-zA-Z_];
  DIGIT    : [0-9];
  WS : [ \r\n\t] + -&gt; channel (HIDDEN);
  </code></pre>
  
  <p>If use this grammar, and use the sample text: <code>abc and d</code> I get a weird tree with unexpected structure as shown below(using IntelliJ and ANTLR4 plug in):</p>
  
  <p><a href="https://i.stack.imgur.com/CCICw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CCICw.png" alt="enter image description here"></a></p>
  
  <p>If I simply change the terminal rule <code>AND: 'and';</code> to read <code>AND: '&amp;&amp;';</code> and then submit <code>abc &amp;&amp; d</code> as input I get the following tree, as expected:</p>
  
  <p><a href="https://i.stack.imgur.com/LaUF1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LaUF1.png" alt="enter image description here"></a></p>
  
  <p>I cannot figure out why it isn't parsing <code>"and"</code> correctly, but does parse <code>'&amp;&amp;'</code> correctly.  </p>