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