[antlr-interest] template generation for dumb rules
Terence Parr
parrt at cs.usfca.edu
Tue Mar 25 12:07:48 PDT 2008
On Mar 25, 2008, at 10:14 AM, Grzegorz Cieslewski wrote:
> I think that the concatenating two templates would be an optimal
> solution. I have many rules that consist of 2 or more sub-rules. If
> the user does not like the default rule he can overwrite it with his
> own, which in my opinion is better than adding many simple templates
> just to get a token to print that is nested 20 rules down. Also, this
> would make it similar in behavior to the AST rewriting approach where
> you don't have to specify a rewrite rule to get a tree back.
Agreed...but what about
d : id (',' id) ';' ;
what should i produce here? In other words, when do I stop doing the
default behavior and force you to say how it works? Do i even put in
the literals into the result template? Maybe.
> Since that would change the default behavior of the ANTLR, I think
> that adding another option like "use_default_template=true" or
> something would make life easier.
Well, I'll probably just add the default behavior...now they would get
nthing so adding it would be ok, i just don't really know what answer
is yet. I suppose cat'ing each element with <stuff> template would be
ok.
Ter
More information about the antlr-interest
mailing list