line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Magic; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#use 5.008002; |
4
|
1
|
|
|
1
|
|
23974
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
use Config::Magic::Grammar |
7
|
|
|
|
|
|
|
#use Data::Dumper; |
8
|
|
|
|
|
|
|
#use Tie::IxHash; |
9
|
1
|
|
|
1
|
|
2126
|
require Exporter; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
14
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
15
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# This allows declaration use Config::Magic ':all'; |
18
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
19
|
|
|
|
|
|
|
# will save memory. |
20
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw(parse new get_result) ] ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT = qw(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = '0.801'; |
27
|
|
|
|
|
|
|
#Used to turn on and off newline checking. Some techniques can skip over newlines, and some can't. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Preloaded methods go here. |
30
|
|
|
|
|
|
|
sub parse |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
my $self=shift; |
33
|
|
|
|
|
|
|
my ($FILE,$text); |
34
|
|
|
|
|
|
|
return $self->{'parser'}->start(shift) if(scalar(@_)); |
35
|
|
|
|
|
|
|
open(FILE,"<".$self->{'filename'}) || die "Unable to open file " . $self->{'filename'} . " in Config::Magic\n"; |
36
|
|
|
|
|
|
|
my @lines=; |
37
|
|
|
|
|
|
|
close(FILE); |
38
|
|
|
|
|
|
|
for my $line (@lines) {$text .= $line; }; |
39
|
|
|
|
|
|
|
$self->{'result'}=$self->{'parser'}->start($text); |
40
|
|
|
|
|
|
|
return $self->{'result'}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub get_result |
44
|
|
|
|
|
|
|
{my $self=shift; |
45
|
|
|
|
|
|
|
return $self->{'result'} if(exists($self->{'result'})); } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub setordered |
48
|
|
|
|
|
|
|
{my $self=shift; |
49
|
|
|
|
|
|
|
$self->{'parser'}->{'ordered'}=shift; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
53
|
|
|
|
|
|
|
my %dat; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#$::RD_HINT=1; |
56
|
|
|
|
|
|
|
$::RD_AUTOACTION = q{ ($#item>1)?[@item[1..$#item]]:$item[1]}; |
57
|
|
|
|
|
|
|
# $::RD_TRACE=1; |
58
|
|
|
|
|
|
|
$dat{'filename'} = $_[1] if(scalar(@_)>1); |
59
|
|
|
|
|
|
|
$dat{'parser'}=Config::Magic::Grammar->new(); |
60
|
|
|
|
|
|
|
# $dat{parser}->{skip}=qr{((\/[*].*?[*]\/)|((#|;|\/\/).*?\n)|\s)*}sm; |
61
|
|
|
|
|
|
|
$dat{'parser'}->{'ordered'} = 0; |
62
|
|
|
|
|
|
|
$dat{'parser'}->{'ordered'} = $_[2] if(scalar(@_)>2); |
63
|
|
|
|
|
|
|
# bless $dat{'parser'}, "Parse::RecDescent"; |
64
|
|
|
|
|
|
|
bless(\%dat); |
65
|
|
|
|
|
|
|
return \%dat; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |