PPIx::Regexp::Structure(3pm)

NAME
PPIx::Regexp::Structure - Represent a structure.

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

INHERITANCE
"PPIx::Regexp::Structure" is a PPIx::Regexp::Node.

"PPIx::Regexp::Structure" is the parent of PPIx::Regexp::Structure::Assertion, PPIx::Regexp::Structure::BranchReset, PPIx::Regexp::Structure::Capture, PPIx::Regexp::Structure::CharClass, PPIx::Regexp::Structure::Code, PPIx::Regexp::Structure::Main, PPIx::Regexp::Structure::Modifier, PPIx::Regexp::Structure::Quantifier, PPIx::Regexp::Structure::Script_Run, PPIx::Regexp::Structure::Subexpression, PPIx::Regexp::Structure::Switch and PPIx::Regexp::Structure::Unknown.

DESCRIPTION
This class represents a bracketed construction of some sort. The brackets are considered part of the structure, but not inside it. So the elements() method returns the brackets if they are defined, but the children() method does not.

METHODS
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.

  elements
This override returns all components of the structure, including those that define it.

  finish
 my $elem = $struct->finish();
 my @elem = $struct->finish();
 my $elem = $struct->finish( 0 );

Returns the finishing structure element. This is included in the "elements" but not in the "children".

The finishing element is actually an array, though it should never have more than one element. Calling "finish" in list context gets you all elements of the array. Calling it in scalar context gets you an element of the array, defaulting to element 0 if no argument is passed.

  start
 my $elem = $struct->start();
 my @elem = $struct->start();
 my $elem = $struct->start( 0 );

Returns the starting structure element. This is included in the "elements" but not in the "children".

The starting element is actually an array. The first element (element 0) is the actual starting delimiter. Subsequent elements, if any, are insignificant elements (comments or white space) absorbed into the start element for ease of parsing subsequent elements.

Calling "start" in list context gets you all elements of the array. Calling it in scalar context gets you an element of the array, defaulting to element 0 if no argument is passed.

  type
 my $elem = $struct->type();
 my @elem = $struct->type();
 my $elem = $struct->type( 0 );

Returns the group type if any. This will be the leading PPIx::Regexp::Token::GroupType token if any. This is included in "elements" but not in "children".

The type is actually an array. The first element (element 0) is the actual type determiner. Subsequent elements, if any, are insignificant elements (comments or white space) absorbed into the type element for consistency with the way the start element is handled.

Calling "type" in list context gets you all elements of the array. Calling it in scalar context gets you an element of the array, defaulting to element 0 if no argument is passed.

SUPPORT
Support is by the author. Please file bug reports at <https://github.com/trwyant/perl-PPIx-Regexp/issues> or in electronic mail to the author.

AUTHOR
Thomas R. Wyant, III harryfmudd at comcast dot net

COPYRIGHT AND LICENSE
Copyright (C) 2009-2023, 2025-2026 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.