[stringtemplate-interest] Translation using Recursive Templates

Jones, Larry Larry.Jones at aspentech.com
Wed Aug 27 19:58:11 PDT 2008


I am translating one language to another. In the source language, I have
expressions such as (SRC A B C D) where SRC is a function ID and A..D
are other expressions. This expression must translate to an expression
like (TGT A, (TGT B, (TGT C, D))) or (TGT(TGT(TGT A, B), C, D))). (The
value of the expression is independent of the order of its arguments.) I
have already parsed the source and created an AST.
 
Because the output grammar is recursive, I attempted to recursively
invoke a template; however, I cannot determine how to terminate the
recursion correctly. For example: tgt(args) ::= <<tgt_fun(<first(args)>,
<rest(args):tgt()>)>> produces incorrect results.
 
Any thoughts on the template I need to produce this translation?
 
Thanks.
 
--

Lawrence Allan Jones
Senior Developer / Technical Advisor
Aspen Technology, Inc.
2500 CityWest Blvd. Suite 1500
Houston, Texas 77042
USA
281-504-3324 (work)
281-504-3395 (fax)
larry.jones at aspentech.com
www.aspentech.com <http://www.aspentech.com/> 

 
 	
 

This e-mail and any attachments are intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you receive this email in error please immediately notify the sender and permanently delete the original copy and any copy of any e-mail, and any printout thereof.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080827/79f747f3/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 2078 bytes
Desc: email_2_03.gif
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080827/79f747f3/attachment.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 200 bytes
Desc: email_2_04.gif
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080827/79f747f3/attachment-0001.gif 


More information about the stringtemplate-interest mailing list