[antlr-interest] Creating a templating engine

Rick Mann rmann at latencyzero.com
Mon Aug 4 14:05:40 PDT 2008


I'd like to create a template language like Velocity for generating  
text from input templates. Velocity has two primary constructs:  
directives and references. A directive takes the form of a '#' at the  
start of a line, followed by keywords and expressions. A reference  
looks like '${' ID '}'. References are replaced with a string  
representation of the value to which they refer. Anything else in the  
file is passed through unchanged. Directives can demarcate multiple  
lines and conditionally or repeatedly emit the lines they contain.

Can someone give me some terminology for what this type of grammar/ 
parser is, so I can better determine where to look? Is it a filter/ 
fuzzy grammar? I don't want to discard the text found between  
references or directives, but rather accumulate it into a variable I  
can then reference (inside my parser). It seems that a filter would  
discard that.

I have the Definitive Guide, but don't really know where to look  
within it.

Are there any examples of a grammar like this that I can study?

Thanks a lot!

-- 
Rick



More information about the antlr-interest mailing list