| 1 | package Treex::PML::Instance::Common; | ||||||||||||
| 2 | |||||||||||||
| 3 | 9 | ▶ | use 5.008; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 9 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 9 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 9 | require Exporter; | |||||||||||
| 9 | 9 | import Exporter qw( import ); | |||||||||||
| 10 | |||||||||||||
| 11 | 9 | our @ISA = qw(Exporter); | |||||||||||
| 12 | 9 | our %EXPORT_TAGS = ( | |||||||||||
| 13 | 'diagnostics' => [ qw( _die _warn _debug DEBUG XSLT_BUG ) ], | ||||||||||||
| 14 | 'constants' => [ qw( LM AM PML_NS SUPPORTED_PML_VERSIONS ) ], | ||||||||||||
| 15 | ); | ||||||||||||
| 16 | $EXPORT_TAGS{'all'} = [ | ||||||||||||
| 17 | 9 | @{ $EXPORT_TAGS{'constants'} }, | |||||||||||
| 18 | 9 | @{ $EXPORT_TAGS{'diagnostics'} }, | |||||||||||
| 19 | qw( $DEBUG $XSLT_BUG SUPPORTED_PML_VERSIONS ) | ||||||||||||
| 20 | ]; | ||||||||||||
| 21 | |||||||||||||
| 22 | 9 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||
| 23 | 9 | our @EXPORT = qw( ); | |||||||||||
| 24 | 9 | our $VERSION = '2.29'; # version template | |||||||||||
| 25 | |||||||||||||
| 26 | |||||||||||||
| 27 | 9 | ▶ | our $DEBUG = $ENV{PML_DEBUG}||0; | ||||||||||
|
Condition50%1/2
$ENV{'PML_DEBUG'} || 0
MC/DC0%0/1
$ENV{'PML_DEBUG'} || 0
$ENV{'PML_DEBUG'}
Truth table50%1/2
A
A= $ENV{'PML_DEBUG'}
| |||||||||||||
| 28 | |||||||||||||
| 29 | 9 | our $XSLT_BUG=0; | |||||||||||
| 30 | 9 | eval { | |||||||||||
| 31 | 9 | require XML::LibXSLT; | |||||||||||
| 32 | 0 | $XSLT_BUG = grep 10127 == $_, XML::LibXSLT::LIBXSLT_VERSION(), | |||||||||||
| 33 | XML::LibXSLT::LIBXSLT_RUNTIME_VERSION(); | ||||||||||||
| 34 | }; | ||||||||||||
| 35 | |||||||||||||
| 36 | 9 | ▶ | use constant LM => 'LM'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 37 | 9 | ▶ | use constant AM => 'AM'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 38 | 9 | ▶ | use constant PML_NS => "http://ufal.mff.cuni.cz/pdt/pml/"; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 39 | 9 | ▶ | use constant SUPPORTED_PML_VERSIONS => " 1.1 1.2 "; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 40 | |||||||||||||
| 41 | ################################### | ||||||||||||
| 42 | # DIAGNOSTICS | ||||||||||||
| 43 | ################################### | ||||||||||||
| 44 | |||||||||||||
| 45 | 0 | ▶ | sub XSLT_BUG { | ||||||||||
|
Subroutine
XSLT_BUG: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 46 | 0 | return $XSLT_BUG; | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 0 | ▶ | sub DEBUG { | ||||||||||
|
Subroutine
DEBUG: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 50 | 0 | ▶ | if (@_) { $DEBUG=$_[0] }; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | 0 | return $DEBUG | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | 0 | ▶ | sub _die { | ||||||||||
|
Subroutine
_die: not called CC=2 SCAR=17.9
| |||||||||||||
| 55 | 0 | my $msg = join q{},@_; | |||||||||||
| 56 | 0 | chomp $msg; | |||||||||||
| 57 | 0 | ▶ | if ($DEBUG) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 58 | 0 | local $Carp::CarpLevel=1; | |||||||||||
| 59 | 0 | confess($msg); | |||||||||||
| 60 | } else { | ||||||||||||
| 61 | 0 | die "$msg\n"; | |||||||||||
| 62 | } | ||||||||||||
| 63 | } | ||||||||||||
| 64 | |||||||||||||
| 65 | 103 | ▶ | sub _debug { | ||||||||||
|
Subroutine
_debug: called CC=4 SCAR=27.4
| |||||||||||||
| 66 | 103 | ▶ | return unless $DEBUG; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 67 | 0 | my $level = 1; | |||||||||||
| 68 | 0 | my $node = undef; | |||||||||||
| 69 | 0 | ▶ | if (ref($_[0])) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 70 | 0 | $level=$_[0]->{level}; | |||||||||||
| 71 | 0 | $node=$_[0]->{node}; | |||||||||||
| 72 | 0 | shift; | |||||||||||
| 73 | } | ||||||||||||
| 74 | 0 | ▶ | return unless abs($DEBUG)>=$level; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 75 | 0 | my $msg=join q{},@_; | |||||||||||
| 76 | 0 | chomp $msg; | |||||||||||
| 77 | 0 | $msg =~ s/\%N/_element_address($node)/e; | |||||||||||
| 78 | 0 | print STDERR "Treex::PML: $msg\n" | |||||||||||
| 79 | } | ||||||||||||
| 80 | |||||||||||||
| 81 | 0 | ▶ | sub _warn { | ||||||||||
|
Subroutine
_warn: not called CC=2 SCAR=17.9
| |||||||||||||
| 82 | 0 | my $msg = join q{},@_; | |||||||||||
| 83 | 0 | chomp $msg; | |||||||||||
| 84 | 0 | ▶ | if ($DEBUG<0) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 85 | 0 | Carp::cluck("Treex::PML: WARNING: $msg"); | |||||||||||
| 86 | } else { | ||||||||||||
| 87 | 0 | warn("Treex::PML: WARNING: $msg\n"); | |||||||||||
| 88 | } | ||||||||||||
| 89 | } | ||||||||||||
| 90 | |||||||||||||
| 91 | |||||||||||||
| 92 | |||||||||||||
| 93 | 9 | 1; | |||||||||||
| 94 | __END__ | ||||||||||||