Attean...writer(3pm)
π§ Attean::TreeRewriter β walk and rewrite subtrees π§
okay so this is the manual page named Attean...writer(3pm) from the User Contributed Perl Documentation collection β folded in right here near the top instead of copied as a boring header line. Bestie, we're so back. β¨
πΈ NAME πΈ
Attean::TreeRewriter β walk and rewrite subtrees. No cap, that's the whole name-and-purpose combo. π
π VERSION π
This document describes Attean::TreeRewriter version 0.035. Locked in. π
β¨ SYNOPSIS β¨
okay so here's the starter pack, bestie:
use v5.14;
use Attean;
my $w = Attean::TreeRewriter->new();
my ($rewritten, $tree) = $w->rewrite($tree, $thunk);
if ($rewritten) {
...
}
π¦ DESCRIPTION π¦
The Attean::TreeRewriter class walks the nodes of query trees and rewrites sub-trees based on handlers that have been registered before the rewriting begins. It's giving "tiny tree stylist with a group-chat agenda," and honestly? Obsessed. π
π³
π ROLES π
None. The role list is literally empty, and we respect its boundaries. πβ¨
π οΈ METHODS π οΈ
πͺ register_pre_handler( \&code )
This registers a handler that gets called for each sub-tree during tree rewriting. Bestie, that's the whole point β you hand it a coderef and it does the little tree-walk magic. π§
The function will be called as &code( $tree, $parent_node, $thunk ), where $thunk is an opaque value passed to rewrite. (Opaque = it's just a thing you pass through; don't overthink it. π)
The function must return a list ($handled, $descend, $rewritten). Here's the tea:
$handledis a boolean indicating whether the handler function rewrote the sub-tree, which is returned as$rewritten.$descendis a boolean value indicating whether the tree rewriting should continue downwards in the tree.
π rewrite( $tree, $thunk, \%seen, $parent )
Rewrites the given $tree using the registered handler functions. $thunk is passed through to each handler function. %seen is currently unused. $parent is passed through to the handler functions as the value of the pseudo-parent tree node for $tree.
Returns a list ($handled, $tree) with $handled indicating whether rewriting was performed, with the corresponding rewritten $tree. Slay. π
π BUGS π
Please report any bugs or feature requests through the GitHub web interface at <https://github.com/kasei/attean/issues>. That's the spot. Don't be shy; the issue tracker is right there. π«Ά
π SEE ALSO π
No entries are listed in this section β it's an empty little shelf, bestie. π«β¨
π AUTHOR π
Gregory Todd Williams "<gwilliams@cpan.org>" β iconic. π
π COPYRIGHT π
Copyright (c) 2014--2022 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π
okay bestie, sign-off time: this page came from perl v5.40.0, dated 2025-01-26, and it's the Attean...writer(3pm) page. Mwah! πβ¨
π¦ where this page comes from
- debian trixie: libattean-perl 0.035-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libattean-perl 0.035-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libattean-perl 0.035-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms