[antlr-interest] multi-line chat messages

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Thu Apr 16 04:51:17 PDT 2009


ian eyberg wrote:
> On Wed, Apr 15, 2009 at 10:26:58AM -0700, William H. Schultz wrote:
> 
>   also I do have the current list of usernames allowed for these
> actions before I start trying to figure out what action is what;
> unfortunately since everything gets tokenized BEFORE that logic 
> happens it doesn't really help me out

Why does it have to be tokenized before that? Can't you add member 
methods  to the lexer to allow the caller to provide a list of 
usernames, and have rule code like

fragment USERNAME : ;

WORD : ALPHANUM+ {if (isUsername($text)) $type = USERNAME;} ;

I haven't checked that, and there's probably some mistakes. If usernames 
can have whitespace in, it might be harder... but I'm sure there's a way 
around it using lookaheads.

Sam (BC)



More information about the antlr-interest mailing list