| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Tags::Output::PYX; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # Pragmas. | 
| 4 | 12 |  |  | 12 |  | 83646 | use base qw(Tags::Output); | 
|  | 12 |  |  |  |  | 25 |  | 
|  | 12 |  |  |  |  | 9324 |  | 
| 5 | 12 |  |  | 12 |  | 314685 | use strict; | 
|  | 12 |  |  |  |  | 26 |  | 
|  | 12 |  |  |  |  | 253 |  | 
| 6 | 12 |  |  | 12 |  | 61 | use warnings; | 
|  | 12 |  |  |  |  | 28 |  | 
|  | 12 |  |  |  |  | 314 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | # Modules. | 
| 9 | 12 |  |  | 12 |  | 59 | use Error::Pure qw(err); | 
|  | 12 |  |  |  |  | 20 |  | 
|  | 12 |  |  |  |  | 452 |  | 
| 10 | 12 |  |  | 12 |  | 64 | use Readonly; | 
|  | 12 |  |  |  |  | 22 |  | 
|  | 12 |  |  |  |  | 470 |  | 
| 11 | 12 |  |  | 12 |  | 9045 | use Tags::Utils qw(encode_newline); | 
|  | 12 |  |  |  |  | 109153 |  | 
|  | 12 |  |  |  |  | 259 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | # Constants. | 
| 14 |  |  |  |  |  |  | Readonly::Scalar my $EMPTY_STR => q{}; | 
| 15 |  |  |  |  |  |  | Readonly::Scalar my $SPACE => q{ }; | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | # Version. | 
| 18 |  |  |  |  |  |  | our $VERSION = 0.03; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | # Attributes. | 
| 21 |  |  |  |  |  |  | sub _put_attribute { | 
| 22 | 9 |  |  | 9 |  | 163 | my ($self, $attr, $value) = @_; | 
| 23 | 9 |  |  |  |  | 14 | push @{$self->{'flush_code'}}, "A$attr $value"; | 
|  | 9 |  |  |  |  | 37 |  | 
| 24 | 9 |  |  |  |  | 32 | return; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | # Begin of tag. | 
| 28 |  |  |  |  |  |  | sub _put_begin_of_tag { | 
| 29 | 20 |  |  | 20 |  | 11813 | my ($self, $tag) = @_; | 
| 30 | 20 |  |  |  |  | 58 | push @{$self->{'flush_code'}}, "($tag"; | 
|  | 20 |  |  |  |  | 77 |  | 
| 31 | 20 |  |  |  |  | 30 | unshift @{$self->{'printed_tags'}}, $tag; | 
|  | 20 |  |  |  |  | 59 |  | 
| 32 | 20 |  |  |  |  | 62 | return; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | # CData. | 
| 36 |  |  |  |  |  |  | sub _put_cdata { | 
| 37 | 1 |  |  | 1 |  | 97 | my ($self, @cdata) = @_; | 
| 38 | 1 |  |  |  |  | 5 | $self->_put_data(@cdata); | 
| 39 | 1 |  |  |  |  | 4 | return; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | # Comment. | 
| 43 |  |  |  |  |  |  | sub _put_comment { | 
| 44 | 2 |  |  | 2 |  | 105 | my ($self, @comments) = @_; | 
| 45 |  |  |  |  |  |  | $self->_put_data( | 
| 46 | 2 |  |  |  |  | 4 | map { '' } @comments, | 
|  | 2 |  |  |  |  | 11 |  | 
| 47 |  |  |  |  |  |  | ); | 
| 48 | 2 |  |  |  |  | 5 | return; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | # Data. | 
| 52 |  |  |  |  |  |  | sub _put_data { | 
| 53 | 12 |  |  | 12 |  | 110 | my ($self, @data) = @_; | 
| 54 | 12 |  |  |  |  | 41 | my $data = join($EMPTY_STR, @data); | 
| 55 | 12 |  |  |  |  | 18 | push @{$self->{'flush_code'}}, '-'.encode_newline($data); | 
|  | 12 |  |  |  |  | 55 |  | 
| 56 | 12 |  |  |  |  | 119 | return; | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | # End of tag. | 
| 60 |  |  |  |  |  |  | sub _put_end_of_tag { | 
| 61 | 20 |  |  | 20 |  | 1026 | my ($self, $tag) = @_; | 
| 62 | 20 |  |  |  |  | 29 | my $printed = shift @{$self->{'printed_tags'}}; | 
|  | 20 |  |  |  |  | 55 |  | 
| 63 | 20 | 100 |  |  |  | 66 | if ($printed ne $tag) { | 
| 64 | 1 |  |  |  |  | 9 | err "Ending bad tag: '$tag' in block of tag '$printed'."; | 
| 65 |  |  |  |  |  |  | } | 
| 66 | 19 |  |  |  |  | 27 | push @{$self->{'flush_code'}}, ")$tag"; | 
|  | 19 |  |  |  |  | 55 |  | 
| 67 | 19 |  |  |  |  | 68 | return; | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | # Instruction. | 
| 71 |  |  |  |  |  |  | sub _put_instruction { | 
| 72 | 2 |  |  | 2 |  | 127 | my ($self, $target, $code) = @_; | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | # Construct instruction line. | 
| 75 | 2 |  |  |  |  | 6 | my $instruction = '?'.$target; | 
| 76 | 2 | 100 |  |  |  | 6 | if ($code) { | 
| 77 | 1 |  |  |  |  | 3 | $instruction .= $SPACE.$code; | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | # To flush code. | 
| 81 | 2 |  |  |  |  | 2 | push @{$self->{'flush_code'}}, encode_newline($instruction); | 
|  | 2 |  |  |  |  | 10 |  | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 2 |  |  |  |  | 15 | return; | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | # Raw data. | 
| 87 |  |  |  |  |  |  | sub _put_raw { | 
| 88 | 1 |  |  | 1 |  | 98 | my ($self, @raw_data) = @_; | 
| 89 | 1 |  |  |  |  | 5 | $self->_put_data(@raw_data); | 
| 90 | 1 |  |  |  |  | 3 | return; | 
| 91 |  |  |  |  |  |  | } | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | 1; | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | __END__ |