[antlr-interest] Duplicate members when generating code with 2 import levels in Java with ANTLR-3.1.1

Terence Parr parrt at cs.usfca.edu
Tue Oct 28 10:25:21 PDT 2008


On Oct 28, 2008, at 1:35 AM, Loring Craymer wrote:

> Ter--
>
> Indirect execution is a very weak form of polymorphism, and the  
> mechanism you describe depends on compiler type awareness.
>
> Assume that you have two versions of rule b, defined in separate but  
> included grammars
>
> b[int foo] : a b c ;  // version 1
>
> b returns int :  d e f ; // version 2
>
> These have different type signatures; in an OO system, b[int x]  
> would translate to version 1, and z = b would imply version 2.

  isn't that overloading rather than overwriting? nothing to do with  
object-oriented programming if I remember correctly.

> As you mention, interpretation depends on the message sent, and part  
> of the message are the data type expectations.

but unless you are using ML and so on,  most languages are not  
polymorphic on the argument types or the return signatures.

> On another note, ANTLR lacks the data abstractions that go with the  
> OO idea of inheritance.  The mechanism implemented in ANTLR 3 looks  
> much more like Python's module import facility than it does  
> inheritance.

Can you give an example of what you can't do with antlr's grammar  
composition that you could do with an ordinary object oriented  
language?  *the* quintessential example of polymorphism is the one I  
gave where you inherit method that calls a method overridden in the  
subclass. If your language doesn't do that, it's not polymorphic. what  
you're talking about is something totally different: parameter-based  
polymorphism or simple overloading as you describe above.
Ter


More information about the antlr-interest mailing list