1 package PPI::Token::Quote;
7 PPI::Token::Quote - String quote abstract base class
17 The C<PPI::Token::Quote> class is never instantiated, and simply
18 provides a common abstract base class for the four quote classes.
19 In PPI, a "quote" is limited to only the quote-like things that
20 themselves directly represent a string. (although this includes
21 double quotes with interpolated elements inside them).
23 The subclasses of C<PPI::Token::Quote> are:
27 =item C<''> - L<PPI::Token::Quote::Single>
29 =item C<q{}> - L<PPI::Token::Quote::Literal>
31 =item C<""> - L<PPI::Token::Quote::Double>
33 =item C<qq{}> - L<PPI::Token::Quote::Interpolate>
37 The names are hopefully obvious enough not to have to explain what
38 each class is here. See their respective pages for more details.
40 Please note that although the here-doc B<does> represent a literal
41 string, it is such a nasty piece of work that in L<PPI> it is given the
42 honor of its own token class (L<PPI::Token::HereDoc>).
51 use vars qw{$VERSION @ISA};
61 #####################################################################
62 # PPI::Token::Quote Methods
68 The C<string> method is provided by all four ::Quote classes. It won't
69 get you the actual literal Perl value, but it will strip off the wrapping
72 # The following all return foo from the ->string method
78 =begin testing string 15
80 # Prove what we say in the ->string docs
81 my $Document = PPI::Document->new(\<<'END_PERL');
87 isa_ok( $Document, 'PPI::Document' );
89 my $quotes = $Document->find('Token::Quote');
90 is( ref($quotes), 'ARRAY', 'Found quotes' );
91 is( scalar(@$quotes), 4, 'Found 4 quotes' );
92 foreach my $Quote ( @$quotes ) {
93 isa_ok( $Quote, 'PPI::Token::Quote');
94 can_ok( $Quote, 'string' );
95 is( $Quote->string, 'foo', '->string returns "foo" for '
104 # my $class = ref $_[0] || $_[0];
105 # die "$class does not implement method ->string";
112 The C<literal> method is provided by ::Quote:Literal and
113 ::Quote::Single. This returns the value of the string as Perl sees
114 it: without the quote marks and with C<\\> and C<\'> resolved to C<\>
117 The C<literal> method is not implemented by ::Quote::Double or
118 ::Quote::Interpolate yet.
128 See the L<support section|PPI/SUPPORT> in the main module.
132 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
136 Copyright 2001 - 2009 Adam Kennedy.
138 This program is free software; you can redistribute
139 it and/or modify it under the same terms as Perl itself.
141 The full text of the license can be found in the
142 LICENSE file included with this module.