1PPIx::Regexp::Dumper(3)User Contributed Perl DocumentatioPnPIx::Regexp::Dumper(3)
2
3
4
6 PPIx::Regexp::Dumper - Dump the results of parsing regular expressions
7
9 use PPIx::Regexp::Dumper;
10 PPIx::Regexp::Dumper->new( 'qr{foo}smx' )
11 ->print();
12
14 "PPIx::Regexp::Dumper" is a PPIx::Regexp::Support.
15
16 "PPIx::Regexp::Dumper" has no descendants.
17
19 This class generates a formatted dump of a PPIx::Regexp::Element object
20 (or any subclass thereof), a PPIx::Regexp::Tokenizer object, or a
21 string that can be made into one of these.
22
24 This class provides the following public methods. Methods not
25 documented here are private, and unsupported in the sense that the
26 author reserves the right to change or remove them without notice.
27
28 new
29 my $dumper = PPIx::Regexp::Dumper->new(
30 '/foo/', ordinal => 1,
31 );
32
33 This static method instantiates the dumper. It takes the string,
34 PPI::Element, PPIx::Regexp::Element, or PPIx::Regexp::Tokenizer to be
35 dumped as the first argument. Optional further arguments may be passed
36 as name/value pairs.
37
38 The following options are recognized:
39
40 default_modifiers array_reference
41 This argument is a reference to a list of default modifiers to be
42 applied to the statement being parsed. See PPIx::Regexp new() for
43 the details.
44
45 encoding name
46 This argument is the name of the encoding of the regular
47 expression. If specified, it is passed through to
48 PPIx::Regexp->new(). It also causes an "Encode::encode" to be done
49 on any parse content dumped.
50
51 explain Boolean
52 If true, this option causes the explain() output of each object to
53 be dumped.
54
55 indent number
56 This argument is the number of additional spaces to indent each
57 level of the parse hierarchy. This is ignored if either the "test"
58 or "tokens" argument is true.
59
60 The default is 2.
61
62 margin number
63 This is the number of spaces to indent the top level of the parse
64 hierarchy. This is ignored if the "test" argument is true.
65
66 The default is zero.
67
68 ordinal Boolean
69 If true, this option causes the "ordinal" values of
70 PPIx::Regexp::Token::Literal objects to be dumped.
71
72 perl_version Boolean
73 If true, this option causes the "perl_version_introduced" and
74 "perl_version_removed" values associated with each object dumped to
75 be displayed.
76
77 ppi Boolean
78 If true, any Perl code contained in the object will be dumped.
79
80 short Boolean
81 If true, leading 'PPIx::Regexp::' will be removed from the class
82 names in the output.
83
84 strict Boolean
85 This option is passed on to the parser, where it specifies whether
86 the parse should assume "use re 'strict'" is in effect.
87
88 The 'strict' pragma was introduced in Perl 5.22, and its
89 documentation says that it is experimental, and that there is no
90 commitment to backward compatibility. The same applies to the parse
91 produced when this option is asserted.
92
93 The default is false.
94
95 significant Boolean
96 If true, this option causes only significant elements to be dumped.
97
98 The default is false.
99
100 test Boolean
101 If true, this option causes the output to be formatted as a
102 regression test rather than as a straight dump. The output produced
103 by asserting this option is explicitly undocumented, in the sense
104 that the author reserves the right to change the generated output
105 without notice of any kind.
106
107 The default is false.
108
109 tokens Boolean
110 If true, this option causes a dump of tokenizer output rather than
111 of a full parse of the regular expression. This is forced true if
112 the dump is of a PPIx::Regexp::Tokenizer.
113
114 The default is false.
115
116 trace number
117 If greater than zero, this option causes a trace of the parse. This
118 option is unsupported in the sense that the author reserves the
119 right to change it without notice.
120
121 The default is zero.
122
123 verbose number
124 If greater than zero, this option causes additional information to
125 be given about the elements found. This option is unsupported in
126 the sense that the author reserves the right to change it without
127 notice.
128
129 The default is zero.
130
131 width Boolean
132 If true, this option causes a dump of the width of the object.
133
134 If the thing to be dumped was a string, unrecognized arguments are
135 passed to "PPIx::Regexp::Tokenizer->new()". Otherwise they are ignored.
136
137 list
138 print map { "$_\n" } $dumper->list();
139
140 This method produces an array containing the dump output, one line per
141 element. The output has no left margin applied, and no newlines.
142
143 print
144 $dumper->print();
145
146 This method simply prints the result of "string" to standard out.
147
148 string
149 print $dumper->string();
150
151 This method adds left margin and newlines to the output of "list",
152 concatenates the result into a single string, and returns that string.
153
155 Support is by the author. Please file bug reports at
156 <https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>,
157 <https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in electronic
158 mail to the author.
159
161 Thomas R. Wyant, III wyant at cpan dot org
162
164 Copyright (C) 2009-2023 by Thomas R. Wyant, III
165
166 This program is free software; you can redistribute it and/or modify it
167 under the same terms as Perl 5.10.0. For more details, see the full
168 text of the licenses in the directory LICENSES.
169
170 This program is distributed in the hope that it will be useful, but
171 without any warranty; without even the implied warranty of
172 merchantability or fitness for a particular purpose.
173
174
175
176perl v5.36.0 2023-01-30 PPIx::Regexp::Dumper(3)