1PPI::Structure(3)     User Contributed Perl Documentation    PPI::Structure(3)
2
3
4

NAME

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

INHERITANCE

9         PPI::Structure
10         isa PPI::Node
11             isa PPI::Element
12

DESCRIPTION

14       PPI::Structure is the root class for all Perl bracing structures. This
15       covers all forms of " [ ... ] ", " { ... } ", and " ( ... ) " brace
16       types, and includes cases where only one half of the pair exist.
17
18       The class PPI::Structure itself is full abstract and no objects of that
19       type should actually exist in the tree.
20
21       Elements vs Children
22
23       A PPI::Structure has an unusual existance. Unlike a PPI::Document or
24       PPI::Statement, which both simply contain other elements, a structure
25       both contains and consists of content.
26
27       That is, the brace tokens are not considered to be "children" of the
28       structure, but are part of it.
29
30       In practice, this will mean that while the ->elements and ->tokens
31       methods (and related) will return a list with the brace tokens at
32       either end, the ->children method explicitly will not return the brace.
33

STRUCTURE CLASSES

35       Excluding the transient PPI::Structure::Unknown that exists briefly
36       inside the parser, there are six types of structure.
37
38       PPI::Structure::List
39
40       This covers all round braces used for function arguments, in "foreach"
41       loops, literal lists, and braces used for precedence-ordering purposes.
42
43       PPI::Structure::ForLoop
44
45       Although not used for the "foreach" loop list, this is used for the
46       special case of the round-brace three-part semicolon-seperated "for"
47       loop expression (the traditional C style for loop).
48
49       PPI::Structure::Condition
50
51       This round-brace structure covers boolean conditional braces, such as
52       for "if" and "while" blocks.
53
54       PPI::Structure::Block
55
56       This curly-brace and common structure is used for all form of code
57       blocks. This includes those for "if", "do" and similar, as well as
58       "grep", "map", "sort", "sub" and (labelled or anonymous) scoping
59       blocks.
60
61       PPI::Structure::Constructor
62
63       This class covers brace structures used for the construction of anony‐
64       mous "ARRAY" and "HASH" references.
65
66       PPI::Structure::Subscript
67
68       This class covers square-braces and curly-braces used after a ->
69       pointer to access the subscript of an "ARRAY" or "HASH".
70

METHODS

72       "PPI::Structure" itself has very few methods. Most of the time, you
73       will be working with the more generic PPI::Element or PPI::Node meth‐
74       ods, or one of the methods that are subclass-specific.
75
76       start
77
78       For lack of better terminology (like "open" and "close") that has not
79       already in use for some other more important purpose, the two individ‐
80       ual braces for the structure are known within PPI as the "start" and
81       "finish" braces (at least for method purposes).
82
83       The "start" method returns the start brace for the structure (i.e. the
84       opening brace).
85
86       Returns the brace as a PPI::Token::Structure or "undef" if the struc‐
87       ture does not have a starting brace.
88
89       Under normal parsing circumstances this should never occur, but may
90       happen due to manipulation of the PDOM tree.
91
92       finish
93
94       The "finish" method returns the finish brace for the structure (i.e.
95       the closing brace).
96
97       Returns the brace as a PPI::Token::Structure or "undef" if the struc‐
98       ture does not have a starting brace. This can be quite common if the
99       document is not complete (for example, from an editor where the user
100       may be halfway through typeing a subroutine).
101
102       braces
103
104       The "braces" method is a utility method which returns the brace type.
105
106       Returns on of the three strings '[]', '{}', or '()', or "undef" on
107       error (primarily not having a start brace, as mentioned above).
108

SUPPORT

110       See the support section in the main module.
111

AUTHOR

113       Adam Kennedy <adamk@cpan.org>
114
116       Copyright 2001 - 2006 Adam Kennedy.
117
118       This program is free software; you can redistribute it and/or modify it
119       under the same terms as Perl itself.
120
121       The full text of the license can be found in the LICENSE file included
122       with this module.
123
124
125
126perl v5.8.8                       2006-09-23                 PPI::Structure(3)
Impressum