[antlr-interest] Disabling overriden rule during iheritance.

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


I'd rather not touch the underlying grammar file as its not
mine. I'm using the java.g from the antlr's "grammar" webwape.
This way I would have to manually make modifications to any
updates that are made to it by Ter and other maintainers.

I actually had to merge IDENT from the java.g into the NUM_INT
rule and assign IDENT token type manually since there were a
number of conflicts with my extended data types such as IPv6
which uses hex digites and thus overlaps with IDENT on 'a'..'f'
alpha characters. I don't know of any way to do predicates on
seperate rules so I had to merge them. It works fine.

One thing I'm trying right now is simply make an empty IDENT
rule in my overriding Lexer "protected":

protected IDENT: ;

Got rid of the warning but I'm getting strange errors in other
places now:

td  : "header"^ SEMI!
    ;

parser exception: a.npl:1:1: expecting "header", found 'header'
a.npl:1:1: expecting "header", found 'header'

If found what it was expecting and still threw an error. Doesn't
seem to be Lexer related, I must have messed up on options or
something like "testLiterals=true" or something although I think
that's a Lexer only option.

Cheers,
mark...


>-----Original Message-----
>From: antlr-interest-bounces at antlr.org
>[mailto:antlr-interest-bounces at antlr.org]On Behalf Of
>Ric Klaren
>Sent: Friday, June 10, 2005 5:36 AM
>To: ANTLR Interest
>Subject: Re: [antlr-interest] Disabling overriden rule during
>iheritance.
>
>
>On 6/10/05, Bryan Ewbank <ewbank at gmail.com> wrote:
>> Another option is to remove IDENT from the base
>grammr, then create a
>> second derived grammar defining IDENT as required.
>
>Good point, that's a better solution than going with a
>hazy method
>like the one I suggested... now where was that coffee
>machine....
>
>Cheers,
>
>Ric
>




More information about the antlr-interest mailing list