[antlr-interest] template parser using antlr v3

Ymo ymo.mail at gmail.com
Mon Mar 17 16:50:57 PDT 2008


Hi.

I am having trouble creating a template parser grammar file. I am wondering
if anyone can give a boot start help.

I am trying to implement a template parsing tool using antlr v3. Basically
the template parser reads a template file and generates a java file for each
template file.The format of the template file is like this :

templateline-1
templateline-2
templateline-3
...
templateline-n

<% javacode %>

   templateline-1
   templateline-2
   templateline-3
   ...
   templateline-n

<%
   javacode
%>

templateline-1
templateline-2
templateline-3
...
templateline-n


1) javacode is anything that is propper java 2 syntax
2) javacode syntax checking is not needed ( How do i get a hold of the
javacode )
3) each templateline is converted to a system.out.println expression ( how
do i get a hold of each line in the AST ?)
4) the template parser copies verbatim the <% (.)* %> to the target java
file
5) each generated java file must be a valid java file. So the java syntax
checking is done by the compiler.
No need to do it inside the template parser.

There are similar tools out there like velocity, jamon , eclipse jet and
even stringtemplate. However each one of these tools
seems limited in one way or another.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080317/7918e70f/attachment.html 


More information about the antlr-interest mailing list