Subject: extensions

From: Rob Earhart <[email-masked]>
Date: Thu, 1 May 1997 14:18:04 -0400 (EDT)

Just for fun, I wrote a parser for the proposed filtering language.
It's pretty simple and clean; not hard at all.  The only problem came
up while writing the code to handle extensions used by the filter that
the interpreter doesn't know about.

  While handling commands and tests defined by unknown extensions is
fairly simple (commands go to the next ';', tests to the next ',' or
unmatched ')'), dealing with control structures defined by unknown
extensions is impossible.

  You can't just give up parsing the current block - even if you're in
an IF, there might be an IF after the extension (so you can't just go
to the next ELSIF/ELSE/ENDIF), or the extension might use one of those
atoms (so you *really* can't just go to the next ELSIF/ELSE/ENDIF).
(You also can't recover to the next ';', as a control structure may
embed commands, and control structures don't end with ';'s).

  In short, you lose - an extension you don't know about is by
definition a parse error, and there's nothing to synchronize against
to let you keep parsing.

  We need to either
   a) Make the grammar more regular with respect to control structures
      (maybe a standard block syntax, like C's {}s or Lisp's ()s?),
   b) Require that control structures end with some standard
      terminator, or
   c) Forbid extension control structures.

  )Rob

---

From: Chris Newman <[email-masked]>
Date: Thu, 01 May 1997 11:47:15 -0700 (PDT)

>    c) Forbid extension control structures.

     d) Forbid extension control structures unless script also includes a
       "require <extension>" prior to their use.

I'm partial to (d).  :-)

---

From: Rob Earhart <[email-masked]>
Date: Thu, 1 May 1997 15:08:35 -0400 (EDT)

>        "require <extension>" prior to their use.

  That doesn't help.  Consider

  if support "foo" then
	require "bar"
	bar "andrew.cmu.edu" then
	    qux;
	elsif "cs.cmu.edu" then
	    baz;
        else
	    thud;
	endbar
  else
	# do it the old fashioned way
	# ...
  endif

  Okay, so there's a require.  You still lose - you have no idea what
that bar is doing.  You can't even tell that it's a control structure,
and not a command.  You don't know which else goes with your if.  It's
completely ambiguous without knowledge of the bar extension.

  In addition, that's a horrible way to design a language.  A parser
for the base language SHOULD be able to recognize any string in that
language with extensions.

  (As an aside, the example under require in the spec doesn't parse,
'cause require's a control structure, and control structures don't end
with ';'s.  :-)

  )Rob