[antlr-interest] += Output Option clarification
bryce.alcock at sungard.com
bryce.alcock at sungard.com
Tue Apr 3 15:10:58 PDT 2007
To the best of my knowledge I am not using that.
I have the following in my options section:
tree grammar ExprWalker;// START:stat
options {
tokenVocab=Expr;
ASTLabelType=CommonTree;
}
I changed it to the following: (I Have Included the code of what I am
trying to do....)
// START:expr
compoundExpr returns [int value, List lim] :
^(COMPOUND (lids+=condExpr)+ )
{
java.util.Iterator iter = $lids.iterator();
boolean hasException = false;
while(iter.hasNext()){
Integer nextVal = (Integer)iter.next();
if(nextVal.intValue() == FALSE){
hasException=true;
}
}
if(hasException){
$value=TRUE;
}else{
$value=FALSE;
}
}
;
And it KINDA works with 1 PROBLEM,
every time after I generate the Tree walker file, I have to go in and
change
RuleReturnScope lids = null;
to
Integer lids = null;
in a method called:
public compoundExpr_return compoundExpr() throws RecognitionException {
Otherwise it is working.
Is there some way I could fix this so that I don't have to keep doing
that.
BTW the line that was causing the java compile error is:
lids=condExpr();
and the Compile Error is :
Compiling 1 source file to /home/balcock/projects/build/classes
/home/balcock/projects/src/com/sungard/sims/[package
path....]/ExprWalker.java:225: incompatible types
found : java.lang.Integer
required: org.antlr.runtime.RuleReturnScope
lids=condExpr();
At 04:57 4/04/2007, bryce.alcock at sungard.com wrote:
>I get the following error in my TreeWalker Grammar file:
>
>error(134): ExprWalker.g:43:14: rule '+=' list labels are not
>allowed w/o output option: lids
[...]
>Can I get some clarification or direction about what I should try
>to do
>in this situation.
I think it means you need to put this at the top of your grammar
(assuming you are generating StringTemplate-based output, of
course):
options {
output = template;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070403/d943d24d/attachment-0001.html
More information about the antlr-interest
mailing list