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

NAME

6       PPI::Statement - The base class for Perl statements
7

INHERITANCE

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

DESCRIPTION

14       PPI::Statement is the root class for all Perl statements. This includes
15       (from perlsyn) "Declarations", "Simple Statements" and "Compound
16       Statements".
17
18       The class PPI::Statement itself represents a "Simple Statement" as
19       defined in the perlsyn manpage.
20

STATEMENT CLASSES

22       Please note that unless documented themselves, these classes are yet to
23       be frozen/finalised. Names may change slightly or be added or removed.
24
25   PPI::Statement::Scheduled
26       This covers all "scheduled" blocks, chunks of code that are executed
27       separately from the main body of the code, at a particular time. This
28       includes all "BEGIN", "CHECK", "UNITCHECK", "INIT" and "END" blocks.
29
30   PPI::Statement::Package
31       A package declaration, as defined in perlfunc.
32
33   PPI::Statement::Include
34       A statement that loads or unloads another module.
35
36       This includes 'use', 'no', and 'require' statements.
37
38   PPI::Statement::Sub
39       A named subroutine declaration, or forward declaration
40
41   PPI::Statement::Variable
42       A variable declaration statement. This could be either a straight
43       declaration or also be an expression.
44
45       This includes all 'my', 'state', 'local' and 'our' statements.
46
47   PPI::Statement::Compound
48       This covers the whole family of 'compound' statements, as described in
49       perlsyn.
50
51       This includes all statements starting with 'if', 'unless', 'for',
52       'foreach' and 'while'. Note that this does NOT include 'do', as it is
53       treated differently.
54
55       All compound statements have implicit ends. That is, they do not end
56       with a ';' statement terminator.
57
58   PPI::Statement::Break
59       A statement that breaks out of a structure.
60
61       This includes all of 'redo', 'goto', 'next', 'last' and 'return'
62       statements.
63
64   PPI::Statement::Given
65       The kind of statement introduced in Perl 5.10 that starts with 'given'.
66       This has an implicit end.
67
68   PPI::Statement::When
69       The kind of statement introduced in Perl 5.10 that starts with 'when'
70       or 'default'.  This also has an implicit end.
71
72   PPI::Statement::Data
73       A special statement which encompasses an entire "__DATA__" block,
74       including the initial '__DATA__' token itself and the entire contents.
75
76   PPI::Statement::End
77       A special statement which encompasses an entire __END__ block,
78       including the initial '__END__' token itself and the entire contents,
79       including any parsed PPI::Token::POD that may occur in it.
80
81   PPI::Statement::Expression
82       PPI::Statement::Expression is a little more speculative, and is
83       intended to help represent the special rules relating to "expressions"
84       such as in:
85
86         # Several examples of expression statements
87
88         # Boolean conditions
89         if ( expression ) { ... }
90
91         # Lists, such as for arguments
92         Foo->bar( expression )
93
94   PPI::Statement::Null
95       A null statement is a special case for where we encounter two
96       consecutive statement terminators. ( ;; )
97
98       The second terminator is given an entire statement of its own, but one
99       that serves no purpose. Hence a 'null' statement.
100
101       Theoretically, assuming a correct parsing of a perl file, all null
102       statements are superfluous and should be able to be removed without
103       damage to the file.
104
105       But don't do that, in case PPI has parsed something wrong.
106
107   PPI::Statement::UnmatchedBrace
108       Because PPI is intended for use when parsing incorrect or incomplete
109       code, the problem arises of what to do with a stray closing brace.
110
111       Rather than die, it is allocated its own "unmatched brace" statement,
112       which really means "unmatched closing brace". An unmatched open brace
113       at the end of a file would become a structure with no contents and no
114       closing brace.
115
116       If the document loaded is intended to be correct and valid, finding a
117       PPI::Statement::UnmatchedBrace in the PDOM is generally indicative of a
118       misparse.
119
120   PPI::Statement::Unknown
121       This is used temporarily mid-parsing to hold statements for which the
122       lexer cannot yet determine what class it should be, usually because
123       there are insufficient clues, or it might be more than one thing.
124
125       You should never encounter these in a fully parsed PDOM tree.
126

METHODS

128       "PPI::Statement" itself has very few methods. Most of the time, you
129       will be working with the more generic PPI::Element or PPI::Node
130       methods, or one of the methods that are subclass-specific.
131
132   label
133       One factor common to most statements is their ability to be labeled.
134
135       The "label" method returns the label for a statement, if one has been
136       defined, but without the trailing colon. Take the following example
137
138         MYLABEL: while ( 1 .. 10 ) { last MYLABEL if $_ > 5 }
139
140       For the above statement, the "label" method would return 'MYLABEL'.
141
142       Returns false if the statement does not have a label.
143
144   specialized
145       Answer whether this is a plain statement or one that has more
146       significance.
147
148       Returns true if the statement is a subclass of this one, false
149       otherwise.
150
151   stable
152       Much like the PPI::Document method of the same name, the ->stable
153       method converts a statement to source and back again, to determine if a
154       modified statement is still legal, and won't be interpreted in a
155       different way.
156
157       Returns true if the statement is stable, false if not, or "undef" on
158       error.
159

TO DO

161       - Complete, freeze and document the remaining classes
162

SUPPORT

164       See the support section in the main module.
165

AUTHOR

167       Adam Kennedy <adamk@cpan.org>
168
170       Copyright 2001 - 2011 Adam Kennedy.
171
172       This program is free software; you can redistribute it and/or modify it
173       under the same terms as Perl itself.
174
175       The full text of the license can be found in the LICENSE file included
176       with this module.
177
178
179
180perl v5.28.1                      2017-06-22                 PPI::Statement(3)
Impressum