Expand description
AST normalization. Port of RelaxNG.pm lines 397–525.
Walks the raw AST produced by super::scan under a binding context
(the enclosing <grammar> name) and:
- resolves
Ref/ParentRefqnames against the binding/parent-binding, - records every reference site in
Relaxng::uses_name(powers the “Used by:” lists in the schema docs), - registers
Elementbody patterns underRelaxng::elements, - combines
Defs into a single canonicalCombinationper qname inRelaxng::defs(withRelaxng::def_combinertracking which combiner won), tracking the singleton-element-def shortcut intoRelaxng::elementdefs/Relaxng::element_reverse_defs, - resolves
Overrides by patching the wrapped module before re-running simplify on the patched form, - preserves document-order of
Relaxng::modules.
The simplifier is shape-preserving in its return value: every input
pattern (except Override and singleton-element-defs) emerges with
the same shape but possibly-rewritten qnames and recursively
simplified bodies. Side effects on rng are the substantive output.
Functions§
- extract_
start - Recursively pull
Pattern::Startbodies out ofModule/Grammarwrappers. MirrorsextractStartand powersModel::add_tag_content('#Document', ...)later in the chain. - simplify
- Recursive normalizer.
- simplify_
combination - Recursively flatten same-op
Group/Choicenests and collapse a singletonGroupto its only member. Port ofsimplifyCombination. - simplify_
top - Top-level simplifier. Maps
simplifyacross each top-level form.