[antlr-interest] Why cant += be used without an "output=" option (and other Q's)

Benjamin Shropshire shro8822 at vandals.uidaho.edu
Fri Feb 15 17:00:08 PST 2008


I want to create a grammar that has a repeated term in it:

rule : red+;

Then I want to add an action to this rule that collects the red's and 
returns the list of them. Thats shouldn't be to hard:

rule returns [IList l ]:  (i += red)+ {$l = $i};

but antlr now insistent I add

options { output=template; }
or
options { output=AST; }

but both of these are worthless for my needs; 'template' turns i into a 
list of StringTemplate's and 'AST' try to do something with tree's. What 
I want is to just get a list of the things that red returns.

Is this even possible?

If it isn't that either antlr has a _serious_ design flaw or it has bean 
_seriously_ miss-marketed. This operation (parse a tree and give me, the 
user, unrestricted and direct access to the actual things that was 
parsed by the referenced rules) is the ONLY thing I was looking for when 
I found antlr. From a first pass over the documentation I got the 
impression that it would give me this. From trying to do this, I'm 
beginnings to fear that it is utterly impossible!

Seriously people, you seem to have a major problem. If antlr isn't 
supposed to do what I'm wanting it to do, why has it taken me 2 weeks to 
learn this? If antlr can do this, why haven't I yet bean able to figure 
out how? (I really hope it isn't the other possibility that antlr is 
just flat broken.)

Benjamin Shropshire





More information about the antlr-interest mailing list