Henning P. Schmiedehausen wrote:
<EMPTY STRING> <DIRECTIVE START> followed by existing <DIRECTIVE NAME>
Render FOO Macro: <MACRO BODY>
10 <PARAM>
/ <MACRO BODY>
20 <PARAM>
and the second template renders as
# <DIRECTIVE START> followed by non-existing <DIRECTIVE NAME>
foo non existing <DIRECTIVE NAME>
(10 20) <TEXT>
So the AST would be (IMHO) different depending on the existence of
'foo' in the table of valid directives (a macro creates a new
directive).
I'm not sure that you can nail this down in pure EBNF. I'm definitely
not a parser guru, though (haven't touched my dragon book in
ages). Our current parser has a mess of sprinkled in Java code and I'm
not really sure how it does it (Geir and Jason might).
Hi Henning,
antlr grammars are not pure EBNF but are very similar. I find them a
little more 'regexpy'. Secondly, I think you're getting confused by
parsing and rendering. These are two separate steps.
So, after parsing, you would get the first tree back:
<DIRECTIVE START>
<DIRECTIVE NAME>
foo
<MACRO BODY>
<PARAM>
10
<PARAM>
20
then, when you'd parsed everything, including all your #parse
directives, you'd start the render process by going back through the
trees. When you come across this part of the tree, if the foo macro has
been defined somewhere you do your macro magic, if not you output
whatever the default would be (which I think is to just treat it as text).
I'll come up with a EBNF specification of the velocity 1.4 language if
you like. I quite like doing them and it would give you a good base for
the velocity 2.0 language!
Paul.
--
*Paul Loy
Software Developer*
Tel: +44 (0) 20 7323 0323
Fax: +44 (0) 20 7580 1938
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.keteracel.com/paul
This email has been scanned by Postini.
For more information please visit http://www.postini.com