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: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Kim Slattery > Sent: Tuesday, April 19, 2011 8:31 AM > To: [email protected] > 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 List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
