[antlr-interest] Q re disambiguating tokens

Gerald B. Rosenberg gbr at newtechlaw.com
Sat May 28 12:29:55 PDT 2005


Cannot seem to find the way of distinguishing lexer tokens defined by 
different strings.

Given a lexer spec:

options
{
     k = 10;
     filter = false;
}

ABBREV:
	( "rangle"
	| "langle"
	)
;

WORDS:
	( '\41'..'\377' )+
;

WS: -- standard definition -- ;


If the lexer input text stream contains the word 'ranges', I get a lexer 
exception of expecting 'l', found 'e'

If I set filter=true, I get a WORDS token containing only the string "s", 
which is the unconsumed part of the input stream.

My desired output is a WORDS token containing "ranges".

Is there a way to get the lexer to compare against entire token strings; 
that is, to do a look ahead on the input stream?

Thanks.
----
Gerald B. Rosenberg, Esq.
NewTechLaw
285 Hamilton Avenue, Suite 520
Palo Alto, CA  94301-2576

650.325.2100  (office)  /  650.703.1724  (cell)
650.325.2107  (fax)

www.newtechlaw.com




More information about the antlr-interest mailing list