[antlr-interest] parser to implement an interface

Jim Idle jimi at temporal-wave.com
Wed May 25 06:53:08 PDT 2011


superclass fred;

class fred extends Parser implements MyInterface ....

Or you may find it easier to just have the superclass implement ANTLR
things like error message handling and have it contain an instance of
myInterface, which you can then call from the grammar as a helper class.
You can then use different implementations of the helper interface to do
different things:

class fred extends Parser {

 MyInterface visitor;
 void setVisitor(MyInterface visitor) { this.visitor = visitor; }
 ...

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of krithika sridhar
> Sent: Tuesday, May 24, 2011 10:09 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] parser to implement an interface
>
> Hi everybody..
>
> I am using ANTLRS plugin with eclipse n i have a combined grammar.I
> want my parser to implement an interface that i have written.I
> understand that the solution to this is to extend a class (using
> superClass option) which implements the required interface.BUT,using
> the "superClass= someClass"
> option overrides the default behaviour,which is, to extend the
> org.antlr.runtime base class Parser.So this approach,gives errors in
> the generated code.I want to extend the Parser base class, at the same
> time implement some other interface.
>
> Is that possible ?
> Thanks in advance
>
> cheers
> Krithika
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list