| 1 | package PMLTQ::NG2PMLTQ; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:MATY'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | $PMLTQ::NG2PMLTQ::VERSION = '1.2.2'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: [DEPRECATED] Conversion functions from NetGraph to PML-TQ | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | import Exporter qw( import ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||||||||||||
| 20 | ng2pmltq | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ) ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | our @EXPORT = qw( ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | sub ng2pmltq { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | local $_=shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ng2pmltq: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my $opts = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | parse_tree(1,{},$opts); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | our $indent = 0; | |||||||||||||||||||||||||||||||||||||||||
| 34 | sub indent (@) { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | join('', @_)."\n"." " x (2*$indent); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | sub report { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my ($fmt,@args)=@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return "\n # WARNING: ".sprintf($fmt, @args)."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | sub parse_tree { | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my ($is_top,$parent_meta,$opts)=@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_tree: not called CC=30 SCAR=68.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | local $indent= $is_top ? 0 : $indent; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $result=''; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | while (length) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ( s/^ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | \[ | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 49 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 50 | [^]"\\]+ | ||||||||||||||||||||||||||||||||||||||||||
| 51 | | | ||||||||||||||||||||||||||||||||||||||||||
| 52 | "[^"]*" | ||||||||||||||||||||||||||||||||||||||||||
| 53 | | | ||||||||||||||||||||||||||||||||||||||||||
| 54 | \\. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | | \]\|\[ | ||||||||||||||||||||||||||||||||||||||||||
| 56 | )* | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 58 | \] | ||||||||||||||||||||||||||||||||||||||||||
| 59 | //x) { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $tok = $1; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my %meta; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $children=''; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $indent ++; | |||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $indent ++; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($tok) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $children = indent().parse_condition($tok,\%meta,$parent_meta,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (s/^\(//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (length $children and $children !~ /(^|[\[(,])\s*$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $children and not $children =~ /(^|[\[(,])\s*$/
MC/DC0%0/2
length $children and not $children =~ /(^|[\[(,])\s*$/
length $children
not $children =~ /(^|[\[(,])\s*$/
Truth table0%0/3
A and not(B)
A= length $childrenB= not $children =~ /(^|[\[(,])\s*$/
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $children.=indent(','); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $children .= parse_tree(0,\%meta,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $children =~ s/,?\s*$//; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | unless (s/^\)//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $result.=report(q{missing ')'}); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $indent --; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (!$is_top) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (defined $meta{'_#occurrences'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $result .= $meta{'_#occurrences'}."x "; | |||||||||||||||||||||||||||||||||||||||||
| 84 | ▶ | } elsif (defined $meta{_optional} and $meta{_optional}=~/^\s*(1|yes|true)\s*/) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $meta{"_optional"} and $meta{"_optional"} =~ /^\s*(1|yes|true)\s*/
MC/DC0%0/2
defined $meta{"_optional"} and $meta{"_optional"} =~ /^\s*(1|yes|true)\s*/
defined $meta{"_optional"}
$meta{"_optional"} =~ /^\s*(1|yes|true)\s*/
Truth table0%0/3
A and B
A= defined $meta{"_optional"}B= $meta{"_optional"} =~ /^\s*(1|yes|true)\s*/
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $result .= '? '; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if (defined $meta{hide}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ($meta{hide}=~/^\s*(1|yes|true|hide)\s*/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ($is_top) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $result .= q(a-node ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | ▶ | } elsif (!$parent_meta->{type} and $opts->{type} eq 'a-node' | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
not $parent_meta->{"type"} and $opts->{"type"} eq "a-node" or ($parent_meta->{"type"} || "") eq "a-node"
not $parent_meta->{"type"} and $opts->{"type"} eq "a-node"
$parent_meta->{'type'} || ''
MC/DC0%0/3
not $parent_meta->{"type"} and $opts->{"type"} eq "a-node" or ($parent_meta->{"type"} || "") eq "a-node"
not $parent_meta->{"type"}
$opts->{"type"} eq "a-node"
$parent_meta->{'type'}
Truth table0%0/5
not(A) and B or C
A= not $parent_meta->{"type"}B= $opts->{"type"} eq "a-node"C= $parent_meta->{'type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | or ($parent_meta->{type}||'') eq 'a-node') { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $result .= q(); | |||||||||||||||||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $result .= q(a/lex.rf|a/aux.rf a-node ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (defined $meta{_transitive}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $result .= 'descendant '; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my $type = $meta{type} || $opts->{type}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$meta{'type'} || $opts->{'type'}
MC/DC0%0/2
$meta{'type'} || $opts->{'type'}
$meta{'type'}
$opts->{'type'}
Truth table0%0/3
A || B
A= $meta{'type'}B= $opts->{'type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (defined($type)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $result .= $type.' ' #if !defined($parent_meta->{type}) or $parent_meta->{type} ne $type; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if (defined $meta{_name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $result .= '$'.lc($meta{_name}).' := '; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $result .= "[".$children; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $indent --; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $result .= indent()."]"; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } elsif (s/^,//) { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $result .= indent(',') unless $result =~ /(^|[\[(,])\s*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | } elsif (s/^([^\[\(\),]+)//) { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $result.=report(q(unrecognized sequence '%s'),$1); | |||||||||||||||||||||||||||||||||||||||||
| 118 | ▶ | } elsif (/\)/ and !$is_top) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
/\)/ and not $is_top
MC/DC0%0/2
/\)/ and not $is_top
/\)/
not $is_top
Truth table0%0/3
A and not(B)
A= /\)/B= not $is_top
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } elsif (s/^(.)//) { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $result.=report(q(had to skip '%s'),$1); | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | my @attrs = map { 'UNKNOWN-'.$_ } 1..50; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | sub fix { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | my ($val,$meta,$parent_meta,$opts)=@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fix: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if (!$opts->{'no-fix'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $val=~s{^a/}{}g; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ($val =~ /^(?:tag|lemma|form)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $val='m/'.$val; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } elsif ($val eq 'token') { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $val='m/w/'.$val; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } elsif ($val eq 'func') { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $val = 'functor'; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } elsif ($val eq 'tlemma') { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $val = 't_lemma'; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } elsif ($val eq 'm_lemma') { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $val = 'lemma'; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } elsif ($val eq 'AID') { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $val = 'id'; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ($val =~ s/^_#//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return $val.'()'; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } elsif ($val eq '_depth') { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return 'depth()'; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if (!defined($meta->{type})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ($val=~/^(?:lemma|tag|ord|form|afun|token)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $meta->{type}='a-node'; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | unless (defined($parent_meta->{type}) and $parent_meta->{type} eq 'a-node') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $parent_meta->{"type"} and $parent_meta->{"type"} eq "a-node"
MC/DC0%0/2
defined $parent_meta->{"type"} and $parent_meta->{"type"} eq "a-node"
defined $parent_meta->{"type"}
$parent_meta->{"type"} eq "a-node"
Truth table0%0/3
A and B
A= defined $parent_meta->{"type"}B= $parent_meta->{"type"} eq "a-node"
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $meta->{hide}=1; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } elsif ($val=~m{^(?:t_lemma|functor|gram/.*|tfa|deepord)}) { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $meta->{type}='t-node'; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | return $val; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | sub quote { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my ($str)=@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $str=~s/'/\\'/g; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return qq('$str'); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | sub parse_condition { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | local $_ = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_condition: not called CC=43 SCAR=75.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $meta = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | my $parent_meta = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my $opts = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $result = ''; #"### $_\n"; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $or = 1 if (/^(?:[^"]|"[^"]*")*\]\|\[/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($or) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $indent++; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $result .= indent "("; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $next_attr = $attrs[0]; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | while (length) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if (s/^\]\|\[//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $result .= indent ' or' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | unless $result =~ /(^|[\[(,]| or)\s*$/; | ||||||||||||||||||||||||||||||||||||||||||
| 187 | } elsif (s/^([{}_\/\#[:alnum:].]+)(?=[!]?=|<|>)//) { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $next_attr=$1; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | unless( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$next_attr =~ s/{([^}.]+)\.([^}.]+)}/() = (lc $1, $2);
$val = fix($val, $meta, $parent_meta, $opts);
"\$$id.$val";/eg or $next_attr =~ s/{([^}.]+)\.([^}.]+)\.(\d+)}/() = (lc $1, $2, $3);
$val = fix($val, $meta, $parent_meta, $opts);
$pos -= 1;
"substr(\$$id.$val,$pos,1)";/eg
MC/DC0%0/2
$next_attr =~ s/{([^}.]+)\.([^}.]+)}/() = (lc $1, $2);
$val = fix($val, $meta, $parent_meta, $opts);
"\$$id.$val";/eg or $next_attr =~ s/{([^}.]+)\.([^}.]+)\.(\d+)}/() = (lc $1, $2, $3);
$val = fix($val, $meta, $parent_meta, $opts);
$pos -= 1;
"substr(\$$id.$val,$pos,1)";/eg
$next_attr =~ s/{([^}.]+)\.([^}.]+)}/() = (lc $1, $2);
$val = fix($val, $meta, $parent_meta, $opts);
"\$$id.$val";/eg
$next_attr =~ s/{([^}.]+)\.([^}.]+)\.(\d+)}/() = (lc $1, $2, $3);
$val = fix($val, $meta, $parent_meta, $opts);
$pos -= 1;
"substr(\$$id.$val,$pos,1)";/eg
Truth table0%0/3
A or B
A= $next_attr =~ s/{([^}.]+)\.([^}.]+)}/() = (lc $1, $2);
$val = fix($val, $meta, $parent_meta, $opts);
"\$$id.$val";/egB= $next_attr =~ s/{([^}.]+)\.([^}.]+)\.(\d+)}/() = (lc $1, $2, $3);
$val = fix($val, $meta, $parent_meta, $opts);
$pos -= 1;
"substr(\$$id.$val,$pos,1)";/eg
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | $next_attr=~s[{([^}.]+)\.([^}.]+)}][ | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my ($id,$val)=(lc($1),$2); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $val=fix($val,$meta,$parent_meta,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | qq{\$$id.$val} | |||||||||||||||||||||||||||||||||||||||||
| 194 | ]eg or | ||||||||||||||||||||||||||||||||||||||||||
| 195 | $next_attr=~s[{([^}.]+)\.([^}.]+)\.(\d+)}][ | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my ($id,$val,$pos)=(lc($1),$2,$3); | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $val=fix($val,$meta,$parent_meta,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $pos-=1; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | qq{substr(\$$id.$val,$pos,1)} | |||||||||||||||||||||||||||||||||||||||||
| 200 | ]eg | ||||||||||||||||||||||||||||||||||||||||||
| 201 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $next_attr=fix($1,$meta,$parent_meta,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } elsif (s/^,//) { | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my $next_attr_idx = first { $attrs[$_-1] eq $next_attr } 1..$#attrs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | $next_attr = $attrs[$next_attr_idx||0]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$next_attr_idx || 0
MC/DC0%0/1
$next_attr_idx || 0
$next_attr_idx
Truth table0%0/2
A
A= $next_attr_idx
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $result .= indent(',') unless $result =~ /(^|[\[(,]| or)\s*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | ▶ | } elsif (s/^((?:!?=|[<>]=?)?)((?:[^\\\]=,"]+|"[^"]*"|\\.)*)(?=[,\]]|$)// and length $2) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
s/^((?:!?=|[<>]=?)?)((?:[^\\\]=,"]+|"[^"]*"|\\.)*)(?=[,\]]|$)// and length $2
MC/DC0%0/2
s/^((?:!?=|[<>]=?)?)((?:[^\\\]=,"]+|"[^"]*"|\\.)*)(?=[,\]]|$)// and length $2
s/^((?:!?=|[<>]=?)?)((?:[^\\\]=,"]+|"[^"]*"|\\.)*)(?=[,\]]|$)//
length $2
Truth table0%0/3
A and B
A= s/^((?:!?=|[<>]=?)?)((?:[^\\\]=,"]+|"[^"]*"|\\.)*)(?=[,\]]|$)//B= length $2
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | my $next_op = $1 || '='; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$1 || '='
MC/DC0%0/1
$1 || '='
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $vals = $2; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ($next_attr =~ /^(?:_transitive|_optional|_name|hide)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $meta->{$next_attr} = $vals; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } elsif ($next_attr eq '_#occurrences') { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my @vals = sort {$a<=>$b} split /\|/,$vals; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my @tests; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($next_op eq '=') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | @tests = @vals; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } elsif ($next_op eq '!=') { | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $prev = shift @vals; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ($prev>0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | push @tests,($prev-1)."-"; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | for (@vals) { | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | next if $prev==$_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | push @tests,($prev+1)."..".($_-1); | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $prev=$_; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | push @tests,($prev+1)."+"; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } elsif ($next_op eq '<=') { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | push @tests, $vals[-1]."-" ; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } elsif ($next_op eq '>=') { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | push @tests, $vals[0]."+" ; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } elsif ($next_op eq '<') { | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | push @tests, ($vals[-1]-1)."-" ; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } elsif ($next_op eq '>') { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | push @tests, ($vals[0]+1)."+" ; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | warn "Unsupported operator for meta-attribute _#occurrences: $next_op\n"; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $meta->{$next_attr} = join '',map { "|" } @tests; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | my @vals = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | ($vals=~/^"(.*)"$/) ? ($vals) : split /\|/,$vals; | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | my $neg = $next_op eq '!=' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ($neg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $result .= q{!}; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $next_op = '='; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if (@vals>1 and ($next_op eq '=')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@vals > 1 and $next_op eq "="
MC/DC0%0/2
@vals > 1 and $next_op eq "="
@vals > 1
$next_op eq "="
Truth table0%0/3
A and B
A= @vals > 1B= $next_op eq "="
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $indent ++; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $result .= qq($next_attr in { ).join(',',map quote($_), @vals).qq( } ); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $indent --; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if (@vals>1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $result .= "("; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $indent ++; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | for my $val (@vals) { | |||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $op = $next_op; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if ($val=~/^"(.*)"$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $op = '~'; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $val=$1; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ($opts->{'no-fix'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $val=~s/\.(?![^{}]+})/?/g; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ($val=~/[?*]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $val=~s/([^[:alnum:]_?*])/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $val=~y/?/./; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $val=~s/\*/.*/g; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $val='^'.$val.'$'; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $op = '~' | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $val=quote($val); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $val=~s[{([^}.]+)\.([^}.]+)}][ | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($id,$val)=(lc($1),$2); | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $val=fix($val,$meta,$parent_meta,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | qq{'&\$$id.$val&'} | |||||||||||||||||||||||||||||||||||||||||
| 282 | ]eg; | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $val=~s[{([^}.]+)\.([^}.]+)\.(\d+)}][ | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my ($id,$val,$pos)=(lc($1),$2,$3); | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $val=fix($val,$meta,$parent_meta,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | qq{'&substr(\$$id.$val,$pos,1)&'} | |||||||||||||||||||||||||||||||||||||||||
| 287 | ]eg; | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $val=~s/^ ''& | |||||||||||||||||||||||||||||||||||||||||
| 289 | | &'' | ||||||||||||||||||||||||||||||||||||||||||
| 290 | $//xg; | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $val=~s/&''&/ & /g; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $indent ++; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $result .= qq($next_attr $op $val); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if (@vals>1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $result.=' or '; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $indent --; | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if (@vals>1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $result.=')'; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $indent --; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } elsif (s/^(.)//) { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $q = quote($1); | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $result.=report("had to skip test $q"); | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ($or) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $indent--; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $result .= indent().")"; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | 1; # End of PMLTQ::NG2PMLTQ | |||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | __END__ | ||||||||||||||||||||||||||||||||||||||||||