interaction between marks and aliases

Does the spec anywhere address the meaning of a grammar like the
following?

  S = -S > alias; 'a'.

It seems most plausible to read the first branch of the right-hand side
as saying that if that branch is taken, the nonterminal is hidden, which
means the alias is ignored.  Since the mark in the right-hand side of
the rule cannot be overridden by any other mark, the subtree it heads
will never be serialized as an element or attribute, so the alias can
never be used.  In this grammar, the alias thus appears to be in effect
an alternative syntax for a comment.

Note that in the following grammar, by contrast, the alias does have an
effect:

  A = S.
  -S > sentence = ^S; 'a'.

The parse trees for the sentence "a" include:

  <A>a</A>
  <A><sentence>a</sentence></A>
  <A><sentence><sentence>a</sentence></sentence></A>
  <A><sentence><sentence><sentence>a</sentence></sentence></sentence></A>
  ...

Might it be a good idea for the spec to address the interaction between
the mark and the alias explicitly?  (Or more explicitly, if anyone
chooses to argue the current text is already explicit.)

For discussion purposes, here is a straw-man proposal to change the
text:

(1) In the section on rules, after

    An alias is just a substitute name for the rule to be used at serialization:

        @alias: name.

add

    If the nonterminal is not serialized (because it is marked with
    "-"), the alias is ignored.

(2) In the section on serialization, after the sentence

    The mark comes from the use of the nonterminal in a rule if present,
    and otherwise from the definition of the rule for that nonterminal
    if it has a mark.

add

    The alias is similarly taken from the use of the nonterminal in a
    rule if present, and otherwise from the definition.

Also, change the bulleted item now reading

    - *Deleted*: all its non-attribute children, if any, are serialized
       in order.

to

    - *Deleted*: all its non-attribute children, if any, are serialized
       in order.  In this case, any alias specified is ignored.


CMSMcQ

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

Received on Monday, 6 November 2023 18:13:47 UTC