[antlr-interest] Antlr v3 Syntax question

bryce.alcock at sungard.com bryce.alcock at sungard.com
Wed Mar 28 12:19:21 PDT 2007

Found "a" solution based on page 90 of the ANTLR book

AND B.T.W.  there is a nice little note on the side that says "new 
inversion 3"


bryce.alcock at sungard.com
Sent by: antlr-interest-bounces at antlr.org
03/28/2007 01:18 PM
        To:     antlr-interest at antlr.org
        Subject:        Re: [antlr-interest] Antlr v3 Syntax question

Ok,  i found a pretty close example on page 136 of the book, 
but that is not working for me because that seems to be at the Parse time, 
not as you are walking the AST. 


I would like to return a vector (or list for that matter of all the 
LITTERAL values whos common 
root was the given "PREDICATE" 

Here was my first attempt. 

predicate returns [java.util.Vector v]  : ^(PREDICATE LITERAL+) { 
     $v = new java.util.Vector(); 
  System.out.println("V.size is => "+$v.size()); 
  System.out.println("V.size after add is => "+$v.size()); 
  System.out.println("v is:"+$v.toString()); 


Here is the Input: 
6+6+8 in ("T","y","R") 

(COMPOUND (in (+ (+ 6 6) 8) (PREDICATE "T" "y" "R"))) 

Here is the output: 

Hello World from TestExprWalker 
V.size is => 0 
V.size after add is => 1 
v is:["R"] 
stat hello world This value will be processed =>5 

This only included the first value. 
What am I doing wrong, and is there an example I can look at. 

I Kinda looked through Terence's book and didn't find an example, 
but I am sure there is one in there somewhere. 

Thanks in advance 

Bryce Alcock 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070328/26e007e5/attachment.html 

More information about the antlr-interest mailing list