[antlr-interest] ANTLR3 Capturing System.out.println

Loring Craymer lgcraymer at yahoo.com
Thu Mar 29 11:23:11 PDT 2007


Right--my version of println was intended as a
conceptual example.  Actually, I would tend more to
use a qualifiedId (construct a text string that
includes all of "System.out.println" as a
reconstructed symbol; or maybe use subtables for class
members and tables of classes) and symbol table lookup
for generic method translation.  

--Loring

--- David Holroyd <dave at badgers-in-foil.co.uk> wrote:

> On Thu, Mar 29, 2007 at 11:56:16AM -0400, Kailey
> Joanette wrote:
> > That particular set of code does not work. LA
> doesn't exist.  And
> > doing input.LA doesn???t work either because ...
> well apparently that
> > returns an int...
> 
> It's input.LT(1).getText() I think.
> 
> 
> > -----Original Message-----
> > From: Loring Craymer [mailto:lgcraymer at yahoo.com] 
> > Sent: March 29, 2007 10:06 AM
> > To: Kailey Joanette; 'F????rat" "K?????????????K'
> > Cc: antlr-interest at antlr.org
> > Subject: Re: [antlr-interest] ANTLR3 Capturing
> System.out.println
> > 
> > Kailey--
> > 
> > You want to use semantic predicates here, not
> > keywords, for names.  That is, try
> > 
> > println
> >     :
> >     {LA(1).getText().equals("System") &&
> > LA(3).getText().equals("println"} => ID
> >     DOT ID
> >     LPAREN
> >     outputExpression
> >     RPAREN
> >     ;
> > 
> > Still better is to use a symbol table for
> functions to
> > be translated (still using sempreds for
> > identification).
> > 
> > --Loring
> > 
> > 
> 
> -- 
> http://david.holroyd.me.uk/
> 



 
____________________________________________________________________________________
Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097


More information about the antlr-interest mailing list