Skip to main content

Module nester

Module nester 

Source
Expand description

Converts a flat collection of matches into a nested form suitable for replacement. When there are multiple matches for a node, or that overlap, priority is given to the earlier rule. Nested matches are only permitted if the inner match is contained entirely within a placeholder of an outer match.

For example, if our search pattern is foo(foo($a)) and the code had foo(foo(foo(foo(42)))), then weโ€™ll get 3 matches, however only the outermost and innermost matches can be accepted. The middle match would take the second foo from the outer match.

Structsยง

MatchCollector ๐Ÿ”’

Functionsยง

nest_and_remove_collisions ๐Ÿ”’
try_add_sub_match ๐Ÿ”’
Attempts to add m as a sub-match of existing.