[stringtemplate-interest] cminus.g
eric nelson
wirecracker at gmail.com
Wed Oct 19 20:27:18 PDT 2005
This is my first try at understanding StringTemplate. Can anyone explain why
"program" returns something, but "declaration" does not? I'm following this
example (http://www.codegeneration.net/tiki-read_article.php?articleId=77)
and I understand that by returning StringTemplates (code), the output is
interpretted. In some places the rules return things, but other rules (such
as declaration and block) they do not.
By the way, my goal as an excercise is eventually to translate from Java
source code to Java source code. I imagine I need to modify java.g in the
spirit of cminus.g in coordination with a more advanced Java.stg. Am I on
the right track?
- e
program returns [StringTemplate code=template("program")]
: (declaration[code])+
;
declaration[StringTemplate code]
{StringTemplate f=null,v=null;}
: v=variable {code.setAttribute("globals", v);}
| f=function {code.setAttribute("functions", f);}
;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20051019/14523ae1/attachment.html
More information about the stringtemplate-interest
mailing list