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

David Holroyd dave at badgers-in-foil.co.uk
Thu Mar 29 10:25:08 PDT 2007


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/


More information about the antlr-interest mailing list