IDL/ParserFactory.pm

filter: Statementstmt 17.3% 26 / 150 Branchbran 0.0% 0 / 62 Conditioncond 0.0% 0 / 41 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 40.0% 8 / 20 Podpod 0.0% 0 / 1 totaltotal 11.3% 34 / 300 CC 47 SCAR 36.9
CC
47
Cov
10%
getopts
74.5
Run
72.0
DisplayStatus
72.0
CRAP 40.2
« IDL/Parser22.pm ↑ Summary IDL/RepositoryIdVisitor.pm »
1
2 #
3 # Interface Definition Language (OMG IDL CORBA v3.0)
4 #
5
6 package CORBA::IDL::ParserFactory;
7
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 1 our $VERSION = '2.60';
12
13 1 ▶use CORBA::IDL::Lexer;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use CORBA::IDL::Symbtab;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use CORBA::IDL::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
16
17 0 ▶sub create {
Subroutine create: not called CC=3 SCAR=24.8
Pod undocumented
18 0 my ($version) = @_;
19
20 0 ▶ $version = '30' unless (defined $version);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 0 0 0
21 0 $version =~ s/\.//g;
22 0 eval "require CORBA::IDL::Parser$version";
23 0 ▶ die $@ if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
24 0 my $parser = new CORBA::IDL::Parser();
25 0 $parser->YYData->{verbose_error} = 1; # 0, 1
26 0 $parser->YYData->{verbose_warning} = 1; # 0, 1
27 0 $parser->YYData->{verbose_info} = 1; # 0, 1
28 0 $parser->YYData->{verbose_deprecated} = 0; # 0, 1 (concerns only version '2.4' and upper)
29 0 $parser->YYData->{collision_allowed} = 0; # 0, 1
30 0 $parser->YYData->{symbtab} = new CORBA::IDL::Symbtab($parser);
31 0 return $parser;
32 }
33
34 package CORBA::IDL::Parser;
35
36 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
38
39 0 ▶sub getopts { # from Getopt::Std
Subroutine getopts: not called CC=9 SCAR=43.1
40 1 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 0 my $parser = shift;
42 0 local($argumentative) = @_;
43 0 local(@args, $_, $first, $rest);
44
45 0 $parser->YYData->{args} = [];
46 0 @args = split( / */, $argumentative );
47 0 ▶ while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV and ($_ = $ARGV[0]) =~ /^-(.)(.*)/) 0 0 0
Condition0%0/3
@ARGV and ($_ = $ARGV[0]) =~ /^-(.)(.*)/
!ll&&!rl&&r
000
MC/DC0%0/2
@ARGV and ($_ = $ARGV[0]) =~ /^-(.)(.*)/
@ARGV ($_ = $ARGV[0]) =~ /^-(.)(.*)/
Truth table0%0/3
A and B
A= @ARGVB= ($_ = $ARGV[0]) =~ /^-(.)(.*)/
ABresult
0X0
100
111
48 0 ($first, $rest) = ($1, $2);
49 0 ▶ if (/^--$/) { # early exit if --
Branch: 1 branch
BranchTrueFalseTotal
if (/^--$/) 0 0 0
50 0 shift(@ARGV);
51 0 last;
52 }
53 0 $pos = index($argumentative,$first);
54 0 ▶ if ($pos >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos >= 0) { } 0 0 0
55 0 ▶ if (defined($args[$pos+1]) and ($args[$pos+1] eq ':')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args[$pos + 1] and $args[$pos + 1] eq ':') { } 0 0 0
Condition0%0/3
defined $args[$pos + 1] and $args[$pos + 1] eq ":"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args[$pos + 1] and $args[$pos + 1] eq ":"
defined $args[$pos + 1] $args[$pos + 1] eq ":"
Truth table0%0/3
A and B
A= defined $args[$pos + 1]B= $args[$pos + 1] eq ":"
ABresult
0X0
100
111
56 0 shift(@ARGV);
57 0 ▶ if ($rest eq q{}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest eq "") 0 0 0
58 0 $rest = shift(@ARGV);
59 }
60 0 $parser->YYData->{"opt_$first"} = $rest;
61 }
62 else {
63 0 $parser->YYData->{"opt_$first"} = 1;
64 0 ▶ if ($rest eq q{}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest eq '') { } 0 0 0
65 0 shift(@ARGV);
66 }
67 else {
68 0 $ARGV[0] = "-$rest";
69 }
70 }
71 }
72 else {
73 0 push @{$parser->YYData->{args}}, shift(@ARGV);
74 }
75 }
76 }
77
78 0 ▶sub Configure {
Subroutine Configure: not called CC=3 SCAR=24.8
79 0 my $parser = shift;
80 0 my %attr = @_;
81 0 ▶ while ( my ($key, $value) = each(%attr) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %attr) 0 0 0
82 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
83 0 $parser->YYData->{$key} = $value;
84 }
85 }
86 0 return $parser;
87 }
88
89 0 ▶sub Run {
Subroutine Run: not called CC=8 SCAR=42.8
90 0 my $parser = shift;
91 0 my $preprocessor = $parser->YYData->{preprocessor};
92
93 0 ▶ if ($preprocessor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($preprocessor) { } 0 0 0
94 0 my @args;
95 0 @args = @{$parser->YYData->{args}}
96 0 ▶ if (exists $parser->YYData->{args});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"args"} 0 0 0
97 0 push @args, @_;
98
99 0 ▶ open $parser->YYData->{fh}, "$preprocessor @args|"
Branch: 1 branch
BranchTrueFalseTotal
open $parser->YYData->{"fh"}, "$preprocessor @args|" or die "can't open @_ ($!).\n" 0 0 0
100 or die "can't open @_ ($!).\n";
101 }
102 else {
103 0 my $file = shift;
104 0 ▶ if (ref $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file) { } 0 0 0
105 0 $parser->YYData->{fh} = $file;
106 0 $parser->YYData->{srcname} = shift;
107 }
108 else {
109 0 ▶ open $parser->YYData->{fh}, $file
Branch: 1 branch
BranchTrueFalseTotal
open $parser->YYData->{"fh"}, $file or die "can't open $file ($!).\n" 0 0 0
110 or die "can't open $file ($!).\n";
111 0 ▶ $parser->YYData->{srcname} = shift || $file;
Condition0%0/3
shift() || $file
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $file
shift() $file
Truth table0%0/3
A || B
A= shift()B= $file
ABresult
1X1
011
000
112 }
113 0 my @st = stat($parser->YYData->{srcname});
114 0 $parser->YYData->{srcname_size} = $st[7];
115 0 $parser->YYData->{srcname_mtime} = $st[9];
116 }
117
118 0 CORBA::IDL::Lexer::InitLexico($parser);
119 0 $parser->YYData->{doc} = q{};
120 0 $parser->YYData->{curr_node} = undef;
121 0 $parser->YYData->{curr_itf} = undef;
122 0 $parser->YYData->{prop} = 0;
123 0 $parser->YYData->{native} = 0;
124 $parser->YYParse(
125 yylex => \&CORBA::IDL::Lexer::Lexer,
126 0 ▶ yyerror => sub { return; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
127 # yydebug => 0x17,
128 0 );
129
130 # Bit Value Outputs
131 # 0x01 Token reading (useful for Lexer debugging)
132 # 0x02 States information
133 # 0x04 Driver actions (shifts, reduces, accept...)
134 # 0x08 Parse Stack dump
135 # 0x10 Error Recovery tracing
136
137 0 close $parser->YYData->{fh};
138 0 delete $parser->{RULES};
139 0 delete $parser->{STATES};
140 0 delete $parser->{STACK};
141
142 0 ▶ if (exists $parser->YYData->{symbtab}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{"symbtab"}) 0 0 0
143 0 $parser->YYData->{symbtab}->CheckForward();
144 0 $parser->YYData->{symbtab}->CheckRepositoryID();
145 }
146 }
147
148 0 ▶sub DisplayStatus {
Subroutine DisplayStatus: not called CC=8 SCAR=42.8
149 0 my $parser = shift;
150 0 ▶ if (exists $parser->YYData->{nb_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{"nb_error"}) 0 0 0
151 0 my $nb = $parser->YYData->{nb_error};
152 0 print "$nb error(s).\n"
153 }
154 0 ▶ if ( $parser->YYData->{verbose_warning}
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->YYData->{"verbose_warning"} and exists $parser->YYData->{"nb_warning"}) 0 0 0
Condition0%0/3
$parser->YYData->{"verbose_warning"} and exists $parser->YYData->{"nb_warning"}
!ll&&!rl&&r
000
MC/DC0%0/2
$parser->YYData->{"verbose_warning"} and exists $parser->YYData->{"nb_warning"}
$parser->YYData->{"verbose_warning"} exists $parser->YYData->{"nb_warning"}
Truth table0%0/3
A and B
A= $parser->YYData->{"verbose_warning"}B= exists $parser->YYData->{"nb_warning"}
ABresult
0X0
100
111
155 and exists $parser->YYData->{nb_warning} ) {
156 0 my $nb = $parser->YYData->{nb_warning};
157 0 print "$nb warning(s).\n"
158 }
159 0 ▶ if ( $parser->YYData->{verbose_info}
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->YYData->{"verbose_info"} and exists $parser->YYData->{"nb_info"}) 0 0 0
Condition0%0/3
$parser->YYData->{"verbose_info"} and exists $parser->YYData->{"nb_info"}
!ll&&!rl&&r
000
MC/DC0%0/2
$parser->YYData->{"verbose_info"} and exists $parser->YYData->{"nb_info"}
$parser->YYData->{"verbose_info"} exists $parser->YYData->{"nb_info"}
Truth table0%0/3
A and B
A= $parser->YYData->{"verbose_info"}B= exists $parser->YYData->{"nb_info"}
ABresult
0X0
100
111
160 and exists $parser->YYData->{nb_info} ) {
161 0 my $nb = $parser->YYData->{nb_info};
162 0 print "$nb info(s).\n"
163 }
164 0 ▶ if ( $parser->YYData->{verbose_deprecated}
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->YYData->{"verbose_deprecated"} and exists $parser->YYData->{"nb_deprecated"}) 0 0 0
Condition0%0/3
$parser->YYData->{"verbose_deprecated"} and exists $parser->YYData->{"nb_deprecated"}
!ll&&!rl&&r
000
MC/DC0%0/2
$parser->YYData->{"verbose_deprecated"} and exists $parser->YYData->{"nb_deprecated"}
$parser->YYData->{"verbose_deprecated"} exists $parser->YYData->{"nb_deprecated"}
Truth table0%0/3
A and B
A= $parser->YYData->{"verbose_deprecated"}B= exists $parser->YYData->{"nb_deprecated"}
ABresult
0X0
100
111
165 and exists $parser->YYData->{nb_deprecated} ) {
166 0 my $nb = $parser->YYData->{nb_deprecated};
167 0 print "$nb deprecated(s).\n"
168 }
169 }
170
171 0 ▶sub Export {
Subroutine Export: not called CC=2 SCAR=17.9
172 0 my $parser = shift;
173 0 ▶ if ( our $IDL_VERSION ge '3.0' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (our $IDL_VERSION ge "3.0") 0 0 0
174 0 $parser->YYData->{symbtab}->Export();
175 }
176 }
177
178 0 ▶sub getRoot {
Subroutine getRoot: not called CC=3 SCAR=24.8
179 0 my $parser = shift;
180 0 ▶ if ( exists $parser->YYData->{root}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{"root"} and not exists $parser->YYData->{"nb_error"}) 0 0 0
Condition0%0/3
exists $parser->YYData->{"root"} and not exists $parser->YYData->{"nb_error"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $parser->YYData->{"root"} and not exists $parser->YYData->{"nb_error"}
exists $parser->YYData->{"root"} not exists $parser->YYData->{"nb_error"}
Truth table0%0/3
A and not(B)
A= exists $parser->YYData->{"root"}B= not exists $parser->YYData->{"nb_error"}
ABresult
0X0
100
111
181 and ! exists $parser->YYData->{nb_error} ) {
182 0 return $parser->YYData->{root};
183 }
184 0 return undef;
185 }
186
187 0 ▶sub Error {
Subroutine Error: not called CC=6 SCAR=37.4
188 0 my $parser = shift;
189 0 my ($msg) = @_;
190
191 0 ▶ $msg ||= "Syntax error.\n";
Condition0%0/2
$msg ||= "Syntax error.\n"
l!l
00
MC/DC0%0/1
$msg ||= "Syntax error.\n"
$msg
Truth table0%0/2
A
A= $msg
Aresult
11
00
192
193 0 ▶ if (exists $parser->YYData->{nb_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{'nb_error'}) { } 0 0 0
194 0 $parser->YYData->{nb_error} ++;
195 }
196 else {
197 0 $parser->YYData->{nb_error} = 1;
198 }
199
200 0 ▶ unless (exists $parser->YYData->{filename}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{'filename'}) { } 0 0 0
201 0 print STDOUT "#No parsed input : ",$msg;
202 }
203 else {
204 print STDOUT '#',$parser->YYData->{filename},':',$parser->YYData->{lineno},'#Error: ',$msg
205 if ( exists $parser->YYData->{verbose_error}
206 0 ▶ and $parser->YYData->{verbose_error});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"verbose_error"} and $parser->YYData->{"verbose_error"} 0 0 0
Condition0%0/3
exists $parser->YYData->{"verbose_error"} and $parser->YYData->{"verbose_error"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $parser->YYData->{"verbose_error"} and $parser->YYData->{"verbose_error"}
exists $parser->YYData->{"verbose_error"} $parser->YYData->{"verbose_error"}
Truth table0%0/3
A and B
A= exists $parser->YYData->{"verbose_error"}B= $parser->YYData->{"verbose_error"}
ABresult
0X0
100
111
207 }
208 }
209
210 0 ▶sub Warning {
Subroutine Warning: not called CC=5 SCAR=34.0
211 0 my $parser = shift;
212 0 my ($msg) = @_;
213
214 0 ▶ $msg ||= ".\n";
Condition0%0/2
$msg ||= ".\n"
l!l
00
MC/DC0%0/1
$msg ||= ".\n"
$msg
Truth table0%0/2
A
A= $msg
Aresult
11
00
215
216 0 ▶ if (exists $parser->YYData->{nb_warning}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{'nb_warning'}) { } 0 0 0
217 0 $parser->YYData->{nb_warning} ++;
218 }
219 else {
220 0 $parser->YYData->{nb_warning} = 1;
221 }
222
223 print STDOUT '#',$parser->YYData->{filename},':',$parser->YYData->{lineno},'#Warning: ',$msg
224 if ( exists $parser->YYData->{verbose_warning}
225 0 ▶ and $parser->YYData->{verbose_warning});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"verbose_warning"} and $parser->YYData->{"verbose_warning"} 0 0 0
Condition0%0/3
exists $parser->YYData->{"verbose_warning"} and $parser->YYData->{"verbose_warning"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $parser->YYData->{"verbose_warning"} and $parser->YYData->{"verbose_warning"}
exists $parser->YYData->{"verbose_warning"} $parser->YYData->{"verbose_warning"}
Truth table0%0/3
A and B
A= exists $parser->YYData->{"verbose_warning"}B= $parser->YYData->{"verbose_warning"}
ABresult
0X0
100
111
226 }
227
228 0 ▶sub Info {
Subroutine Info: not called CC=5 SCAR=34.0
229 0 my $parser = shift;
230 0 my ($msg) = @_;
231
232 0 ▶ $msg ||= ".\n";
Condition0%0/2
$msg ||= ".\n"
l!l
00
MC/DC0%0/1
$msg ||= ".\n"
$msg
Truth table0%0/2
A
A= $msg
Aresult
11
00
233
234 0 ▶ if (exists $parser->YYData->{nb_info}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{'nb_info'}) { } 0 0 0
235 0 $parser->YYData->{nb_info} ++;
236 }
237 else {
238 0 $parser->YYData->{nb_info} = 1;
239 }
240
241 print STDOUT '#',$parser->YYData->{filename},':',$parser->YYData->{lineno},'#Info: ',$msg
242 if ( exists $parser->YYData->{verbose_info}
243 0 ▶ and $parser->YYData->{verbose_info});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"verbose_info"} and $parser->YYData->{"verbose_info"} 0 0 0
Condition0%0/3
exists $parser->YYData->{"verbose_info"} and $parser->YYData->{"verbose_info"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $parser->YYData->{"verbose_info"} and $parser->YYData->{"verbose_info"}
exists $parser->YYData->{"verbose_info"} $parser->YYData->{"verbose_info"}
Truth table0%0/3
A and B
A= exists $parser->YYData->{"verbose_info"}B= $parser->YYData->{"verbose_info"}
ABresult
0X0
100
111
244 }
245
246 0 ▶sub Deprecated {
Subroutine Deprecated: not called CC=5 SCAR=34.0
247 0 my $parser = shift;
248 0 my ($msg) = @_;
249
250 0 ▶ $msg ||= ".\n";
Condition0%0/2
$msg ||= ".\n"
l!l
00
MC/DC0%0/1
$msg ||= ".\n"
$msg
Truth table0%0/2
A
A= $msg
Aresult
11
00
251
252 0 ▶ if (exists $parser->YYData->{nb_deprecated}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{'nb_deprecated'}) { } 0 0 0
253 0 $parser->YYData->{nb_deprecated} ++;
254 }
255 else {
256 0 $parser->YYData->{nb_deprecated} = 1;
257 }
258
259 print STDOUT '#',$parser->YYData->{filename},':',$parser->YYData->{lineno},'#Deprecated: ',$msg
260 if ( exists $parser->YYData->{verbose_deprecated}
261 0 ▶ and $parser->YYData->{verbose_deprecated});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"verbose_deprecated"} and $parser->YYData->{"verbose_deprecated"} 0 0 0
Condition0%0/3
exists $parser->YYData->{"verbose_deprecated"} and $parser->YYData->{"verbose_deprecated"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $parser->YYData->{"verbose_deprecated"} and $parser->YYData->{"verbose_deprecated"}
exists $parser->YYData->{"verbose_deprecated"} $parser->YYData->{"verbose_deprecated"}
Truth table0%0/3
A and B
A= exists $parser->YYData->{"verbose_deprecated"}B= $parser->YYData->{"verbose_deprecated"}
ABresult
0X0
100
111
262 }
263
264 1 1;
265
« IDL/Parser22.pm ↑ Summary IDL/RepositoryIdVisitor.pm »