ietf-mta-filters
[Top] [All Lists]

Re: "extensible" grammar

1998-01-21 08:11:38
Tim Showalter <tjs+(_at_)andrew(_dot_)cmu(_dot_)edu> writes:
This cuts over 30 lines off the formal grammar.  Anyone claiming this
reduces complexity is wrong; it merely moves it out of the parser and up a
level to where the script can't be essentially validated by the parser.

  It reduces complexity; it seperates command/argument checking from
syntactic analysis (making both simpler) while maintaining
extensibility.  (You've still got the same amount of *work*, it's just
simpler. :-)

  (Look at it this way: a C parser *could* check the useage of all of
one's function calls to standard library routines, but it'd be ugly;
it's better for it to just worry about syntax, build an abstract
syntax tree, and let some higher level check the tree and deal with
function call checking.)

  This does mean that (assuming the way I write interpreters :-), in
semantic analysis, a control-structure implementation module needs to
be passed a pointer to the previous control-structure (if the prior
element was a control-structure) so that, for example, "else" can
check that it's preceeded by an "if".  That's not a big deal at all,
though, and I love the flexiblity of being able to dynamically add
more control-structures...

Note that this also adds a couple lines for "tags", which are intended for
optional LISP-style tagged arguments.

        vacation :days 6 "I'm on vacation until Oct. 19th; bye.";

  I like this...


Ned Freed <Ned(_dot_)Freed(_at_)innosoft(_dot_)com> writes:
How do you do an if-then-else in this grammar?

  if (test) { commands } else { commands }

  (As Tim noted, trying to explain it in terms of the syntax elements
is a lose - but this should be familiar enough to people.)


  The only grammar suggestion I have is that tests in
control-structure look a lot like string-list elements, at least when
you first hit them - is there any chance we could use a different
pair of characters to bracket string-list?  Say, '[' and ']'?

  (It'd be nice if actions could take the results of tests in their
arguments; then the distinction between control-structure and action
could vanish... but as is, it's only a few extra states in one's
parser DFA to keep track of whether the current command's been
restricted to being a control-structure or not; it's not a big deal.)

  )Rob

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