[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Elision, or: Nick rides again in jbonai



   Date: Fri, 12 Apr 91 08:39:12 -0500
   From: dmb@bigd.cray.com
   ...
      You've raised a very good question.  ...

Thank you.  For a while there I was afraid I was flaming in thin air.

   3) In other cases (hopefully all of the rest) attempts to specify the
      elision in the grammar have resulted in complaints that the grammar
      is no longer LR(1).  Now, as you well know, non-LR(1) does not
      necessarily mean ambiguous. ...

Indeed.  Moreover, it may even be the case that the language actually
is LR(1), that is, there does exist an LR(1) grammar that specifies
it but such a grammar has not been found yet.  Part of my point is
that the attempt to find an unambiguous LR(1) grammar may yield new
insights about the grammatical structure of the language.  To refer
to the dangling-ELSE problem in C once again, I had realized that
constructions such as

	if (x > 0)
	   if (y > z) y = 3;
	else x = 4;

were ambiguous (or incorrectly parsed), but it wasn't until I set
out to make an unambiguous grammar that I realized the problem was
recursive; for example,

	if (x > 0)
	   while (y > q) switch(q) default: if (y > z) case 4: y = 3;
	else x = 4;

also exhibits the problem.  (And if you think that use of "switch" is
malformed, check the grammar!  You can find a useful example of such
a strange "switch" in "C: A Reference Manual" by Harbison and Steele,
Prentice-Hall.)  The notion of "dangling danger" as something that
was contagious from a contained statement to its container did not
become clear to me until it was forced upon me by the exercise of
constructing the grammar.  We might find lojban constructs also
falling into two general categories: those after which (before
which?) elision is permissible, and all others.  The nature of that
dichotomy is worth exploring.

--Guy Steele