| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Text::TokenStream::Token; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 3 |  |  | 3 |  | 143845 | use v5.12; | 
|  | 3 |  |  |  |  | 19 |  | 
| 4 | 3 |  |  | 3 |  | 1144 | use Moo; | 
|  | 3 |  |  |  |  | 23130 |  | 
|  | 3 |  |  |  |  | 18 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.02'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 3 |  |  | 3 |  | 3422 | use Carp qw(confess); | 
|  | 3 |  |  |  |  | 8 |  | 
|  | 3 |  |  |  |  | 138 |  | 
| 9 | 3 |  |  | 3 |  | 1386 | use Text::TokenStream::Types qw(Identifier Position); | 
|  | 3 |  |  |  |  | 11 |  | 
|  | 3 |  |  |  |  | 34 |  | 
| 10 | 3 |  |  | 3 |  | 1701 | use Types::Standard qw(Bool HashRef Str); | 
|  | 3 |  |  |  |  | 15 |  | 
|  | 3 |  |  |  |  | 18 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 3 |  |  | 3 |  | 4324 | use namespace::clean; | 
|  | 3 |  |  |  |  | 33057 |  | 
|  | 3 |  |  |  |  | 21 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | has type => (is => 'ro', isa => Identifier, required => 1); | 
| 15 |  |  |  |  |  |  | has text => (is => 'ro', isa => Str, required => 1); | 
| 16 |  |  |  |  |  |  | has captures => (is => 'ro', isa => HashRef[Str], default => sub { +{} }); | 
| 17 |  |  |  |  |  |  | has cuddled => (is => 'ro', isa => Bool, default => 0); | 
| 18 |  |  |  |  |  |  | has position => (is => 'ro', isa => Position, required => 1); | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 13 |  |  | 13 | 1 | 250 | sub text_for_matching { shift->text } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub matches { | 
| 23 | 15 |  |  | 15 | 1 | 334 | my ($self, $target) = @_; | 
| 24 | 15 | 100 |  |  |  | 42 | return $self->text_for_matching eq $target if Str->check($target); | 
| 25 | 3 |  |  |  |  | 52 | return !!grep $target->($_), $self; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub repr { | 
| 29 | 3 |  |  | 3 | 1 | 42 | my ($self, $indent) = @_; | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 3 |  | 100 |  |  | 47 | return sprintf '%sToken type=%s position=%d cuddled=%d text=[%s]', | 
| 32 |  |  |  |  |  |  | $indent // '', $self->type, $self->position, $self->cuddled, $self->text; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | 1; | 
| 36 |  |  |  |  |  |  | __END__ |