[antlr-interest] how to allow keywords as variables

mzukowski at yci.com mzukowski at yci.com
Fri Jun 6 09:38:42 PDT 2003


That won't work because you can't feed back to the parser from the lexer
reliably because the lexer has already lexed at least k tokens ahead.

However, something like that would work inside a TokenStream filter as
described in my page http://www.codetransform.com/filterexample.html,
because all the changing would be done before the parser knows about the
token.

Monty

-----Original Message-----
From: Ruslan Zasukhin [mailto:sunshine at public.kherson.ua] 
Sent: Thursday, June 05, 2003 11:22 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] how to allow keywords as variables


on 6/6/03 1:57, mzukowski at yci.com at mzukowski at yci.com wrote:

> 2.7.2 still does not hoist, with the exception of hoisting from lexer 
> rules into the nextToken() method.
> 
> Ter's method would look like
> 
> id_or_keyword:
> ID
> |"if"
> |"else"
> ;
> 
> But this still can be cumbersome and generate lots of ambiguities 
> which you might need to straighten out with syntactic predicates.

Okay, I see.

It seems I also have hear in mp3 word about ability resolve this using stack
of context state.

What about this?

For example

    "drop" "table" { ExpectIdNow = true; }  ID

And in lexer 

    ID: 
        if( ExpectIdNow )
            then allow ID or keyword
        else 
            keywords only.

Or something such?

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------


 

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


 

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




More information about the antlr-interest mailing list