title: JavaCC: encountered... Was expecting one of... error
body: <p>I'm getting this error when trying to run a parser written in JavaCC on a sample (syntactically valid) file:</p>
  
  <pre><code>Exception in thread "main" ParseException: Encountered "8;" at line 13, column 17.
  Was expecting one of:                                                        
  &lt;INT_CONST&gt; ...
  "&lt;" ...at jimpleParser.generateParseException(jimpleParser.java:2421)
  at jimpleParser.jj_consume_token(jimpleParser.java:2292)
  at jimpleParser.expr(jimpleParser.java:1038)
  </code></pre>
  
  <p>(shortened for conciseness)</p>
  
  <p>I cannot work out why it is throwing an error. "8" should be a valid token. Here is the function in question:</p>
  
  <pre><code> String expr():
  {
  Token t1 = null, t2 = null;
  String f1 = null, f2 = null, f3 = null;
  }
  
  {
  (LOOKAHEAD(3)
  f1 = imm() {System.out.println(f1);}    
  | f1 = new_expr()                       
  | t1 = &lt;LBR&gt; f2 = nonvoid_type() t2 = &lt;RBR&gt; f3 = imm()            
  {f1 = t1.image.concat(f2.concat(t2.image.concat(f3)));}
  | LOOKAHEAD(2)
  f2 = imm() t1 = &lt;INSTANCEOF&gt; f3 = nonvoid_type()
  {f1 = f2.concat(t1.image.concat(f3));}
  | f1 = invoke_expr()                        
  | LOOKAHEAD(2)
  f1 = reference()
  | LOOKAHEAD(2)
  f1 = binop_expr()
  | f1 = unop_expr())
  {return f1;}
  }
  </code></pre>
  
  <p>which should in turn call imm shown here:</p>
  
  <pre><code>String imm():
  {
  String f1 = null;
  }
  
  {
  (f1 = constant()
  | f1 = local_name())
  {return f1;}
  }
  </code></pre>
  
  <p>which should in turn call constant shown here:</p>
  
  <pre><code>String constant():
  {
  Token t1 = null, t2 = null;
  String f1 = null;
  }
  
  {
  (t1 = &lt;INT_CONST&gt; {f1 = t1.image; System.out.println(f1);}
  | t1 = &lt;FLOAT_CONST&gt; {f1 = t1.image;}
  | t1 = &lt;MIN_INT_CONST&gt; {f1 = t1.image;}
  | t1 = &lt;MIN_FLOAT_CONST&gt; {f1 = t1.image;}
  | t1 = &lt;STRING_CONST&gt; {f1 = t1.image;}
  | t1 = &lt;CLASS&gt; t2 = &lt;STRING_CONST&gt; {f1 = t1.image.concat(t2.image);}
  | t1 = &lt;NULL&gt; {f1 = t1.image;})
  {return f1;}
  }
  </code></pre>
  
  <p>8 should be an INT_CONST. Relevant token specifications are shown here:</p>
  
  <pre><code>&lt;INT_CONST: ((&lt;OCT_CONST&gt; | &lt;DEC_CONST&gt; | &lt;HEX_CONST&gt;) ("L")?)&gt;
  &lt;DEC_CONST: (&lt;DEC_DIGIT&gt;)+&gt;
  &lt;DEC_DIGIT: ["0"-"9"]&gt;
  </code></pre>
  
  <p>Any help would be much appreciated. Thanks</p>