line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Lexer.pm,v 1.10 2013/07/27 00:34:39 Paulo Exp $
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Parse::FSM::Error;
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Parse::FSM::Error - Format error and waring messages
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
621
|
use 5.010;
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
88
|
|
16
|
2
|
|
|
2
|
|
12
|
use strict;
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
73
|
|
17
|
2
|
|
|
2
|
|
10
|
use warnings;
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
115
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.11';
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Parse::FSM::Error qw( error warning );
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
error($message);
|
28
|
|
|
|
|
|
|
error($message, $file, $line_nr);
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
warning($message);
|
31
|
|
|
|
|
|
|
warning($message, $file, $line_nr);
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module formats an error or warning mesage and displays it on C,
|
36
|
|
|
|
|
|
|
exiting with die for C.
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 EXPORTS
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
None by default.
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
45
|
2
|
|
|
2
|
|
11
|
use Exporter 'import';
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
644
|
|
46
|
|
|
|
|
|
|
our @EXPORT_OK = qw( error warning );
|
47
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 error
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Formats the error message, shows it on C and dies.
|
52
|
|
|
|
|
|
|
The file name and line number are optional.
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
57
|
|
|
|
|
|
|
sub error {
|
58
|
27
|
|
|
27
|
1
|
5096
|
die _error_msg("Error", @_);
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 warning
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Formats the warning message and shows it on C.
|
65
|
|
|
|
|
|
|
The file name and line number are optional.
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
70
|
|
|
|
|
|
|
sub warning {
|
71
|
23
|
|
|
23
|
1
|
4768
|
warn _error_msg("Warning", @_);
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
75
|
|
|
|
|
|
|
sub _error_msg {
|
76
|
50
|
|
|
50
|
|
97
|
my($type, $message, $file, $line_nr) = @_;
|
77
|
|
|
|
|
|
|
|
78
|
50
|
100
|
|
|
|
115
|
$file = defined($file) ? "file '$file'" : undef;
|
79
|
50
|
100
|
|
|
|
71
|
$line_nr = $line_nr ? "line $line_nr" : undef;
|
80
|
58
|
|
|
|
|
108
|
my $pos = (defined($file) || defined($line_nr)) ?
|
81
|
50
|
100
|
100
|
|
|
208
|
"at ".join(", ", grep {defined} $file, $line_nr) :
|
82
|
|
|
|
|
|
|
undef;
|
83
|
|
|
|
|
|
|
|
84
|
50
|
100
|
|
|
|
83
|
if (defined($message)) {
|
85
|
48
|
|
|
|
|
138
|
$message =~ s/\s+\z//; # in case message comes from die, has a "\n"
|
86
|
48
|
100
|
|
|
|
77
|
if ($message eq "") {
|
87
|
4
|
|
|
|
|
7
|
undef $message;
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
else {
|
90
|
44
|
|
|
|
|
62
|
$message = ": ".$message;
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
|
94
|
50
|
|
|
|
|
61
|
return join(" ", grep {defined} $type, $pos, $message)."\n";
|
|
150
|
|
|
|
|
365
|
|
95
|
|
|
|
|
|
|
}
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR, BUGS, FEEDBACK, LICENSE, COPYRIGHT
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
See L
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1;
|