[antlr-interest] ANTLR v4 planning stages

Scott Stanchfield scott at javadude.com
Tue Jan 19 12:49:59 PST 2010


RE Language-agnostic actions - if you treat this as a strategy pattern
(like I seem to recall you did in the antlr 2 code base) this could
work really well. What would be really cool IMNSHO:

   grammar Foo;
    foo : xxxxxx  {@doX(...); }  ;
    fee : xxxxxx  {@doY(...); }  ;

and the generators could generate a spec/interface/abstract class for
the action methods, like in Java:

  public interface FooActionStrategy {
      void doX(...);
      void doY(...);
  }

and generate

   setActionStrategy(FooActionStrategy x) {...}

that would be used in the code. All that's needed is an implementation.

If all of the action code were simple action-strategy calls, this
should be generatable in pretty much any target language. (Of course I
haven't given this much thought, but it feels pretty good OTTOMH)

-- Scott

----------------------------------------
Scott Stanchfield
http://javadude.com


More information about the antlr-interest mailing list