[antlr-interest] ANTLR274: Small functional extension proposal: synonym

Francis ANDRE francis.andre at easynet.fr
Tue Sep 7 04:51:14 PDT 2004


Hi Terence & all

I would like to propose you the following extension to manage simply 
synonyms. One could define in the tokens section definition some 
lexemes that abstract themself to a same token like :

tokens {
	 YES = "YES" | "Y" | "OK" | "YEAP" | "DA";
}

Since all literals above should returns the same YES token value, 
IMHO, it should be enough to generate in the Lexer something like:

void Lexer::initLiterals()
{
	literals["YES"] = 3;
	literals["Y"]= 3;
	literals["OK"] = 3;
	literals["YEAP"] 3;
	literals["DA"] = 3;
}


In fact, this will avoid to have a grammar rule that specifies all 
the alternatives to get a YES which is really the case!!


What do you think about??

Cheers

FA







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list