Farly/ASA/Builder.pm

filter: Statementstmt 94.5% 69 / 73 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 17 / 17 Podpod 0.0% 0 / 3 totaltotal 90.7% 88 / 97 CC 4 SCAR 4.9
CC
4
Cov
92%
run
4.2
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« Farly/Value/Integer.pm ↑ Summary Farly/ASA/Parser.pm »
1 package Farly::ASA::Builder;
2
3 8 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Farly::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use Farly::ASA::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use Farly::ASA::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use Farly::ASA::Annotator;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶use Farly::ASA::Rewriter;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 8 ▶use Farly::ASA::Generator;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 ▶use Farly::ASA::PortFormatter;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 8 ▶use Farly::ASA::ProtocolFormatter;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 8 ▶use Farly::ASA::ICMPFormatter;
Subroutine BEGIN: called CC=1 SCAR=0.0
17
18 8 our $VERSION = '0.26';
19 8 our @ISA = 'Farly::Builder';
20
21 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
22 6 my ($class) = @_;
23
24 #call the constructor of the parent class
25 6 my $self = $class->SUPER::new();
26 6 bless $self, $class;
27
28 6 $log->info("$self NEW");
29
30 6 return $self;
31 }
32
33 5 ▶sub run {
Subroutine run: called CC=4 SCAR=14.3
Pod undocumented
34 5 my ($self) = @_;
35
36 5 my $filter = Farly::ASA::Filter->new();
37 5 my $parser = Farly::ASA::Parser->new();
38 5 my $annotator = Farly::ASA::Annotator->new();
39 5 my $rewriter = Farly::ASA::Rewriter->new();
40 5 my $generator = Farly::ASA::Generator->new();
41
42 5 $filter->set_file( $self->file() );
43
44 5 my @preprocessed_file = $filter->run();
45
46 5 ▶ confess "configuration not recognized"
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @preprocessed_file > 0 0 5 5
47 unless ( scalar(@preprocessed_file) > 0 );
48
49 5 my $parse_tree;
50
51 5 foreach my $line (@preprocessed_file) {
52
53 325 eval {
54
55 #get the parse tree for the current line
56 325 $parse_tree = $parser->parse($line);
57
58 #turn the tokens into objects
59 325 $annotator->visit($parse_tree);
60
61 #rewrite the parse tree into an abstract syntax tree (AST)
62 325 my $ast = $rewriter->rewrite($parse_tree);
63
64 #convert the AST into an Farly::Object object
65 #which is stored in the generator's container object
66 325 $generator->visit($ast);
67 };
68 325 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 325 325
69 0 my $err = $@;
70 0 $log->fatal( $self->file() . "\n: $line \n $err\n" );
71 0 chomp($line);
72 0 die "Problem at line :\n$line\nError : $@";
73 }
74
75 }
76
77 5 $self->{CONTAINER} = $generator->container();
78
79 5 return;
80 }
81
82 5 ▶sub result {
Subroutine result: called CC=1 SCAR=0.0
Pod undocumented
83 5 return $_[0]->{CONTAINER};
84 }
85
86 8 1;
87 __END__
« Farly/Value/Integer.pm ↑ Summary Farly/ASA/Parser.pm »