hygiene problems in grammars

If I read the text of the spec (2022-02-22) correctly, gramars are
non-conforming if if either of the following applies:
  
  - They have multiple rules for the same nonterminal.
  
  - Any nonterminal appearing on a right-hand side lacks a defining
    rule.

There are some other constraints listed in the conformance section which
need not concern us here.

It has been explained that hygiene problems frequently are signs of
trouble in the grammar and should be flagged.

The current state of play with respect to grammar hygiene troubles me
for two reasons.  First, I think a warning would be more appropriate
than an error, given that hygiene issues do not prevent parsing.  And
second, if we want to flag grammars with hygiene issues we should
probably use a more systematic and less ad hoc
them as non-conforming.


If I understand correctly, under the current spec the following are all
conforming ixml grammars.  

{ 1.  An unreferenced nonterminal other than the start symbol. }
{ B is unreachable from S and cannot contribute to any successful 
  parse. }
  S = 'a'.
  B = 'b'.
  

{ 2.  A nonterminal which is referred to but unreachable. }
{ B and C are referred to but unreachable; they cannot contribute to 
  any successful parse. }
  S = 'a'.
  B = {}; 'b', C.
  C = {}; 'c', B.

{ 3. A non-productive nonterminal. }
{ A is reachable from S but cannot contribute to any successful parse. }
  S = A; B.
  A = 'a', A.
  B = 'b'.

{ 4. Another non-productive nonterminal. }
{ A is reachable from S but cannot contribute to any successful parse. }
  S = A; B.
  A = 'a', C.
  B = 'b'.
  C = '(', A, ')'.

Grammars 1 through 4 all have rules (or, more strictly, LHS+RHS pairs)
we can class as useless, in the sense that the rule will never be
involved in any successful derivation.  If we believe that the spec
should require that grammars with hygiene problems should be rejected as
non-conforming, then why are these grammars acceptable?

Michael

-- 
C. M. Sperberg-McQueen
Black Mesa Technologies LLC
http://blackmesatech.com

Received on Saturday, 12 March 2022 19:52:32 UTC