[antlr-interest] Switching keywords

Sean Walton swalton at cs.utah.edu
Tue Sep 5 12:00:35 PDT 2006


I mean "'A' statements are embedded in 'B' programs".
Thanks for the tip.  I am using 3.0 -- would 
"input.LT(1).getText().equals("includes")}?" be a reasonable solution?
-Sean

Loring Craymer wrote:
> What do you mean by "on top of"?  Do you mean that "A" statements are 
> embedded in "B" programs?  Or that "B" compiles to "A"?
>
> If you just need to handle tokens that are keywords in one context and 
> not another, then these are best handled as
>
> keyword
>     :
>     { LT(1).getText().equals("keyword") }? TEXT
>     ;
>
> and then use "keyword" in the appropriate context.  Semantic predicate 
> hoisting is very handy, and "is a keyword only in context" is a common 
> problem.
>
> --Loring
>
>
> */Sean Walton <swalton at cs.utah.edu>/* wrote:
>
>     [This is for anyone that can answer this problem.]
>     I am building a language (B) on top of another language (A). This
>     causes a particular problem with any new reserved words defined in
>     Language B. For example, if there needs to be a reserved word
>     'set' in
>     Language B, but when in the context of Language A, 'set' still
>     needs to
>     be an identifier.
>     Does anyone have any ideas how to do this?
>     -Sean Walton
>     PS. The real development is honestly more complicated than the above:
>     there is a third language (C) involved. Why? I guess I like
>     pain.... ;)
>
>
> ------------------------------------------------------------------------
> How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call 
> rates. 
> <http://us.rd.yahoo.com/mail_us/taglines/postman8/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060905/4dd342aa/attachment.html 


More information about the antlr-interest mailing list