I fixed the issue. I just had to remove the <init> attribute from ByteCode.stg. In the PDF version of the book, it it is correct. But if you download the code from this link: http://media.pragprog.com/titles/tpantlr/code/templates/generator/2pass/ByteCode.stg
or the zip/tar file on the book's website, 2 extra and useless <init> attributes are included in the stg file. Regards. ------- Hi, I'm trying to run the files in \templates\generator\2pass. I haven't changed anything code related. I created a new project in Eclipse, added the files in a new package, and compiled them. They compiled fine, but when I give them any input like 2+4*3, they give the following error: Exception in thread "main" java.util.NoSuchElementException: no such attribute: init in template context [jasminFile] at org.antlr.stringtemplate.StringTemplate.checkNullAttributeAgainstFormalArguments(StringTemplate.java:1311) at org.antlr.stringtemplate.StringTemplate.getAttribute(StringTemplate.java:684) at org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:360) at org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:136) at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:84) at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149) at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705) at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1670) at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1661) at strt.Test.main(Test.java:37) Is there something missing in the code or I'm doing something wrong? Regards. 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.
