[antlr-interest] Disabling overriden rule during iheritance.

Mark Bednarczyk voytechs at yahoo.com
Fri Jun 10 04:11:04 PDT 2005


Yes, I tried that and it seems to work. Excellent suggestion.

(I have funny way of answering my own questions when I type up
an email message about a question.)

Cheers,
mark...

>-----Original Message-----
>From: Ric Klaren [mailto:ric.klaren at gmail.com]
>Sent: Friday, June 10, 2005 4:29 AM
>To: Mark Bednarczyk
>Cc: antlr-interest at antlr.org
>Subject: Re: [antlr-interest] Disabling overriden rule during
>iheritance.
>
>
>On 6/10/05, Mark Bednarczyk <voytechs at yahoo.com> wrote:
>> I need to disable a lexer rule in the subclass grammar file.
>> That is B inherits from 1.
>>
>> Base class (A) contains:
>>
>> IDENT: blah blah blah...
>>
>> sub grammar file (B) overrides:
>>
>> IDENT: /* empty */
>>
>> What I really need to disable the IDENT rule since the token
>> type IDENT is assigned manually in a different way.
>
>If I understand you correctly: In grammar A you have a
>IDENT rule that
>deals with the IDENT. In grammar B you deal with IDENT
>in another rule
>and do a $setType or something with the IDENT tokentype?
>
>I'm no expert on grammar inheritance but you might try
>make the IDENT
>rule protected in the B grammar (don't know if antlr
>allows that, but
>there's no mechanism to leave rules out anycase) if it
>works then the
>IDENT rule should not be folded into the nextToken
>method of the
>lexer, which should be sufficient I think. (try it on
>a small example
>grammar where you can see if the lookahead
>calculations make sense)
>
>Cheers,
>
>Ric
>




More information about the antlr-interest mailing list