[antlr-interest] Antlr v3 Syntax question
bryce.alcock at sungard.com
bryce.alcock at sungard.com
Wed Mar 28 10:31:10 PDT 2007
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+) {
if($v==null){
$v = new java.util.Vector();
}
System.out.println("V.size is => "+$v.size());
$v.add($LITERAL.text);
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")
AST.toString....
(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/8d0725fd/attachment.html
More information about the antlr-interest
mailing list