make room for $VERSION after package declaration (newer [PkgVersion] requires it)
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / PPI.pm
CommitLineData
1716b200 1use strict;
2use warnings;
c5bf3ed2 3package Devel::REPL::Plugin::PPI;
c5bf3ed2 4
6f4f9516 5use Devel::REPL::Plugin;
c5bf3ed2 6use PPI;
7use PPI::Dumper;
aa8b7647 8use namespace::autoclean;
c5bf3ed2 9
3a400715 10sub BEFORE_PLUGIN {
11 my $self = shift;
12 $self->load_plugin('Turtles');
13}
c5bf3ed2 14
15sub expr_command_ppi {
16 my ( $self, $eval, $code ) = @_;
17
18 my $document = PPI::Document->new(\$code);
19 my $dumper = PPI::Dumper->new($document);
20 return $dumper->string;
21}
22
23__PACKAGE__
24
25__END__
26
27=pod
28
29=head1 NAME
30
31Devel::REPL::Plugin::PPI - PPI dumping of Perl code
32
33=head1 SYNOPSIS
34
35 repl> #ppi Devel::REPL
36 PPI::Document
37 PPI::Statement
38 PPI::Token::Word 'Devel::REPL'
afc8677b 39
c5bf3ed2 40 repl> #ppi {
41 > warn $];
42 > }
43 PPI::Document
44 PPI::Statement::Compound
45 PPI::Structure::Block { ... }
46 PPI::Token::Whitespace '\n'
47 PPI::Statement
48 PPI::Token::Word 'warn'
49 PPI::Token::Whitespace ' '
50 PPI::Token::Magic '$]'
51 PPI::Token::Structure ';'
52 PPI::Token::Whitespace '\n'
53
54=head1 DESCRIPTION
55
56This plugin provides a C<ppi> command that uses L<PPI::Dumper> to dump
57L<PPI>-parsed Perl documents.
58
59The code is not actually executed, which means that when used with
60L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>.
61
62=head1 AUTHOR
63
64Shawn M Moore E<lt>sartak@gmail.comE<gt>
65
66=cut
67
68