[antlr-interest] ... and ANTLR Patterns

Terence Parr parrt at jguru.com
Wed May 8 08:39:56 PDT 2002


On Tuesday, May 7, 2002, at 02:21  PM, Ruslan Zasukhin wrote:
> If continue this logic...I again want remind to Terr, that I was very
> disappointed by "inheritance" of ANTLR.

Ah...the "inheritance is screwed up" guy :)  Howdy.  Long time no chat.

I think you'll find by my prior letters in this list that grammar 
inheritance cannot operate exactly like class inheritance...i even made 
a FAQ entry:

http://www.jguru.com/faq/view.jsp?EID=68255

So you are bound to be disappointed if you don't realize what is going 
on.  The crux of the problem is that if you, for example, modify what an 
expr is by subclassing then you necessarily modify the lookahead sets 
for a whole bunch of other rules.  I MUST...repeat MUST reproduce this 
rule to have it's altered lookahead sets useful to your subclass.  Rules 
whose sets do not change are also included because I was too busy to 
figure out which had changed ;)

BTW, inheritance even in java is a fancy word for "include plus 
override", right?  Just because you can see it happen in antlr shouldn't 
bother you at all.

I trust this is the last we'll hear about this? ;)

Terence

> When I have read about "inheritance" of grammar I was sure that I can 
> have
> few grammars that extend one other (like C++ classes), and I was going 
> to
> have
>
>     grammar A
>         -----> grammar B
>         -----> grammar C
>
> All in one application. I did expect to see that ANTL will generate 3
> classes:
>
>
>     class A_Parser
>     class B_Parser : public A_parser
>     class C_Parser : public A_parser
>
> Instead I have to see only B and C classes that just CONTAIN common 
> part of
> A grammar :-(
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org


 

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



More information about the antlr-interest mailing list