| 1 | package PPI::Token::DashedWord; | ||||||||||
| 2 | |||||||||||
| 3 | =pod | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | PPI::Token::DashedWord - A dashed bareword token | ||||||||||
| 8 | |||||||||||
| 9 | =head1 INHERITANCE | ||||||||||
| 10 | |||||||||||
| 11 | PPI::Token::DashedWord | ||||||||||
| 12 | isa PPI::Token | ||||||||||
| 13 | isa PPI::Element | ||||||||||
| 14 | |||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||
| 16 | |||||||||||
| 17 | The "dashed bareword" token represents literal values like C<-foo>. | ||||||||||
| 18 | |||||||||||
| 19 | NOTE: this class is currently unused. All tokens that should be | ||||||||||
| 20 | PPI::Token::DashedWords are just normal PPI::Token::Word instead. | ||||||||||
| 21 | That actually makes sense, since there really is nothing special about | ||||||||||
| 22 | this class except that dashed words cannot be subroutine names or | ||||||||||
| 23 | keywords. As such, this class may be removed from PPI in the future. | ||||||||||
| 24 | |||||||||||
| 25 | =head1 METHODS | ||||||||||
| 26 | |||||||||||
| 27 | =cut | ||||||||||
| 28 | |||||||||||
| 29 | 63 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 63 | ▶ | use PPI::Token (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | |||||||||||
| 32 | 63 | our $VERSION = '1.260'; # VERSION | |||||||||
| 33 | |||||||||||
| 34 | 63 | our @ISA = "PPI::Token"; | |||||||||
| 35 | |||||||||||
| 36 | =pod | ||||||||||
| 37 | |||||||||||
| 38 | =head2 literal | ||||||||||
| 39 | |||||||||||
| 40 | Returns the value of the dashed word as a string. This differs from | ||||||||||
| 41 | C<content> because C<-Foo'Bar> expands to C<-Foo::Bar>. | ||||||||||
| 42 | |||||||||||
| 43 | =cut | ||||||||||
| 44 | |||||||||||
| 45 | 63 | *literal = *PPI::Token::Word::literal; | |||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | ##################################################################### | ||||||||||
| 50 | # Tokenizer Methods | ||||||||||
| 51 | |||||||||||
| 52 | sub __TOKENIZER__on_char { | ||||||||||
| 53 | 187 | ▶ | my $t = $_[1]; | ||||||||
|
Subroutine
__TOKENIZER__on_char: called CC=3 SCAR=11.0
| |||||||||||
| 54 | |||||||||||
| 55 | # Suck to the end of the dashed bareword | ||||||||||
| 56 | 187 | pos $t->{line} = $t->{line_cursor}; | |||||||||
| 57 | 187 | ▶ | if ( $t->{line} =~ m/\G(\w+)/gc ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 47 | $t->{token}->{content} .= $1; | |||||||||
| 59 | 47 | $t->{line_cursor} += length $1; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | # Are we a file test operator? | ||||||||||
| 63 | 187 | ▶ | if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | # File test operator | ||||||||||
| 65 | 122 | $t->{class} = $t->{token}->set_class( 'Operator' ); | |||||||||
| 66 | } else { | ||||||||||
| 67 | # No, normal dashed bareword | ||||||||||
| 68 | 65 | $t->{class} = $t->{token}->set_class( 'Word' ); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 187 | $t->_finalize_token->__TOKENIZER__on_char( $t ); | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 63 | 1; | |||||||||
| 75 | |||||||||||
| 76 | =pod | ||||||||||
| 77 | |||||||||||
| 78 | =head1 SUPPORT | ||||||||||
| 79 | |||||||||||
| 80 | See the L<support section|PPI/SUPPORT> in the main module. | ||||||||||
| 81 | |||||||||||
| 82 | =head1 AUTHOR | ||||||||||
| 83 | |||||||||||
| 84 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||||||||
| 85 | |||||||||||
| 86 | =head1 COPYRIGHT | ||||||||||
| 87 | |||||||||||
| 88 | Copyright 2001 - 2011 Adam Kennedy. | ||||||||||
| 89 | |||||||||||
| 90 | This program is free software; you can redistribute | ||||||||||
| 91 | it and/or modify it under the same terms as Perl itself. | ||||||||||
| 92 | |||||||||||
| 93 | The full text of the license can be found in the | ||||||||||
| 94 | LICENSE file included with this module. | ||||||||||
| 95 | |||||||||||
| 96 | =cut | ||||||||||