You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Jason van Zyl <jv...@periapt.com> on 2000/09/07 23:27:31 UTC

Re: [Webmacro] development proejct: parser

On Thu, 7 Sep 2000, Lane Sharman wrote:

> Greetings,
> 
> Would it be possible Justin for you to collaborate with Jason(subject to his 
> willingness, of course) to accomplish this
> project for WM?

I'm totally for this! Here is a little snippet of the plan:

Velocity has a Processor interface, and a Processor houses
a set of tools for parsing a template, and creating a
parse tree that can be used by the introspection
engine and caching systems.

A Processor can also be configured to use multiple
syntaxes.

So right now I have a JavaCCProcessor that can parse
WM style templates, and an experimental syntax that
I'm playing with.

Bob McWhirter and I have been discussing the creation
of a Handler similiar to that in Apache. So a Handler
would consist of a Processor and a syntax. So, say
for all files that have .wm extension use the
JavaCCProcessor + WebMacro syntax.

So anyone can make a parser and tree walkers
in any fashion they like, as long as the
resultant parse tree adheres to an interface.
Bob and I are still working on this but that's
the general idea.

So within the same system you might have a
handler for .wm files and .vm files.

I am only interested in working on a couple
of syntaxes, but I think it would be great
to be able to accomodate other templating
systems like Tea, or whatever else. Once
the info is parsed and in a generic parse
tree then we can use a set of common tools
to manipulate the parse tree into a cached
or compiled format or whatever.

The over head might be slightly higher
providing this sort of abstracted mechanism
but a template won't be parsed all that
often, the cached/compiled version will be used
most of time. So I think the slight
bit of overhead is worth it to provide
the flexibility of using a parser generator
tool of your choice and being able
to create new syntaxes if you wish.

For example you might come up with a very
simple syntax that fits your specific
purpose and is constructed in such a way
that it can be compiled. We hope to
provide some sort of analysis engine
that can determine this. If it can't be
because of introspection constraints
then it will fall back to a caching
type system.

The use of different processors already
works, and by the end of the day I will
have a syntax for WM, and for Velocity.
That's what I'm working on now. Bob
and I will be chatting tonight what
format will be used for the intermediate
parse tree. We might use the AST
provided by Antlr. I don't know yet.

Like I said I will only be working on
the WM and Velocity syntax, but anyone
else can do whatever they want. I'm
sure we will come to settle on a standard
syntax but I would like to allow easy
migration from all other template
systems to Velocity.

But the short answer is that WM could
take the parsing system out of Velocity
and walk the parse tree generated to
create a format that can be fed directly
into the WM introspection engine.

jvz.

-- 

Jason van Zyl
jvanzyl@periapt.com