[antlr-interest] Java1.5 grammar and enum as identifier and not as a keyword

Jörg Rech joerg.rech at gmail.com
Wed Jun 29 12:10:16 PDT 2005


Hi,
  maybe I got something wrong here but isn't the lexer called before the 
recognizer for the methods? So if I enter a method changes to enableEnum 
have no effect on the lexer?

Or is the lexer just registered and called by the recognizer/parser on 
demand?

Bye,
Joerg

David Ewing schrieb:

> You might be able to call JavaLexer.enableEnum(false) from an action  
> when you enter the recognition of a method, and call  
> JavaLexer.enableEnum(true) when leaving. A hack, but perhaps a useful  
> one. :)
>
> Dave
>
> On Jun 26, 2005, at 3:13 PM, Jörg Rech wrote:
>
>> Michael Studman schrieb:
>>
>>
>>> If you're not in a position to be able to change the source code  
>>> you're parsing and you can guarantee "enum" is not used as a  
>>> keyword  then you can call JavaLexer.enableEnum(false) on the  lexer 
>>> before you pass it into the recogniser.
>>>
>>
>> If you mean by "guarantee enum is not used" that I can decide  wether 
>> the class is either 1.4 or 1.5 I fear that this is not  possible. The 
>> only way I currently see is to have two different  pipelines with 
>> lexer, filter, and parser for 1.4 and 1.5 and then  parse the class 
>> first with 1.5 and if errors occur use the 1.4  pipeline.
>> I haven't tried it yet but it seems feasible (and ugly :-( )
>>
>> Thanks for your idea,
>> Joerg.
>


-- 
Joerg Rech
Computer Scientist        Web:   http://www.joerg-rech.de
Tel.: (+49|0) 631/10653   email: joerg.rech at gmail.com



More information about the antlr-interest mailing list