[antlr-interest] Reusing grammars
Ian McDonagh
ianmdev at yahoo.co.uk
Mon Feb 4 04:07:41 PST 2008
Hi all
I want to implement my own template language (like Velocity, JSP or ASP) and reuse an existing ANTLR 3.0 grammar I've written for evaluating expressions.
I might have something like this:
________________________________________
Contacts:
@foreach( getPeople(lastName) )
Name: ${Name}
@end
________________________________________
This input would be parsed to construct a template, which is made up of various nodes, which could in turn be merged with a context to produce the template output. The parsed template structure would look something like this:
#Text:"Contacts:"
#ForEach: getPeople(lastName)
|----#Text:"Name: "
|----#Expression: Name
My problem is that my expression language uses some of the same tokens I want to use in my template language, so it's difficult to use a lexical filter only (which is pretty simple with tags like '<%' and '%>').
Is it possible to parse the entire input in one pass, switching between different parsers?
With ANTLR 2.7 I could just use grammar inheritance. What to do in ANTLR 3?
Any advice would be greatly appreciated.
Thanks.
__________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080204/3ffbcacb/attachment-0001.html
More information about the antlr-interest
mailing list