1Attean::TreeRewriter(3)User Contributed Perl DocumentatioAnttean::TreeRewriter(3)
2
3
4

NAME

6       Attean::TreeRewriter - Walk and rewrite subtrees
7

VERSION

9       This document describes Attean::TreeRewriter version 0.025
10

SYNOPSIS

12         use v5.14;
13         use Attean;
14         my $w = Attean::TreeRewriter->new();
15         my ($rewritten, $tree) = $w->rewrite($tree, $thunk);
16         if ($rewritten) {
17               ...
18         }
19

DESCRIPTION

21       The Attean::TreeRewriter class walks the nodes of query trees and
22       rewrites sub-trees based on handlers that have been registered prior to
23       rewriting.
24

ROLES

26       None.
27

METHODS

29       "register_pre_handler( \&code )"
30           Register a handler that will be called for each sub-tree during
31           tree rewriting.
32
33           The function will be called as "&code( $tree, $parent_node, $thunk
34           )" where $thunk is an opaque value passed to "rewrite".
35
36           The function must return a list "($handled, $descend, $rewritten)".
37           $handled is a boolean indicating whether the handler function
38           rewrote the sub-tree, which is returned as $rewritten. The $descend
39           boolean value indicates whether the the tree rewriting should
40           continue downwards in the tree.
41
42       "rewrite( $tree, $thunk, \%seen, $parent )"
43           Rewrites the given $tree using the registered handler functions.
44           $thunk is passed through to each handler function.  %seen is
45           currently unused.  $parent is passed through to the handler
46           functions as the value of the pseudo-parent tree node for $tree.
47
48           Returns a list "($handled, $tree)" with $handled indicating whether
49           rewriting was performed, with the corresponding rewritten $tree.
50

BUGS

52       Please report any bugs or feature requests to through the GitHub web
53       interface at <https://github.com/kasei/attean/issues>.
54

SEE ALSO

AUTHOR

57       Gregory Todd Williams  "<gwilliams@cpan.org>"
58
60       Copyright (c) 2014--2019 Gregory Todd Williams.  This program is free
61       software; you can redistribute it and/or modify it under the same terms
62       as Perl itself.
63
64
65
66perl v5.30.0                      2019-10-31           Attean::TreeRewriter(3)
Impressum