[antlr-interest] OO design question

Trey Spiva Trey.Spiva at embarcadero.com
Thu Jun 13 15:19:35 PDT 2002

> >>
> >> So!  How do you get a good separable chunk called an Analyzer without
> >> making the implementation fully of crappy switch-statements?  I.e., how
> >> do I use aspect programming w/o losing the polymorphism convenience?!
> >> Anybody wanna lend me some smarts?
> >
> > Have you thought about using a Visitor Pattern?
> I think a visitor is really what i'm talking about; perhaps I'm asking
> about a good way to implement it :)
Well how about this.  

public class Analyzer implements LookaheadVistor

When you want to retrieve the lookahead information make the call

GrammarElement element = <Some Grammar Element>


The GrammerElement will still be responsible of calculating the lookahead
and will be using the analyzer to calculating the lookahead.  You will also
be able to change how the lookahead is calculated by changing the
implementation of the LookaheadVistor that is used by the GrammerElement.


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

More information about the antlr-interest mailing list