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


PPIx-Regexp documentation  | view source Contained in the PPIx-Regexp distribution.

Index


NAME

Top

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

SYNOPSIS

Top

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

INHERITANCE

Top

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::Subexpression, PPIx::Regexp::Structure::Switch and PPIx::Regexp::Structure::Unknown.

DESCRIPTION

Top

This class represents a bracketed construction of some sort. The brackets 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

Top

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.

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

Top

Support is by the author. Please file bug reports at http://rt.cpan.org, or in electronic mail to the author.

AUTHOR

Top

Thomas R. Wyant, III wyant at cpan dot org

COPYRIGHT AND LICENSE

Top


PPIx-Regexp documentation  | view source Contained in the PPIx-Regexp distribution.