[antlr-interest] Antlr v3 Syntax question

bryce.alcock at sungard.com bryce.alcock at sungard.com
Wed Mar 28 11:18:28 PDT 2007

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/58fda015/attachment-0001.html 

More information about the antlr-interest mailing list