| 1 | package Localizer::Scanner::Xslate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use 5.008005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = "0.05"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | sub DEBUG () { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Localizer::Dictionary; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Class::Accessor::Lite 0.05 ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ro => [qw(parser)], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my %args = @_==1 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $self = bless { }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | my $syntax = $args{syntax} || 'TTerse'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'syntax'} || 'TTerse'
MC/DC0%0/1
$args{'syntax'} || 'TTerse'
$args{'syntax'}
Truth table50%1/2
A
A= $args{'syntax'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | $self->{parser} = $self->_build_parser($syntax); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | our $RESULT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | our $FILENAME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub _build_parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_parser: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | my ($self, $syntax) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | eval "use Text::Xslate::Syntax::${syntax};"; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | "Text::Xslate::Syntax::${syntax}"->new(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | sub scan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my($self, $result, $filename, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my $ast = $self->parser->parse($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | local $FILENAME = $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | local $RESULT = $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | $self->_walker($ast); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub scan_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan_file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my ($self, $result, $filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | open my $fh, '<:encoding(utf-8)', $filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | or die "Cannot open file '$filename' for reading: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | my $data = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | return $self->scan($result, $filename, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | my $sp = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 241 | ▶ | sub _walker { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_walker: called CC=17 SCAR=31.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 241 | my($self, $ast) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 241 | ▶ | $ast = [ $ast ] if $ast && ref($ast) eq 'Text::Xslate::Symbol'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ast and ref $ast eq "Text::Xslate::Symbol"
MC/DC100%2/2
$ast and ref $ast eq "Text::Xslate::Symbol"
$ast
ref $ast eq "Text::Xslate::Symbol"
Truth table100%3/3
A and B
A= $astB= ref $ast eq "Text::Xslate::Symbol"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 241 | ▶ | return unless $ast && ref($ast) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ast and ref $ast eq "ARRAY"
MC/DC50%1/2
$ast and ref $ast eq "ARRAY"
$ast
ref $ast eq "ARRAY"
Truth table66%2/3
A and B
A= $astB= ref $ast eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 55 | for my $sym (@{ $ast }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 80 | ▶ | if ($sym->arity eq 'call' && $sym->value eq '(') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sym->arity eq "call" and $sym->value eq "("
MC/DC50%1/2
$sym->arity eq "call" and $sym->value eq "("
$sym->arity eq "call"
$sym->value eq "("
Truth table66%2/3
A and B
A= $sym->arity eq "call"B= $sym->value eq "("
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 11 | my $first = $sym->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 11 | ▶ | if ($first && ref($first) eq 'Text::Xslate::Symbol') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$first and ref $first eq "Text::Xslate::Symbol"
MC/DC0%0/2
$first and ref $first eq "Text::Xslate::Symbol"
$first
ref $first eq "Text::Xslate::Symbol"
Truth table33%1/3
A and B
A= $firstB= ref $first eq "Text::Xslate::Symbol"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 11 | ▶ | if ($first->arity eq 'variable' && $first->value eq 'l') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$first->arity eq "variable" and $first->value eq "l"
MC/DC0%0/2
$first->arity eq "variable" and $first->value eq "l"
$first->arity eq "variable"
$first->value eq "l"
Truth table33%1/3
A and B
A= $first->arity eq "variable"B= $first->value eq "l"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 11 | my $second = $sym->second; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 11 | ▶ | if ($second && ref($second) eq 'ARRAY' && $second->[0] && ref($second->[0]) eq 'Text::Xslate::Symbol') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$second and ref $second eq "ARRAY" and $second->[0] and ref $second->[0] eq "Text::Xslate::Symbol"
$second and ref $second eq "ARRAY" and $second->[0]
$second and ref $second eq "ARRAY"
MC/DC0%0/4
$second and ref $second eq "ARRAY" and $second->[0] and ref $second->[0] eq "Text::Xslate::Symbol"
$second
ref $second eq "ARRAY"
$second->[0]
ref $second->[0] eq "Text::Xslate::Symbol"
Truth table20%1/5
A and B and C and D
A= $secondB= ref $second eq "ARRAY"C= $second->[0]D= ref $second->[0] eq "Text::Xslate::Symbol"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 11 | my $value = $second->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 11 | ▶ | if ($value->arity eq 'literal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 10 | $RESULT->add_entry_position($value->value, $FILENAME, $value->line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 80 | unless (DEBUG) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 80 | $self->_walker($sym->first); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 80 | $self->_walker($sym->second); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 80 | $self->_walker($sym->third); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | warn "$sp id: " . $sym->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | warn "$sp line: " . $sym->line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | warn "$sp ldp: ". $sym->lbp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | warn "$sp udp: ". $sym->ubp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | warn "$sp type: ". $sym->type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | warn "$sp arity: ". $sym->arity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | warn "$sp assignment: ". $sym->assignment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | warn "$sp value: ". $sym->value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | warn "$sp first: " . $sym->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | $sp .= ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | $self->_walker($sym->first); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $sp =~ s/^.//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | warn "$sp second: " . $sym->second; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $sp .= ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | $self->_walker($sym->second); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | $sp =~ s/^.//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | warn "$sp third: " . $sym->third; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $sp .= ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $self->_walker($sym->third); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | $sp =~ s/^.//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | warn $sp . '----------'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||