GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
PPIx::Regexp::Node(3) User Contributed Perl Documentation PPIx::Regexp::Node(3)

PPIx::Regexp::Node - Represent a container

 use PPIx::Regexp::Dumper;
 PPIx::Regexp::Dumper->new( 'qr{(foo)}' )->print();

"PPIx::Regexp::Node" is a PPIx::Regexp::Element.

"PPIx::Regexp::Node" is the parent of PPIx::Regexp, PPIx::Regexp::Node::Range and PPIx::Regexp::Structure.

This class represents a structural element that contains other classes. It is an abstract class, not instantiated by the lexer.

This class provides the following public methods. Methods not documented here are private, and unsupported in the sense that the author reserves the right to change or remove them without notice.

 my $kid = $node->child( 0 );

This method returns the child at the given index. The indices start from zero, and negative indices are from the end of the list, so that "$node->child( -1 )" returns the last child of the node.

This method returns the children of the Node. If called in scalar context it returns the number of children.

 print $node->contains( $elem ) ? "yes\n" : "no\n";

This method returns true if the given element is contained in the node, or false otherwise.

This method returns the elements in the Node. For a "PPIx::Regexp::Node" proper, it is the same as "children()".

 my $rslt = $node->find( 'PPIx::Regexp::Token::Literal' );
 my $rslt = $node->find( 'Token::Literal' );
 my $rslt = $node->find( sub {
     return $_[1]->isa( 'PPIx::Regexp::Token::Literal' )
         && $_[1]->ordinal < ord(' ');
     } );

This method finds things.

If given a string as argument, it is assumed to be a class name (possibly without the leading 'PPIx::Regexp::'), and all elements of the given class are found.

If given a code reference, that code reference is called once for each element, and passed $self and the element. The code should return true to accept the element, false to reject it, and ( for subclasses of "PPIx::Regexp::Node") "undef" to prevent recursion into the node. If the code throws an exception, you get nothing back from this method.

Either way, the return is a reference to the list of things found, a false (but defined) value if nothing was found, or "undef" if an error occurred.

 my $rslt = $node->find_parents( sub {
     return $_[1]->isa( 'PPIx::Regexp::Token::Operator' )
         && $_[1]->content() eq '|';
     } );

This convenience method takes the same arguments as "find", but instead of the found objects themselves returns their parents. No parent will appear more than once in the output.

This method returns a reference to the array of parents if any were found. If no parents were found the return is false but defined. If an error occurred the return is "undef".

This method has the same arguments as "find", but returns either a reference to the first element found, a false (but defined) value if no elements were found, or "undef" if an error occurred.

This method returns the first element in the node.

This method returns the first token in the node. If there is none, it returns nothing.

This method returns the last element in the node.

This method returns the last token in the node. If there is none, it returns nothing.

This method returns a true value if any of the node's children does. Otherwise it returns "undef" if any of the node's children does. Otherwise it returns a false (but defined) value.

This method returns the maximum value of "perl_version_introduced" returned by any of its elements. In other words, it returns the minimum version of Perl under which this node is valid. If there are no elements, 5.000 is returned, since that is the minimum value of Perl supported by this package.

This method returns the minimum defined value of "perl_version_removed" returned by any of the node's elements. In other words, it returns the lowest version of Perl in which this node is "not" valid. If there are no elements, or if no element has a defined "perl_version_removed", "undef" is returned.

This method returns the significant child at the given index; that is, "$node->schild(0)" returns the first significant child, "$node->schild(1)" returns the second significant child, and so on. Negative indices count from the end.

This method returns the significant children of the Node. If called in scalar context it returns the number of significant children.

Support is by the author. Please file bug reports at <https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>, <https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in electronic mail to the author.

Thomas R. Wyant, III wyant at cpan dot org

Copyright (C) 2009-2022 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

2022-03-18 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.