[antlr-interest] Passing information from main program to lexer, parser and tree walker

Alexandre Porcelli porcelli at uol.com.br
Tue Jun 5 16:43:05 PDT 2007


Yes you can... Just to keep it clear: this solution will not enable
you to control the Lexer states with Parser information...
This solution is a simple way to share data...

On 6/5/07, Cameron Esfahani <dirty at apple.com> wrote:
> > So, for example, I could create an InformationBuffer class, and then add a
> > setInformationBuffer/getInformationBuffer pair of routines
> > to the lexer, parser and tree walker.
> >
> > After creating the lexer, parser and tree walker, I can call
> > setInformationBuffer() to pass them the relevant information:
> >
> >  ANTLRInputStream input = new ANTLRInputStream( System.in );
> >
> >  // create a lexer that feeds off of input CharStream
> >  TLexer lexer = new TLexer( input );
> >
> >  .....
> >  lexer.setInformationBuffer( info );
> >
> > Something like that?
> >
> >
> > On Jun 5, 2007, at 4:24 PM, Alexandre Porcelli wrote:
> >
> >
> > You can create some set and get methods using the members directive
> >
> > (http://www.antlr.org/wiki/display/ANTLR3/Migrating+from+ANTLR+2+to+ANTLR+3#MigratingfromANTLR2toANTLR3-Codesectionformembersmustnowbelabelled).
> >
> > So... using the get and sets you can pass data from a class to other.
> >
> > Cameron Esfahani
> > dirty at apple.com
> >
> > "You only live once, and the way I live, once is enough"
> >
> > Frank Sinatra
> >
> >
> >
> >
>


More information about the antlr-interest mailing list