[antlr-interest] Help with null tree?
Jim Idle
jimi at temporal-wave.com
Tue Apr 19 08:42:52 PDT 2011
You are probably not passing the templates up from one or more rules. You
have to set the $st that you are returning then combine the templates as
you get higher and higher up the tree until the root node.
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Kim Slattery
> Sent: Tuesday, April 19, 2011 8:31 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Help with null tree?
>
> Hi, all. I've been working on translating the language our lab has
> created
> (Hop) to Java, and I keep hitting a wall. Has anyone had experience
> with the StringTemplate returned by getTemplate() being null? When I
> debug, st inside the tree returned by the tree grammar is null, and I
> can't figure out why. Is this because there's something wrong with the
> template? Any guesses?
>
> I'm referring to code that, from Dr. Parr's books, looks like:
>
> Gen.prog_return r2 = walker.prog(parser.numOps, parser.locals);
>
> Above, the st in the start_return (or prog_return, or what is returned
> by the start rule) of r2 is null. And:
>
> StringTemplate output = (StringTemplate)r2.getTemplate();
> System.out.println(output.toString());
>
> Because st is null, the output is obviously null. My rules all seem to
> be syntactically correct. I don't understand... Any help, in certain
> or guess form, is appreciated.
>
> Kim
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address
More information about the antlr-interest
mailing list