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:

  • $handled is a boolean indicating whether the handler function rewrote the sub-tree, which is returned as $rewritten.
  • $descend is 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 (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