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