title: Why does this //ID pass but //DEF fails?
body: <p>I'm experimenting with the XPath using the grammar provided in the test suite and am having a problem with the path <code>//ID</code> being identified, but <code>//DEF</code> is not found. An <code>IllegalArgumentException</code> is thrown. "DEF at index 2 isn't a valid token name" Why is <code>//ID</code> matched, but <code>//DEF</code>not?</p>
  
  <pre><code>String exprGrammar = "grammar Expr;\n" +
  "prog:   func+ ;\n" +
  "func:  DEF ID '(' arg (',' arg)* ')' body ;\n" +
  "body:  '{' stat+ '}' ;\n" +
  "arg :  ID ;\n" +
  "stat:   expr ';'                 # printExpr\n" +
  "    |   ID '=' expr ';'          # assign\n" +
  "    |   'return' expr ';'        # ret\n" +
  "    |   ';'                      # blank\n" +
  "    ;\n" +
  "expr:   expr ('*'|'/') expr      # MulDiv\n" +
  "    |   expr ('+'|'-') expr      # AddSub\n" +
  "    |   primary                  # prim\n" +
  "    ;\n" +
  "primary" +
  "    :   INT                      # int\n" +
  "    |   ID                       # id\n" +
  "    |   '(' expr ')'             # parens\n" +
  "    ;" +
  "\n" +
  "MUL :   '*' ; // assigns token name to '*' used above in grammar\n" +
  "DIV :   '/' ;\n" +
  "ADD :   '+' ;\n" +
  "SUB :   '-' ;\n" +
  "RETURN : 'return' ;\n" +
  "DEF:  'def';\n" +
  "ID  :   [a-zA-Z]+ ;      // match identifiers\n" +
  "INT :   [0-9]+ ;         // match integers\n" +
   "NEWLINE:'\\r'? '\\n' -&gt; skip;     // return newlines to parser (is end-statement signal)\n" +
   "WS  :   [ \\t]+ -&gt; skip ; // toss out whitespace\n";
  
          String SAMPLE_PROGRAM =
                  "def f(x,y) { x = 3+4; y; ; }\n" +
                  "def g(x) { return 1+2*x; }\n";
  
          Grammar g2 = new Grammar(exprGrammar);
  
          LexerInterpreter g2LexerInterpreter = g2.createLexerInterpreter(new ANTLRInputStream(SAMPLE_PROGRAM));
          CommonTokenStream tokens = new CommonTokenStream(g2LexerInterpreter);
          ParserInterpreter parser = g2.createParserInterpreter(tokens);
          parser.setBuildParseTree(true);
          ParseTree tree = parser.parse(g2.rules.get("prog").index);
  
           String xpath = "//DEF";
          for (ParseTree t : XPath.findAll(tree, xpath, parser) ) {
              System.out.println(t.getSourceInterval());
          }
  </code></pre>