>#foreach $element in $list $element #end
>             1      2    3     4
>
>If all directives are pluggable then there
>is nothing specific in the grammar to
>catch a #foreach $element in $list. You are basically
>looking for #anything, then a list of arguments.
>In the above example it's not possible to tell
>that (4) is in the body of the #foreach without
>giving the parser a hint i.e. the number of
>arguments to the directive. So a #foreach has
>three arguments so what follows must be the
>body of loop.

Actually, what I did in WM is a little more complicated, but this is 
close.  Each directive has a directive descriptor, which includes a list of 
argument descriptors.  Argument descriptors describe an argument, and there 
are defined types for Conditional, LValue, RValue, Keyword, Block, etc.  So 
the argument list for #foreach would be: ( LValue, Keyword("in"), RValue, 
Block )

While this solves the problem of backward compatibility in WM, it does make 
the parser more complicated.  Jason's idea of delimiting the argument list 
with ( .. ) seems to work, although you're still going to want to be able 
to say that some directives require a block (like #if and #foreach) and 
some don't (like #set.)  I think this will still require some, but fewer, 
JAVACODE productions.



--
Brian Goetz
Quiotix Corporation
[EMAIL PROTECTED]           Tel: 650-843-1300            Fax: 650-324-8032

http://www.quiotix.com

Reply via email to