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

Kailey Joanette kaileyjo at bigbluebubble.com
Thu Mar 29 08:56:16 PDT 2007


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...

-----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




More information about the antlr-interest mailing list