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

Monty Zukowski monty at codetransform.com
Tue Sep 7 12:29:27 PDT 2004


Actually this comes up more than you might think.  It wouldn't be that 
hard to do, would it?

Of course, for now, you can do that manually.

Monty

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html


On Sep 7, 2004, at 10:50 AM, Terence Parr wrote:

> Hi.  Well, that's pretty specialized.  Further, all you have to do is
> add them to the hashtable of literals with the same token type and
> it'll just work. :)
>
> Ter
> On Sep 7, 2004, at 4:51 AM, Francis ANDRE wrote:
>
>> 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
>>
>>
>>
>>
>>
>>
> --
> CS Professor & Grad Director, University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Cofounder, http://www.jguru.com
> Cofounder, http://www.knowspam.net enjoy email again!
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>



 
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