PPIx::Regexp::Dumper - Dump the results of parsing regular expressions
use PPIx::Regexp::Dumper; PPIx::Regexp::Dumper->new( 'qr{foo}smx' ) ->print();
PPIx::Regexp::Dumper is a PPIx::Regexp::Support.
PPIx::Regexp::Dumper
PPIx::Regexp::Dumper has no descendants.
This class generates a formatted dump of a PPIx::Regexp::Element object (or any subclass thereof), a PPIx::Regexp::Tokenizer object, or a string that can be made into one of these.
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.
my $dumper = PPIx::Regexp::Dumper->new( '/foo/', ordinal => 1, );
This static method instantiates the dumper. It takes the string, PPI::Element, PPIx::Regexp::Element, or PPIx::Regexp::Tokenizer to be dumped as the first argument. Optional further arguments may be passed as name/value pairs.
The following options are recognized:
This argument is a reference to a list of default modifiers to be applied to the statement being parsed. See PPIx::Regexp new() for the details.
This argument is the name of the encoding of the regular expression. If specified, it is passed through to PPIx::Regexp->new(). It also causes an Encode::encode to be done on any parse content dumped.
Encode::encode
This argument is the number of additional spaces to indent each level of the parse hierarchy. This is ignored if either the test or tokens argument is true.
test
tokens
The default is 2.
This is the number of spaces to indent the top level of the parse hierarchy. This is ignored if the test argument is true.
The default is zero.
If true, this option causes the ordinal values of PPIx::Regexp::Token::Literal objects to be dumped.
ordinal
If true, this option causes the perl_version_introduced and perl_version_removed values associated with each object dumped to be displayed.
perl_version_introduced
perl_version_removed
If true, this option causes only significant elements to be dumped.
The default is false.
If true, this option causes the output to be formatted as a regression test rather than as a straight dump. The output produced by asserting this option is explicitly undocumented, in the sense that the author reserves the right to change the generated output without notice of any kind.
If true, this option causes a dump of tokenizer output rather than of a full parse of the regular expression. This is forced true if the dump is of a PPIx::Regexp::Tokenizer.
If greater than zero, this option causes a trace of the parse. This option is unsupported in the sense that the author reserves the right to change it without notice.
If greater than zero, this option causes additional information to be given about the elements found. This option is unsupported in the sense that the author reserves the right to change it without notice.
If the thing to be dumped was a string, unrecognized arguments are passed to PPIx::Regexp::Tokenizer->new(). Otherwise they are ignored.
PPIx::Regexp::Tokenizer->new()
print map { "$_\n" } $dumper->list();
This method produces an array containing the dump output, one line per element. The output has no left margin applied, and no newlines.
$dumper->print();
This method simply prints the result of "string" to standard out.
print $dumper->string();
This method adds left margin and newlines to the output of "list", concatenates the result into a single string, and returns that string.
Support is by the author. Please file bug reports at http://rt.cpan.org, or in electronic mail to the author.
Thomas R. Wyant, III wyant at cpan dot org
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.
To install PPIx::Regexp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PPIx::Regexp
CPAN shell
perl -MCPAN -e shell install PPIx::Regexp
For more information on module installation, please visit the detailed CPAN module installation guide.