[antlr-interest] Re: announcing 1.0.2 release of StringTemplate template engine

Terence Parr parrt at cs.usfca.edu
Wed Oct 15 22:20:20 PDT 2003


On Wednesday, October 15, 2003, at 09:51  PM, Mark D. Anderson wrote:

> --- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
>> StringTemplate is a really good example (umm...if I do say so myself)
>> of how to use ANTLR to build an interpreter (ANTLR converts templates
>> into text + trees.  To execute them, a tree parser walks the trees and
>> executes the actions, spitting out text etc...).
>
> I was hoping it might also be a really good example of how to do
> switching of token streams as a way to implement lexical states for
> embedded languages.
> That is, along the lines of  the "multilex" example in the antlr
> distribution.
>
> But instead I find a hand-written implementation in StringTemplate.java
> with  charAt(cp) ... cp++ etc.
> Surely this does not set a good example for impressionable young
> people? :)

The problem is that the delimiters are not fixed (even in length).  A 
dynamic sniffer has to look for it given zero restrictions on the 
delimiters...I'd be happy to do this more formally if you can tell me 
how to do it in ANTLR ;)

I think you'll find that the hand-built stuff only chunks the template 
and then the real ANTLR magic happens inside the $...$ chunks. :)  Did 
you see the two grammars and all that support code in 
org.antlr.language.*?  That is really what i'm talking about. :)

> In particular, for the cases where StringTemplate is going to be used 
> on
> html templates, it'd be nice to be able to be able to offer validation 
> of
> the html chunks.

That sounds like something another program can/should do...

> I don't see how delimeter escaping is done btw.

Yeah, sorry about that...a student asked me that yesterday too ;)  I 
don't know what to do when the delimiters can be *anything*.  Can you 
suggest something?

Thanks for looking at StringTemplate :)

Ter
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com link sharing, pure-n-simple




 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list