PPIx::Regexp::Dumper(3)

NAME
PPIx::Regexp::Dumper - Dump the results of parsing regular expressions

SYNOPSIS
 use PPIx::Regexp::Dumper;
 PPIx::Regexp::Dumper->new( 'qr{foo}smx' )
     ->print();

INHERITANCE
"PPIx::Regexp::Dumper" is a PPIx::Regexp::Support.

"PPIx::Regexp::Dumper" has no descendants.

DESCRIPTION
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.

METHODS
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.

  new
 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:

default_modifiers array_reference
    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.

encoding name
    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.

explain Boolean
    If true, this option causes the explain() output of each object to be dumped.

indent number
    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.

    The default is 2.

margin number
    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.

ordinal Boolean
    If true, this option causes the "ordinal" values of PPIx::Regexp::Token::Literal objects to be dumped.

perl_version Boolean
    If true, this option causes the "perl_version_introduced" and "perl_version_removed" values associated with each object dumped to be displayed.

ppi Boolean
    If true, any Perl code contained in the object will be dumped.

short Boolean
    If true, leading 'PPIx::Regexp::' will be removed from the class names in the output.

strict Boolean
    This option is passed on to the parser, where it specifies whether the parse should assume "use re 'strict'" is in effect.

    The 'strict' pragma was introduced in Perl 5.22, and its documentation says that it is experimental, and that there is no commitment to backward compatibility. The same applies to the parse produced when this option is asserted.

    The default is false.

significant Boolean
    If true, this option causes only significant elements to be dumped.

    The default is false.

test Boolean
    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.

    The default is false.

tokens Boolean
    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.

    The default is false.

trace number
    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.

    The default is zero.

verbose number
    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.

    The default is zero.

width Boolean
    If true, this option causes a dump of the width of the object.

If the thing to be dumped was a string, unrecognized arguments are passed to "PPIx::Regexp::Tokenizer->new()". Otherwise they are ignored.

  list
 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.

  print
 $dumper->print();

This method simply prints the result of "string" to standard out.

  string
 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
Support is by the author. Please file bug reports at <https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>, <https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in electronic mail to the author.

AUTHOR
Thomas R. Wyant, III wyant at cpan dot org

COPYRIGHT AND LICENSE
Copyright (C) 2009-2023 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.