title: "Mismatched input <EOF>" with very simple grammar
body: <p>I am quite new to ANTLR and I made the following very simple grammar:</p>
  
  <pre><code>
  grammar vsop;
  entry:
      program EOF;
  program:
      LBRACE RBRACE;
  
  LBRACE : 
      '{';
  RBRACE :
      '}';
  WS : 
      [ \t\r\n] -> skip;
  </code></pre>
  
  <p>When I try it with the input "{ }", I get the following error:
  <code>line 2:0 mismatched input 'EOF' expecting '{'</code></p>
  
  <p>Here is the Java code I use:
  <pre><code>
  public static void main(String[] args) {</p>
  
  <pre><code>    String stringToProcess = "{}";
  
      ANTLRInputStream input = new ANTLRInputStream(stringToProcess);
      vsopLexer lexer = new vsopLexer(input); 
      CommonTokenStream tokens = new CommonTokenStream(lexer);
  
      tokens.consume();
      while(!tokens.get(tokens.index()).getText().equals("EOF"))
          tokens.consume();
  
      vsopParser parser = new vsopParser(tokens);
  
      ParseTreeWalker ptw = new ParseTreeWalker();
      vsopListenerImpl vl = new vsopListenerImpl();
      ParseTree tree = parser.entry();
      ptw.walk(vl, tree);
  }
  </code></pre>
  
  <p></code></pre> (where each <code>EOF</code> are actually <code>&lt;EOF&gt;</code> and where vsopListenerImpl contains two methods "enterProgram" and "exitProgram" that only do a print on the standard output)</p>
  
  <p>It is worth noting that when I debug and take a look into the "tokens" variable, it contains the following ArrayList:
  <code>[[@0,0:0='{',&lt;1>,1:0], [@1,1:1='}',&lt;2>,1:1], [@2,2:1='EOF',&lt;-1>,1:2]]</code> (which seems to correctly represent the different tokens).</p>
  
  <p>I have read a lot of other stackoverflow questions but I still don't know why I get this error with such a simple grammar and input. </p>
  
  <p>Thank you for your help.</p>