Skip to main content

Module simplify

Module simplify 

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

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::Start bodies out of Module / Grammar wrappers. Mirrors extractStart and powers Model::add_tag_content('#Document', ...) later in the chain.
simplify
Recursive normalizer.
simplify_combination
Recursively flatten same-op Group/Choice nests and collapse a singleton Group to its only member. Port of simplifyCombination.
simplify_top
Top-level simplifier. Maps simplify across each top-level form.