← Prev in month
← Prev in thread
[relax-ng] Use of attribute grammars for A.1
I think that the BNF in A.1 is equivalent to an attribute grammar with
a synthesized attribute for constructing an XML-synax grammar and an
inherited attribute for representing contexts (i.e., a set of
prefix-URI bindings).
If we use the syntax of attriute grammars, we have:
topLevel ::= preamble topLevelBody
{ topLevel.value = topLevelBody.value
topLevelBody.context = preamble.context }
preamble_1 ::=
$B&E(J
{ preamble_1.value = preamble_1.context}
| decl preamble_2
{ preamble_2.context = decl.context
preamble_1.value = preamble_2.value}
decl ::= "namespace" namespacePrefix "=" namespaceURILiteral
Constraint: xml prefix
Constraint: xml namespace URI
Constraint: duplicate declaration
{ decl.value =
bindPrefix(decl.context,
namespacePrefix.value,
namespaceURILiteral.value) }
....
Yes, this is wordy. But this is easy for me to read. Many people
already know how to read this notation. For example, see [1]
We can make the above description more compact. We can
separate equations for synthesized attributes and those
for inherited attributes. We can even omit attribute names
(i.e., "context" and "value"), since we have only one synthesized
attribute and one inherited attribute.
[1] http://www-rocq.inria.fr/oscar/www/fnc2/manual/node32.html#SECTION02400000000000000000
Makoto
← Prev in month
← Prev in thread