[stringtemplate-interest] Does a Perl port exist? Anyone interested?

Jonathan Buhacoff jonathan at buhacoff.net
Fri Jan 2 21:05:44 PST 2009


Ok.  I started playing with the perl target and learning the tools.    
Thanks to Sam Harwell for the ST grammars.

I also had an idea to try the perl Inline::Java module for direct  
access to the the latest stringtemplate & antlr jar files.  It turned  
out to be very trivial.  I'm going to continue playing with the perl  
target, but, for now, anyone who wants to use stringtemplate from perl  
can just write something like this:

#!/usr/bin/perl
use strict;
use warnings;
use Inline
     Java => 'STUDY',
     STUDY => [ qw(
         org.antlr.stringtemplate.StringTemplate
     ) ],
     AUTOSTUDY => 1,
     PACKAGE => 'main';

my $t = org::antlr::stringtemplate::StringTemplate->new('hello $name$
');
$t->setAttribute("name","Jonathan");
my $out = $t->toString();
print $out;


This requires Inline::Java to be installed on the system, and for the  
CLASSPATH environment variable to include the antlr and stringtemplate  
jar files.

Jonathan


On Dec 2, 2008, at 10:51 AM, Terence Parr wrote:

>
> On Dec 2, 2008, at 7:52 AM, Jonathan Buhacoff wrote:
>
>> I did a quick search for a perl port on Google and CPAN and did not
>> find one.
>>
>> If it doesn't exist yet I'd like to make it.
>
> You're on :)
>
>> I think the procedure would be to take the string template grammar,
>> generate a perl target, then write the perl API and engine to use it,
>> probably by translating Terrence's Java code for StringTemplate.
>
> I'm not sure that the Perl target is up to snuff. Further, the  
> grammars in ST have to be updated to v3; they are in v2 at the  
> moment, which does not even have a Perl target. As part of my  
> sabbatical next year I will be rebuilding ST.
>
>> Or maybe I can use StringTemplate and ANTLR to make a Java-to-perl
>> source translation and then just apply it to the StringTemplate
>> sources?  I guess I'd have to de-compile any libraries that it uses  
>> so
>> I can use the translation on those sources as well.
>>
>> Jonathan
>> (part time comp sci student and perl fan looking for fun project!)
>
> I'd first take a look at the Perl target and see if it works ;) If  
> so, then perhaps build a Perl native version of ST that mimics the  
> Java version.
> Ter



More information about the stringtemplate-interest mailing list