[antlr-interest] What about grammar inheritance?

Terence Parr parrt at cs.usfca.edu
Mon Dec 8 10:34:30 PST 2003


On Monday, December 8, 2003, at 12:58  AM, Ruslan Zasukhin wrote:

> on 12/8/03 10:03 AM, Silvain Piree at s.piree at enneya.com wrote:
>
>> On the antlr website, the paper "ANTLR 3 Whitepaper"
>> mentions "dropping inheritance" as one of the features of
>> ANTLR 3.
>>
>> Will there be an alternative grammar re-use mechanism
>> in ANTLR 3?

Either inheritance or delegation or something...haven't turned my 
thoughts to this yet. :)

>> We use grammar inheritance extensively to model differences
>> in language dialects (e.g. different Cobol dialects, etc.). This
>> is a feature I would not like to lose. In fact, it was one of the
>> reasons for us to go with ANTLR.
>
> I can add, that I was disappointed with the way grammar inheritance 
> made...
>
> For example, we have SQL parser for our Valentina database.
> This parser include of course EXPRESSION parsing part.
>
> But in Database we have also part, where we need ONLY EXPR part.
>
> When I have read docs of ANTLR I did expect that if I make grammars
>
>     EXPR
>     SQL : inherited from EXPR
>
>
> Then I will get 2 C++ classes
>
>     EXPR
>     {
>     }
>
>     SQL : EXPR
>     {
>
>     }

You will.

> But in second case I get just class SQL with all the same methods.
> This is NOT GOOD.

This is not possible.  It will have SQL + EXPR methods and must be this 
way as changing a rule in subclass can affect code gen for rules 
inherited from super.

Ter
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com link sharing, pure-n-simple




 

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




More information about the antlr-interest mailing list