[antlr-interest] ANTLR 3 output=AST for tree parser?

Mark Bednarczyk voytechs at yahoo.com
Mon Feb 26 06:31:35 PST 2007


I'm sure Terrence will come up with something. I am perfectly content with
the way it works now. 

The one thing that really threw me off is when you don't set the
"output=template" in the tree grammar. The return type then changes
depending on what you declare in the rule. Basically 1 change in one rule,
would suddenly create a number of compile errors in the generated Java
walker because return type would change from void, to a single return value,
to a rulename_return structure.

Setting the "output=template" forces all rules to return a consistent
"rulename_return" class that contains the .st field for the template and
aadditional fields for whatever your specific return values are. It may be
less efficient for cases when you don't need anything returned, but its
consistent. Cost me a bit of debugger time to get that pinned down.

Cheers,
mark...

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org 
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Kay Roepke
> Sent: Monday, February 26, 2007 9:20 AM
> To: mark at slytechs.com
> Cc: 'ANTLR Interest'; FranklinChen at cmu.edu
> Subject: Re: [antlr-interest] ANTLR 3 output=AST for tree parser?
> 
> 
> On Feb 26, 2007, at 3:14 PM, Mark Bednarczyk wrote:
> 
> > So in essence, I rely on tree walker rules to do the 
> matching and get 
> > me in the right place of the AST, the action code to do any 
> processing 
> > and rewrites and then rewrite "->" to produce the templates in the 
> > last phase of the processing.
> 
> Yeah, that's the way to do it right now. In the future it'd 
> be awesome to do tree transformations by having some syntax for it :)
> 
> cheers,
> -k
> 
> --
> Kay Röpke
> http://classdump.org/
> 
> 
> 
> 
> 




More information about the antlr-interest mailing list