title: JavaCC Token is not matched
body: <p>I'm trying to write a parser for simple language and I got to the point where I don't know how to handle this problem. Here is my.jj file  </p>
  
  <pre><code>options
  {
    STATIC = false;
    LOOKAHEAD=2;
    //DEBUG_LOOKAHEAD = true;
    DEBUG_TOKEN_MANAGER=true;
    FORCE_LA_CHECK = true;
    DEBUG_PARSER = true;
    JDK_VERSION = "1.7";
  }
  
  PARSER_BEGIN(Parser)
  import java.io.BufferedWriter;
  import java.io.FileWriter;
  import java.io.IOException; 
  
  public class Parser{
    private static BufferedWriter bufferFileWriter;
    private static FileWriter fWriter;
  
    public static void main(String args []) throws ParseException, IOException
    {
      Parser parser = new Parser(System.in);
      fWriter = new FileWriter("result", true);
      bufferFileWriter  = new BufferedWriter(fWriter);
      parser.program();
  
      // TO DO
    }
  }
  PARSER_END(Parser)
  
  SKIP :
  {
      " "
    | "\r"
    | "\t"
    | "\n"
  }
  
  TOKEN : /* OPERATORS */
  {
      &lt; PLUS : "+" &gt;
    | &lt; MINUS : "-" &gt;
    | &lt; MULTIPLY : "*" &gt;
    | &lt; DIVIDE : "/" &gt;
    | &lt; MODULO : "%" &gt;
    | &lt; ASSIG : ":=" &gt;
    | &lt; EQUAL : "==" &gt;
    | &lt; DIFF : "!=" &gt;
    | &lt; SMALLER : "&lt;" &gt;
    | &lt; GRATER : "&gt;" &gt;
    | &lt; S_OR_EQU: "&lt;=" &gt;
    | &lt; G_OR_EQU: "=&gt;" &gt; 
  }
  
  TOKEN :  /*KEY WORDS FROM LANGUAGE */
  {
      &lt; VAR: "VAR"&gt;
    | &lt; BEGIN : "BEGIN" &gt;
    | &lt; END : "END" &gt;
    | &lt; IF : "IF" &gt;
    | &lt; ELSE : "ELSE" &gt;
    | &lt; THEN : "THEN" &gt;
    | &lt; WHILE: "WHILE" &gt;
    | &lt; DO : "DO" &gt;
    | &lt; READ : "READ" &gt;
    | &lt; WRITE : "WRITE" &gt;
    | &lt; SEMICOL : ";" &gt;
  }
  
  TOKEN :
  {
      &lt; VALUE : &lt; ID &gt; | &lt; NUMBER &gt; &gt;
    | &lt; NUMBER : (&lt; DIGIT &gt;)+ &gt;
    | &lt; #DIGIT : [ "0"-"9" ] &gt;
    | &lt; ID : (["a"-"z"])+ &gt;
  }
  
  void program():
  {}
  {
    varDeclarations()&lt; BEGIN &gt; commands() &lt; END &gt;   
  }
  
  void varDeclarations():
  {}
  {
    &lt; VAR &gt;
    {
      System.out.println("past VAR token");
    }
  
    (&lt; ID &gt;
    )+
  }
  void commands():
  {}
  { 
    (LOOKAHEAD(3)
      command())+
  }
  
  void command():
  {
    Token t;
  }
  {
    assign()
      |&lt; IF &gt;condition()&lt; THEN &gt;commands()&lt; ELSE &gt;commands()&lt; END &gt;
      |&lt; WHILE &gt;condition()&lt; DO &gt;commands()&lt; END &gt;
      |&lt; READ &gt;
      t=&lt; ID &gt;
      {
        try
        {
          fWriter.append("LOAD "+t.image);
          System.out.println("LOAD "+t.image);
        }
        catch(IOException e)
        {
        };
      }
      &lt; SEMICOL &gt;
  
      |&lt; WRITE &gt;
          t = &lt; VALUE &gt;&lt; SEMICOL &gt;
  
  }
  void assign():
  {
    Token t;
  }
  {
    t=&lt; ID &gt;
    {
    }
    &lt; ASSIG &gt;expression(t)&lt; SEMICOL &gt;
  }
  void condition():
  {}
  {
      &lt; VALUE &gt; condOperator() &lt; VALUE &gt;
  }
  void condOperator():
  {}
  {
    &lt; EQUAL &gt; | &lt; DIFF &gt; | &lt; SMALLER &gt; | &lt; S_OR_EQU &gt; | &lt; GRATER &gt; | &lt; G_OR_EQU &gt;
  }
  Token operator():
  {
    Token tok;
  }
  {
    tok=&lt; PLUS &gt;
    {
      System.out.println(tok.image);
      return tok;
    }
    |tok=&lt; MINUS &gt;
    {
      System.out.println(tok.image);
      return tok;
    }
    |tok=&lt; MULTIPLY &gt;
    {
      System.out.println(tok.image);
      return tok;
    }
    |tok=&lt; DIVIDE &gt;
    {
      System.out.println(tok.image);
      return tok;
    }
    |tok=&lt; MODULO &gt;
    {
      System.out.println(tok.image);
      return tok;
    }
  } 
  void expression(Token writeTo):
  {
    Symbol s;
    Token t1, t2, t3;
  }
  {
    t1 = &lt; VALUE &gt;
    t2 = operator()
    t3 = &lt; VALUE &gt;
    &lt; SEMICOL &gt;
  {
    if(t2.image.equals("+"))
    {
      try
      {   
        fWriter.append("ADD "+t1.image+" "+t2.image);
        System.out.println("ADD "+t1.image+" "+t2.image);
      }catch(IOException e)
      {
      }
    }
  }
  }
  </code></pre>
  
  <p>Writing to file is not important at this moment.</p>
  
  <p>And this is the text i want to parse:  </p>
  
  <pre><code>VAR
  a b
  BEGIN
    READ a ;
    READ b ;
    WHILE a != b DO
      IF a &lt; b THEN (* a &lt;-&gt; b *)
        a := a + b ;
        b := a - b ;
        a := a - b ;
      ELSE
      END
      a := a - b ;
    END
    WRITE a ;
  END
  </code></pre>
  
  <p>and this is output I get from the debugger:</p>
  
  <pre><code>mother-ship $ java Parser test
  Call:   program
  Call:   varDeclarations
  </code></pre>
  
  <p>As you can see parser enters varDeclaration method but why can't he match token  with word VAR?<br>
  I'll be grateful for any help.</p>
  
  <p>@Theodore I did as you suggest but it didn't work. Maybe I'm compiling and executing the program the wrong way?
  This is copy of my console:  </p>
  
  <pre><code>$javacc Parser.jj  
  Java Compiler Compiler Version 5.0 (Parser Generator)  
  (type "javacc" with no arguments for help)  
  Reading from file Parser.jj . . .  
  File "TokenMgrError.java" is being rebuilt.  
  File "ParseException.java" is being rebuilt.  
  File "Token.java" is being rebuilt.  
  File "SimpleCharStream.java" is being rebuilt.  
  Parser generated successfully.  
  $ javac *.java  
  $ java Parser VAR a  
  Call:   program  
  Call:   varDeclarations
  </code></pre>