ietf-openproxy
[Top] [All Lists]

RE: Decision on Rules Language

2003-09-21 12:37:43

On Sat, 20 Sep 2003, Anwar M. Haneef wrote:

I haven't had a chance to look at this properly, but I do have a suggestion 
for the if-statement:

   if-statement =
      "if" "(" expression ")" "{" code "}" /
      "if" "(" expression ")" "{" code "}" "else" "{" code "}"

should be:

   if-statement =
      "if" "(" expression ")" "{" code "}" /
      if-statement "else" "{" code "}"

Hmm... This allows for
        if () code else code else code else code
which does not make sense. You probably meant something like this:

        if-statement = if-head *if-alt [if-tail]
        if-head      = "if" "(" expression ")" "{" code "}"
        if-alt       = "elsif" "(" expression ")" "{" code "}"
        if-tail      = "else" "{" code "}"

For example:
        if (cond1) {
                ...
        }
        elsif (cond2) {
                ...
        }
        elsif (cond3) {
                ...
        }
        else {
                ...
        }

which is succinct, strict (no guessing which "if" the "else" part applies to),
and common enough (Ada, Modula, Perl, PHP):
http://merd.net/pixel/language-study/syntax-across-languages/CntrFlow.html

Did I get the grammar right?

Thanks,

Alex.

<Prev in Thread] Current Thread [Next in Thread>