[antlr-interest] Re: more lexical determinism

howardckatz howardk at fatdog.com
Wed Dec 5 14:24:47 PST 2001

--- In antlr-interest at y..., Terence Parr <parrt at j...> wrote:

> As for distinguishing between the two kinds of words/ids, you could 
> do the following in one rule (assume Word unless you see _ or 
> digit):
> Word:	( Letter | '_'  {$setType(Identifier);}) (Letter | 
> Digit{$setType(Identifier);})*;

That didn't quite do it, I think, Doesn't the above say that anything 
starting with a Letter is a Word? But that's not what I want, since 
valid Identifiers can start with Letters too. The following should be 
legal input,

     id : word

but throws an "Unexpected token: id" error. I would guess the parser 
sees this as "Word : Word" and accordingly chokes. Or am I 
misunderstanding something?



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list