Re: interaction between marks and aliases

"C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com> writes:
> 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. 

I think that’s correct. My mental model for the renaming is that it’s
“part of” the name. Since S>alias will never be serialized, the fact
that it’s aliased is irrelevant.

> In this grammar, the alias thus appears to be in effect
> an alternative syntax for a comment.

For comments that consist of a single sequence of name characters, I
suppose that’s one way to look at it :-)

> 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>

Yes. A test I fail at the moment, alas. Please make a pull request to
add these tests (or tests like them) to the test suite.

> Might it be a good idea for the spec to address the interaction between
> the mark and the alias explicitly? 

Yes, I think so.

                                        Be seeing you,
                                          norm

--
Norm Tovey-Walsh
Saxonica

Received on Tuesday, 7 November 2023 13:36:16 UTC