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


Manual Reference Pages  -  PPI::STRUCTURE (3)

.ds Aq ’

NAME

PPI::Structure - The base class for Perl braced structures

CONTENTS

INHERITANCE



  PPI::Structure
  isa PPI::Node
      isa PPI::Element



DESCRIPTION

PPI::Structure is the root class for all Perl bracing structures. This covers all forms of [ ... ] , { ... } , and ( ... ) brace types, and includes cases where only one half of the pair exist.

The class PPI::Structure itself is full abstract and no objects of that type should actually exist in the tree.

    Elements vs Children

A <B>PPI::StructureB> has an unusual existence. Unlike a PPI::Document or PPI::Statement, which both simply contain other elements, a structure <B>bothB> contains and consists of content.

That is, the brace tokens are <B>notB> considered to be children of the structure, but are part of it.

In practice, this will mean that while the ->elements and ->tokens methods (and related) <B>willB> return a list with the brace tokens at either end, the ->children method explicitly will <B>notB> return the brace.

STRUCTURE CLASSES

Excluding the transient PPI::Structure::Unknown that exists briefly inside the parser, there are eight types of structure.

    PPI::Structure::List

This covers all round braces used for function arguments, in foreach loops, literal lists, and braces used for precedence-ordering purposes.

    PPI::Structure::For

Although <B>notB> used for the foreach loop list, this <B>isB> used for the special case of the round-brace three-part semicolon-separated for loop expression (the traditional C style for loop).

    PPI::Structure::Given

This is for the expression being matched in switch statements.

    PPI::Structure::When

This is for the matching expression in when statements.

    PPI::Structure::Condition

This round-brace structure covers boolean conditional braces, such as for if and while blocks.

    PPI::Structure::Block

This curly-brace and common structure is used for all form of code blocks. This includes those for if, do and similar, as well as grep, map, sort, sub and (labelled or anonymous) scoping blocks.

    PPI::Structure::Constructor

This class covers brace structures used for the construction of anonymous ARRAY and HASH references.

    PPI::Structure::Subscript

This class covers square-braces and curly-braces used after a -> pointer to access the subscript of an ARRAY or HASH.

METHODS

PPI::Structure itself has very few methods. Most of the time, you will be working with the more generic PPI::Element or PPI::Node methods, or one of the methods that are subclass-specific.

    start

For lack of better terminology (like open and close) that has not already in use for some other more important purpose, the two individual braces for the structure are known within PPI as the start and finish braces (at least for method purposes).

The start method returns the start brace for the structure (i.e. the opening brace).

Returns the brace as a PPI::Token::Structure or undef if the structure does not have a starting brace.

Under normal parsing circumstances this should never occur, but may happen due to manipulation of the PDOM tree.

    finish

The finish method returns the finish brace for the structure (i.e. the closing brace).

Returns the brace as a PPI::Token::Structure or undef if the structure does not have a finishing brace. This can be quite common if the document is not complete (for example, from an editor where the user may be halfway through typeing a subroutine).

    braces

The braces method is a utility method which returns the brace type, regardless of whether has both braces defined, or just the starting brace, or just the ending brace.

Returns on of the three strings [], {}, or (), or undef on error (primarily not having a start brace, as mentioned above).

complete

The complete method is a convenience method that returns true if the both braces are defined for the structure, or false if only one brace is defined.

Unlike the top level complete method which checks for completeness in depth, the structure complete method ONLY confirms completeness for the braces, and does not recurse downwards.

SUPPORT

See the support section in the main module.

AUTHOR

Adam Kennedy <adamk@cpan.org>

COPYRIGHT

Copyright 2001 - 2011 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

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


perl v5.20.3 PPI::STRUCTURE (3) 2014-11-11

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