[antlr-interest] ANTLR274: Small functional extension proposal: synonym
Terence Parr
parrt at cs.usfca.edu
Tue Sep 7 10:50:08 PDT 2004
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
<*> 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