[antlr-interest] Help with grammar keywords

Bryan Ewbank ewbank at gmail.com
Fri Dec 2 02:23:12 PST 2005


Hi Rick,

> Parsing: /pubs
> exception: line 1:2: unexpected char: 'p'
>
> Parsing: /pubs/
> exception: line 1:2: unexpected char: 'p'
>
> Parsing: /pubs/popular
> exception: line 1:2: unexpected char: 'p'

The first two might fail because the production for <pubsPath> requires "/"
"pubs" "/" ID, and there is no ID element in either of these inputs.  The third
might fail because the ID token is defined to recognize a sequence of digits
(no letters allowed).  This will cause

I say "might", because I find it strange tha PUBS is defined as a protected
token.  I don't use ANTLR-generated lexers, so this may be incorrect, but it
seems (from the error location reported) that "pubs" is not getting reported as
a recognized token because it's marked protected.

One thing you can do is to rebuild your parser/lexer with "-trace" and watch
what's going on.  This is usually a good way to say "wait a minute; that's
wrong..."


More information about the antlr-interest mailing list