PPIx::Regexp::Element(3)

NAME
PPIx::Regexp::Element - Base of the PPIx::Regexp hierarchy.

SYNOPSIS
No user-serviceable parts inside.

INHERITANCE
"PPIx::Regexp::Element" is not descended from any other class.

"PPIx::Regexp::Element" is the parent of PPIx::Regexp::Node and PPIx::Regexp::Token.

DESCRIPTION
This class is the base of the PPIx::Regexp object hierarchy. It provides the same kind of navigational functionality that is provided by PPI::Element.

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.

  ancestor_of
This method returns true if the object is an ancestor of the argument, and false otherwise. By the definition of this method, $self is its own ancestor.

  can_be_quantified
 $token->can_be_quantified()
     and print "This element can be quantified.\n";

This method returns true if the element can be quantified.

  class
This method returns the class name of the element. It is the same as "ref $self".

  comment
This method returns true if the element is a comment and false otherwise.

  content
This method returns the content of the element.

  descendant_of
This method returns true if the object is a descendant of the argument, and false otherwise. By the definition of this method, $self is its own descendant.

  error
 say $token->error();

If an element is one of the classes that represents a parse error, this method may return a brief message saying why. Otherwise it will return "undef".

  is_quantifier
 $token->is_quantifier()
     and print "This element is a quantifier.\n";

This method returns true if the element is a quantifier. You can not tell this from the element's class, because a right curly bracket may represent a quantifier for the purposes of figuring out whether a greediness token is possible.

  modifier_asserted
 $token->modifier_asserted( 'i' )
     and print "Matched without regard to case.\n";

This method returns true if the given modifier is in effect for the element, and false otherwise.

What it does is to walk backwards from the element until it finds a modifier object that specifies the modifier, whether asserted or negated. and returns the specified value. If nobody specifies the modifier, it returns "undef".

This method will not work reliably if called on tokenizer output.

  next_sibling
This method returns the element's next sibling, or nothing if there is none.

  parent
This method returns the parent of the element, or undef if there is none.

  perl_version_introduced
This method returns the version of Perl in which the element was introduced. This will be at least 5.000. Before 5.006 I am relying on the perldelta, perlre, and perlop documentation, since I have been unable to build earlier Perls. Since I have found no documentation before 5.003, I assume that anything found in 5.003 is also in 5.000.

Since this all depends on my ability to read and understand masses of documentation, the results of this method should be viewed with caution, if not downright skepticism.

There are also cases which are ambiguous in various ways. For those see "RESTRICTIONS" in PPIx::Regexp, and especially "Changes in Syntax" in PPIx::Regexp.

  perl_version_removed
This method returns the version of Perl in which the element was removed. If the element is still valid the return is "undef".

All the caveats to perl_version_introduced() apply here also, though perhaps less severely since although many features have been introduced since 5.0, few have been removed.

  previous_sibling
This method returns the element's previous sibling, or nothing if there is none.

  significant
This method returns true if the element is significant and false otherwise.

  snext_sibling
This method returns the element's next significant sibling, or nothing if there is none.

  sprevious_sibling
This method returns the element's previous significant sibling, or nothing if there is none.

  tokens
This method returns all tokens contained in the element.

  top
This method returns the top of the hierarchy.

  unescaped_content
This method returns the content of the element, unescaped.

  whitespace
This method returns true if the element is whitespace and false otherwise.

  nav
This method returns navigation information from the top of the hierarchy to this node. The return is a list of names of methods and references to their argument lists. The idea is that given $elem which is somewhere under $top,

 my @nav = $elem->nav();
 my $obj = $top;
 while ( @nav ) {
     my $method = shift @nav;
     my $args = shift @nav;
     $obj = $obj->$method( @{ $args } ) or die;
 }
 # At this point, $obj should contain the same object
 # as $elem.

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

AUTHOR
Thomas R. Wyant, III wyant at cpan dot org

COPYRIGHT AND LICENSE
Copyright (C) 2009-2015 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.