[antlr-interest] how to allow keywords as variables
Terence Parr
parrt at jguru.com
Fri Jun 6 09:33:58 PDT 2003
On Thursday, June 5, 2003, at 11:22 PM, Ruslan Zasukhin wrote:
> 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.
Yes, something like what you have below. You can do the "state" here
or in a separate TokenStream object that manipulates the token stream,
changing "table" to ID when necessary.
Terence
>
> 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/
>
>
>
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Co-founder, http://www.peerscope.com link sharing, pure-n-simple
Lecturer in Comp. Sci., University of San Francisco
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list