Re: Thoughts on pragmas and iXML

On Wed, Feb 12, 2025 at 04:55:20PM +0000, Bethan Tovey-Walsh scripsit:
[snip]
> If I understand you correctly, you're suggesting that the
> specification should require that pragmas are interpreted with a
> specific understanding of precedence, so that (e.g.) the pragma on the
> "animals" nonterminal has precedence over the pragmas on its children,
> "animals_1" and "animals_2", which are essentially nullified in favour
> of the pragma on their parent. Is that right?

Perhaps not quite.

I've been mostly thinking of the things that live in xsl:output or
character maps as examples of things that would be wanted in pragmas;
I'm sure there will be more, but serialization controls seem like a
really obvious use case for pragmas.

XML-natives like preserve-space or xml:lang already have place-in-the
-tree precedence rules so don't seem likely to be a problem. But
something like character mapping could easily be turned on and turned
off by the same pragma, and that pragma could properly be applied at
different points in the tree. (And not do anything at all to the parse
tree.)

I think it's obvious that more than one pragma can pertain to a single
scope. ("no more than one pragma of grammar scope" seems intuitively
obviously not on, and then by extension zero to arbitrarily many pragmas
can pertain to any particular scope available in the definition of the
grammar.) In this way it seems to me that pragmas are not so much like
comments or processing instructions, but more like namespaces. (The
"like templates" version, where one and only one pragma pertains to any
one scope, and there are rules for figuring out which one, also seems
intuitively obviously not on.)

Which makes me think there will need to be some requirement to resolve
the meaning of overlapping scope; if some equivalent of character
mapping is set and then unset several times in the same portion of the
parse tree by the same pragma pertaining to various portions of the
grammar it seems like it might be plausible to require that a given
pragma pertains to a single scope no more than once.

Exactly how you should tell which instance of a pragma might well not be
specified in ixml, but I think the general requirement that it isn't
more than one instance of the same pragma pertaining to a single scope
would generally make sense.

> As I understand it, the objection to Requirements 9 and 10 is an
> objection to the notion that implementations should have a common
> understanding of where a pragma belongs in the parse tree - i.e. which
> element of the grammar it is attached to. So there's no suggestion
> that a pragma would have no / arbitrary scope for any given processor,
> but that different processors may have different interpretations of
> scope, and that the specification should not provide any guidance on
> the matter.
[snip illustrative examples]
> Other ways of interpreting the pragma's scope are no doubt possible. A
> user would have to check each implementation's rules for establishing
> the syntactic scope of a pragma in order to read and write grammars
> with pragmas. They would also have to expect that different processors
> would produce different parse trees when generating an XML version of
> an iXML grammar including pragmas.
[snip]

Speaking as a user, anything that makes creating a general pragma-aware
grammar linter nigh-impossible like that is doing something other than
helping.

> > I think that makes sense; as a user, I would like to know what parts
> > of the grammar to which the pragma will apply, and (presumably) an
> > implementor necessarily has the same concern. Which means you have
> > to (in some informal sense) bind a pragma to a grammar construct for
> > a pragma to be useful.
> 
> Exactly - the current unresolved debate is whether the principles
> governing that binding should be established in the specification, or
> whether it should be a matter for implementations to determine their
> own set of principles.

I think an analogy from natural language may apply; one may not know
what the word means, but one would still know where to put it in a
sentence if one knew what part of speech it was. Just because a local
dialect has magic words doesn't mean "magic word" as a category isn't a
part of speech and subject to syntax rules.

[snip]
> Yes - the syntax of comments as they're currently specified is not
> optimal for pragmas in a few minor ways. A proposal for adding pragmas
> need not make pragmas a variation on comments, of course - the
> requirements document deliberately tries to avoid making any
> assumptions about the ideal syntactic form for pragmas, so that the
> design process is open to innovative suggestions.

I think that's entirely sensible, but also think that pragmas do need to
be a defined part of the ixml syntax should they be present at all; the
pragma being necessarily some fashion of part of speech distinct from
volitive interjections.

Much appreciated,
Graydon


--  
Graydon Saunders  | graydonish@fastmail.com
Þæs oferéode, ðisses swá mæg.
-- Deor  ("That passed, so may this.")

Received on Friday, 14 February 2025 00:35:47 UTC