CQL::Visitor(3pm)

πŸ“¦
version 1.13 Β· 2 versions
  • 1.13 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.13 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CQL::Visitor β€” the manual, but make it cute πŸ’–

okay bestie, welcome to CQL::Visitor(3pm), a Perl module from the User Contributed Perl Documentation crew ✨ this one is literally about walking around inside a CQL parse tree and saying hi to the nodes. no cap.


🌸 NAME 🌸

CQL::Visitor β€” visit nodes in a CQL parse tree πŸ¦‹


✨ SYNOPSIS ✨

here's the vibe, copy it exactly okay:

package MyVisitor;
use base qw( CQL::Visitor );

sub term {
    my ($self,$node) = @_;
    # do something to the node
}

# later on

my $parser = CQL::Parser->new();
my $root = $parser->parse($cql);

my $visitor = MyVisitor->new();
$vistor->visit($root);

(yes the $vistor typo is in the original, i am NOT touching it, i'm just the messenger πŸ™ˆ)


πŸ‘‘ DESCRIPTION πŸ‘‘

so, CQL::Visitor gives you a super simple interface for visiting the nodes in your parse tree. it's giving "i just want to poke around in here" energy. 🫢

it could be useful if you wanna do something like turn a query that looks like this:

dc.title=foo and dc.creator=bar

into:

title=foo and creator=bar

or literally any similar procedure, you do you. πŸ’…

the way this works: you just create a new subclass of CQL::Visitor and override the appropriate method β€” like term(), for example. every single term that gets encountered during the traversal will be handed off to your term() method. slay. ✨

note bestie: at the moment only term() is supported, because that's what was needed 😭 but if you need other ones feel free to add them, or ask for them. iconic behavior honestly.

πŸŽ€ METHODS πŸŽ€

πŸ’œ new()

the constructor, she's here, she's ready, she makes you a new visitor. 🧚

🌈 visit()

call this one to traverse your parse tree, starting right at the root. main character energy fr fr. πŸ‘‘

πŸ“ term()

your subclass should override this, and do something meaningful with the CQL::TermNode object. that's the whole assignment bestie. πŸ”₯


and that's the whole page, no notes πŸ’– this was perl v5.36.0, dated 2022-12-11 β€” shoutout to the original CQL::Visitor(3pm) footer, mwah, periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from