ASN1/parser.pm

filter: Statementstmt 78.2% 360 / 460 Branchbran 68.0% 113 / 166 Conditioncond 53.5% 38 / 71 MC/DCmcdc 44.1% 15 / 34 Subroutinesub 63.1% 12 / 19 Podpod 0.0% 0 / 14 totaltotal 70.4% 538 / 764 CC 111 SCAR 37.8
CC
111
Cov
73%
expand_ops
110.0
yy_err_recover
72.0
yyparse
68.9
CRAP 43.7
« ASN1/Debug.pm ↑ Summary ASN1/IO.pm »
1 #$yysccsid = "@(#)yaccpar 1.8 (Berkeley) 01/20/91 (Perl 2.0 12/31/92)";
2 # 24 "parser.y"
3 ;# Copyright (c) 2000-2005 Graham Barr <gbarr@pobox.com>. All rights reserved.
4 ;# This program is free software; you can redistribute it and/or
5 ;# modify it under the same terms as Perl itself.
6  
7 package Convert::ASN1::parser;
8 32 $Convert::ASN1::parser::VERSION = '0.37';
9 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 32 ▶use Convert::ASN1 qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 32 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
12 $asn $yychar $yyerrflag $yynerrs $yyn @yyss
13 $yyssp $yystate @yyvs $yyvsp $yylval $yys $yym $yyval
14 32 );
15  
16 32 ▶BEGIN { Convert::ASN1->_internal_syms }
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 32 my $yydebug=0;
19 32 my %yystate;
20  
21 32 my %base_type = (
22 BOOLEAN => [ asn_encode_tag(ASN_BOOLEAN), opBOOLEAN ],
23 INTEGER => [ asn_encode_tag(ASN_INTEGER), opINTEGER ],
24 BIT_STRING => [ asn_encode_tag(ASN_BIT_STR), opBITSTR ],
25 OCTET_STRING => [ asn_encode_tag(ASN_OCTET_STR), opSTRING ],
26 STRING => [ asn_encode_tag(ASN_OCTET_STR), opSTRING ],
27 NULL => [ asn_encode_tag(ASN_NULL), opNULL ],
28 OBJECT_IDENTIFIER => [ asn_encode_tag(ASN_OBJECT_ID), opOBJID ],
29 REAL => [ asn_encode_tag(ASN_REAL), opREAL ],
30 ENUMERATED => [ asn_encode_tag(ASN_ENUMERATED), opINTEGER ],
31 ENUM => [ asn_encode_tag(ASN_ENUMERATED), opINTEGER ],
32 'RELATIVE-OID' => [ asn_encode_tag(ASN_RELATIVE_OID), opROID ],
33  
34 SEQUENCE => [ asn_encode_tag(ASN_SEQUENCE | ASN_CONSTRUCTOR), opSEQUENCE ],
35 EXPLICIT => [ asn_encode_tag(ASN_SEQUENCE | ASN_CONSTRUCTOR), opEXPLICIT ],
36 SET => [ asn_encode_tag(ASN_SET | ASN_CONSTRUCTOR), opSET ],
37  
38 ObjectDescriptor => [ asn_encode_tag(ASN_UNIVERSAL | 7), opSTRING ],
39 UTF8String => [ asn_encode_tag(ASN_UNIVERSAL | 12), opUTF8 ],
40 NumericString => [ asn_encode_tag(ASN_UNIVERSAL | 18), opSTRING ],
41 PrintableString => [ asn_encode_tag(ASN_UNIVERSAL | 19), opSTRING ],
42 TeletexString => [ asn_encode_tag(ASN_UNIVERSAL | 20), opSTRING ],
43 T61String => [ asn_encode_tag(ASN_UNIVERSAL | 20), opSTRING ],
44 VideotexString => [ asn_encode_tag(ASN_UNIVERSAL | 21), opSTRING ],
45 IA5String => [ asn_encode_tag(ASN_UNIVERSAL | 22), opSTRING ],
46 UTCTime => [ asn_encode_tag(ASN_UNIVERSAL | 23), opUTIME ],
47 GeneralizedTime => [ asn_encode_tag(ASN_UNIVERSAL | 24), opGTIME ],
48 GraphicString => [ asn_encode_tag(ASN_UNIVERSAL | 25), opSTRING ],
49 VisibleString => [ asn_encode_tag(ASN_UNIVERSAL | 26), opSTRING ],
50 ISO646String => [ asn_encode_tag(ASN_UNIVERSAL | 26), opSTRING ],
51 GeneralString => [ asn_encode_tag(ASN_UNIVERSAL | 27), opSTRING ],
52 CharacterString => [ asn_encode_tag(ASN_UNIVERSAL | 28), opSTRING ],
53 UniversalString => [ asn_encode_tag(ASN_UNIVERSAL | 28), opSTRING ],
54 BMPString => [ asn_encode_tag(ASN_UNIVERSAL | 30), opSTRING ],
55 BCDString => [ asn_encode_tag(ASN_OCTET_STR), opBCD ],
56  
57 CHOICE => [ '', opCHOICE ],
58 ANY => [ '', opANY ],
59  
60 EXTENSION_MARKER => [ '', opEXTENSIONS ],
61 );
62  
63 32 my $tagdefault = 1; # 0:IMPLICIT , 1:EXPLICIT default
64  
65 ;# args: class,plicit
66 545 ▶sub need_explicit {
Subroutine need_explicit: called CC=3 SCAR=11.0
Pod undocumented
67 545 ▶ (defined($_[0]) && (defined($_[1])?$_[1]:$tagdefault));
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] and defined $_[1] ? $_[1] : $tagdefault 89 456 545
defined $_[1] ? : 18 71 89
68 }
69  
70 ;# Given an OP, wrap it in a SEQUENCE
71  
72 19 ▶sub explicit {
Subroutine explicit: called CC=1 SCAR=0.0
Pod undocumented
73 19 my $op = shift;
74 19 my @seq = @$op;
75  
76 19 @seq[cTYPE,cCHILD,cVAR,cLOOP] = ('EXPLICIT',[$op],undef,undef);
77 19 @{$op}[cTAG,cOPT] = ();
78  
79 19 \@seq;
80 }
81  
82 sub constWORD () { 1 }
83 sub constCLASS () { 2 }
84 sub constSEQUENCE () { 3 }
85 sub constSET () { 4 }
86 sub constCHOICE () { 5 }
87 sub constOF () { 6 }
88 sub constIMPLICIT () { 7 }
89 sub constEXPLICIT () { 8 }
90 sub constOPTIONAL () { 9 }
91 sub constLBRACE () { 10 }
92 sub constRBRACE () { 11 }
93 sub constCOMMA () { 12 }
94 sub constANY () { 13 }
95 sub constASSIGN () { 14 }
96 sub constNUMBER () { 15 }
97 sub constENUM () { 16 }
98 sub constCOMPONENTS () { 17 }
99 sub constPOSTRBRACE () { 18 }
100 sub constDEFINED () { 19 }
101 sub constBY () { 20 }
102 sub constEXTENSION_MARKER () { 21 }
103 sub constYYERRCODE () { 256 }
104 32 my @yylhs = ( -1,
105 0, 0, 2, 2, 3, 3, 6, 6, 6, 6,
106 8, 13, 13, 12, 14, 14, 14, 9, 9, 9,
107 10, 18, 18, 18, 18, 18, 19, 19, 11, 16,
108 16, 20, 20, 20, 21, 21, 1, 1, 1, 22,
109 22, 22, 24, 24, 24, 24, 23, 23, 23, 23,
110 15, 15, 4, 4, 5, 5, 5, 17, 17, 25,
111 7, 7,
112 );
113 32 my @yylen = ( 2,
114 1, 1, 3, 4, 4, 1, 1, 1, 1, 1,
115 3, 1, 1, 6, 1, 1, 1, 4, 4, 4,
116 4, 1, 1, 1, 2, 1, 0, 3, 1, 1,
117 2, 1, 3, 3, 4, 1, 0, 1, 2, 1,
118 3, 3, 2, 1, 1, 1, 4, 1, 3, 1,
119 0, 1, 0, 1, 0, 1, 1, 1, 3, 2,
120 0, 1,
121 );
122 32 my @yydefred = ( 0,
123 0, 54, 0, 50, 0, 1, 0, 0, 48, 0,
124 40, 0, 0, 0, 0, 57, 56, 0, 0, 0,
125 3, 0, 6, 0, 11, 0, 0, 0, 0, 49,
126 0, 41, 42, 0, 22, 0, 0, 0, 0, 46,
127 44, 0, 45, 0, 29, 47, 4, 0, 0, 0,
128 0, 7, 8, 9, 10, 0, 25, 0, 52, 43,
129 0, 0, 0, 0, 36, 0, 0, 32, 62, 5,
130 0, 0, 0, 58, 0, 18, 19, 0, 20, 0,
131 0, 28, 60, 21, 0, 0, 0, 34, 33, 59,
132 0, 0, 17, 15, 16, 0, 35, 14,
133 );
134 32 my @yydgoto = ( 5,
135 6, 7, 21, 8, 18, 51, 70, 9, 52, 53,
136 54, 55, 44, 96, 60, 66, 73, 45, 57, 67,
137 68, 10, 11, 46, 74,
138 );
139 32 my @yysindex = ( 2,
140 58, 0, 8, 0, 0, 0, 11, 123, 0, 3,
141 0, 59, 123, 19, 73, 0, 0, 92, 7, 7,
142 0, 123, 0, 119, 0, 59, 107, 109, 116, 0,
143 82, 0, 0, 119, 0, 107, 109, 84, 126, 0,
144 0, 90, 0, 132, 0, 0, 0, 7, 7, 10,
145 139, 0, 0, 0, 0, 141, 0, 143, 0, 0,
146 82, 156, 159, 82, 0, 160, 4, 0, 0, 0,
147 171, 158, 6, 0, 123, 0, 0, 123, 0, 10,
148 10, 0, 0, 0, 143, 124, 119, 0, 0, 0,
149 107, 109, 0, 0, 0, 90, 0, 0,
150 );
151 32 my @yyrindex = ( 155,
152 105, 0, 0, 0, 0, 0, 174, 111, 0, 80,
153 0, 105, 138, 0, 0, 0, 0, 0, 161, 145,
154 0, 138, 0, 0, 0, 105, 0, 0, 0, 0,
155 105, 0, 0, 0, 0, 29, 33, 70, 74, 0,
156 0, 46, 0, 0, 0, 0, 0, 45, 45, 0,
157 54, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 105, 0, 0, 105, 0, 0, 164, 0, 0, 0,
159 0, 0, 0, 0, 138, 0, 0, 138, 0, 0,
160 165, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 89, 93, 0, 0, 0, 25, 0, 0,
162 );
163 32 my @yygindex = ( 0,
164 85, 0, 151, 1, -12, 91, 0, 47, -18, -19,
165 -17, 157, 0, 0, 83, 0, 0, 0, 0, 0,
166 -3, 0, 127, 0, 95,
167 );
168 sub constYYTABLESIZE () { 181 }
169 32 my @yytable = ( 30,
170 24, 13, 1, 2, 41, 40, 42, 31, 2, 34,
171 64, 15, 22, 14, 19, 80, 84, 85, 3, 25,
172 20, 81, 4, 3, 51, 51, 22, 4, 23, 23,
173 65, 13, 24, 24, 12, 51, 51, 23, 13, 23,
174 23, 24, 51, 24, 24, 51, 23, 53, 53, 53,
175 24, 53, 53, 61, 61, 37, 51, 51, 23, 2,
176 2, 75, 86, 51, 78, 87, 94, 93, 95, 27,
177 27, 12, 23, 26, 26, 3, 88, 89, 27, 38,
178 27, 27, 26, 2, 26, 26, 26, 27, 23, 23,
179 38, 26, 24, 24, 27, 28, 29, 23, 59, 23,
180 23, 24, 56, 24, 24, 53, 23, 53, 53, 53,
181 24, 53, 53, 55, 55, 55, 48, 53, 49, 35,
182 53, 36, 37, 29, 35, 50, 91, 92, 29, 16,
183 17, 38, 62, 63, 39, 58, 38, 61, 55, 39,
184 55, 55, 55, 72, 39, 32, 33, 53, 53, 53,
185 55, 53, 53, 55, 37, 39, 69, 53, 53, 53,
186 71, 53, 53, 53, 53, 53, 76, 53, 53, 77,
187 79, 82, 83, 2, 30, 31, 47, 97, 98, 90,
188 43,
189 );
190 32 my @yycheck = ( 18,
191 13, 1, 1, 2, 24, 24, 24, 1, 2, 22,
192 1, 1, 12, 6, 12, 12, 11, 12, 17, 1,
193 18, 18, 21, 17, 0, 1, 26, 21, 0, 1,
194 21, 31, 0, 1, 6, 11, 12, 9, 6, 11,
195 12, 9, 18, 11, 12, 0, 18, 3, 4, 5,
196 18, 7, 8, 0, 1, 11, 11, 12, 12, 2,
197 2, 61, 75, 18, 64, 78, 86, 86, 86, 0,
198 1, 14, 26, 0, 1, 17, 80, 81, 9, 0,
199 11, 12, 9, 2, 11, 12, 14, 18, 0, 1,
200 11, 18, 0, 1, 3, 4, 5, 9, 9, 11,
201 12, 9, 19, 11, 12, 1, 18, 3, 4, 5,
202 18, 7, 8, 3, 4, 5, 10, 13, 10, 1,
203 16, 3, 4, 5, 1, 10, 3, 4, 5, 7,
204 8, 13, 48, 49, 16, 10, 13, 6, 1, 16,
205 3, 4, 5, 1, 0, 19, 20, 3, 4, 5,
206 13, 7, 8, 16, 0, 11, 18, 3, 4, 5,
207 20, 7, 8, 3, 4, 5, 11, 7, 8, 11,
208 11, 1, 15, 0, 11, 11, 26, 87, 96, 85,
209 24,
210 );
211 sub constYYFINAL () { 5 }
212  
213  
214  
215 sub constYYMAXTOKEN () { 21 }
216 0 ▶sub yyclearin { $yychar = -1; }
Subroutine yyclearin: not called CC=1 SCAR=6.9
Pod undocumented
217 0 ▶sub yyerrok { $yyerrflag = 0; }
Subroutine yyerrok: not called CC=1 SCAR=6.9
Pod undocumented
218 0 ▶sub YYERROR { ++$yynerrs; &yy_err_recover; }
Subroutine YYERROR: not called CC=1 SCAR=6.9
Pod undocumented
219 sub yy_err_recover
220 0 ▶{
Subroutine yy_err_recover: not called CC=8 SCAR=42.8
Pod undocumented
221 0 ▶ if ($yyerrflag < 3)
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yyerrflag < 3) { } 0 0 0
222 {
223 0 $yyerrflag = 3;
224 0 while (1)
225 {
226 0 ▶ if (($yyn = $yysindex[$yyss[$yyssp]]) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yyss[$Convert::ASN1::parser::yyssp]] and ($Convert::ASN1::parser::yyn += 256) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == 256) { } 0 0 0
Condition0%0/9
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yyss[$Convert::ASN1::parser::yyssp]] and ($Convert::ASN1::parser::yyn += 256) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == 256
!ll&&!rl&&r
000
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yyss[$Convert::ASN1::parser::yyssp]] and ($Convert::ASN1::parser::yyn += 256) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck
!ll&&!rl&&r
000
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yyss[$Convert::ASN1::parser::yyssp]] and ($Convert::ASN1::parser::yyn += 256) >= 0
!ll&&!rl&&r
000
MC/DC0%0/4
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yyss[$Convert::ASN1::parser::yyssp]] and ($Convert::ASN1::parser::yyn += 256) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == 256
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yyss[$Convert::ASN1::parser::yyssp]] ($Convert::ASN1::parser::yyn += 256) >= 0 $Convert::ASN1::parser::yyn <= $#yycheck $yycheck[$Convert::ASN1::parser::yyn] == 256
Truth table0%0/5
A and B and C and D
A= $Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yyss[$Convert::ASN1::parser::yyssp]]B= ($Convert::ASN1::parser::yyn += 256) >= 0C= $Convert::ASN1::parser::yyn <= $#yycheckD= $yycheck[$Convert::ASN1::parser::yyn] == 256
ABCDresult
0XXX0
10XX0
110X0
11100
11111
227 ($yyn += constYYERRCODE()) >= 0 &&
228 $yyn <= $#yycheck && $yycheck[$yyn] == constYYERRCODE())
229 {
230  
231  
232  
233  
234 0 $yyss[++$yyssp] = $yystate = $yytable[$yyn];
235 0 $yyvs[++$yyvsp] = $yylval;
236 0 next yyloop;
237 }
238 else
239 {
240  
241  
242  
243  
244 0 ▶ return(1) if $yyssp <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yyssp <= 0 0 0 0
245 0 --$yyssp;
246 0 --$yyvsp;
247 }
248 }
249 }
250 else
251 {
252 0 ▶ return (1) if $yychar == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yychar == 0 0 0 0
253 0 $yychar = -1;
254 0 next yyloop;
255 }
256 0 0;
257 } # yy_err_recover
258  
259 sub yyparse
260 116 ▶{
Subroutine yyparse: called CC=43 SCAR=42.3
Pod undocumented
261  
262 116 ▶ if ($yys = $ENV{'YYDEBUG'})
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yys = $ENV{"YYDEBUG"}) 0 116 116
263 {
264 0 ▶ $yydebug = int($1) if $yys =~ /^(\d)/;
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yys =~ /^(\d)/ 0 0 0
265 }
266  
267  
268 116 $yynerrs = 0;
269 116 $yyerrflag = 0;
270 116 $yychar = (-1);
271  
272 116 $yyssp = 0;
273 116 $yyvsp = 0;
274 116 $yyss[$yyssp] = $yystate = 0;
275  
276 116 yyloop: while(1)
277 {
278 yyreduce: {
279 6290 ▶ last yyreduce if ($yyn = $yydefred[$yystate]);
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yyn = $yydefred[$Convert::ASN1::parser::yystate] 2860 3430 6290
280 3430 ▶ if ($yychar < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yychar < 0) 1999 1431 3430
281 {
282 0 ▶ if (($yychar = &yylex) < 0) { $yychar = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (($Convert::ASN1::parser::yychar = &yylex) < 0) 0 1999 1999
283 }
284 3430 ▶ if (($yyn = $yysindex[$yystate]) && ($yyn += $yychar) >= 0 &&
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar) 1883 1547 3430
Condition44%4/9
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
!ll&&!rl&&r
015471883
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck
!ll&&!rl&&r
003430
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0
!ll&&!rl&&r
003430
MC/DC25%1/4
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate] ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 $Convert::ASN1::parser::yyn <= $#yycheck $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
Truth table40%2/5
A and B and C and D
A= $Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate]B= ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0C= $Convert::ASN1::parser::yyn <= $#yycheckD= $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
ABCDresult
0XXX0
10XX0
110X0
11100
11111
285 $yyn <= $#yycheck && $yycheck[$yyn] == $yychar)
286 {
287  
288  
289  
290  
291 1883 $yyss[++$yyssp] = $yystate = $yytable[$yyn];
292 1883 $yyvs[++$yyvsp] = $yylval;
293 1883 $yychar = (-1);
294 1883 ▶ --$yyerrflag if $yyerrflag > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yyerrflag > 0 0 1883 1883
295 1883 next yyloop;
296 }
297 1547 ▶ if (($yyn = $yyrindex[$yystate]) && ($yyn += $yychar) >= 0 &&
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar) 1547 0 1547
Condition33%3/9
$Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
!ll&&!rl&&r
001547
$Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck
!ll&&!rl&&r
001547
$Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0
!ll&&!rl&&r
001547
MC/DC0%0/4
$Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
$Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate] ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0 $Convert::ASN1::parser::yyn <= $#yycheck $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
Truth table20%1/5
A and B and C and D
A= $Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate]B= ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0C= $Convert::ASN1::parser::yyn <= $#yycheckD= $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yychar
ABCDresult
0XXX0
10XX0
110X0
11100
11111
298 $yyn <= $#yycheck && $yycheck[$yyn] == $yychar)
299 {
300 1547 $yyn = $yytable[$yyn];
301 1547 last yyreduce;
302 }
303 0 ▶ if (! $yyerrflag) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Convert::ASN1::parser::yyerrflag) 0 0 0
304 0 &yyerror('syntax error');
305 0 ++$yynerrs;
306 }
307 0 ▶ return undef if &yy_err_recover;
Branch: 1 branch
BranchTrueFalseTotal
if &yy_err_recover 0 0 0
308 } # yyreduce
309  
310  
311  
312  
313 4407 $yym = $yylen[$yyn];
314 4407 $yyval = $yyvs[$yyvsp+1-$yym];
315 switch:
316 {
317 4407 my $label = "State$yyn";
318 4407 ▶goto $label if exists $yystate{$label};
Branch: 1 branch
BranchTrueFalseTotal
if exists $yystate{$label} 3589 818 4407
319 818 last switch;
320 State1: {
321 # 107 "parser.y"
322 101 { $yyval = { '' => $yyvs[$yyvsp-0] };
323 101 last switch;
324 } }
325 State3: {
326 # 112 "parser.y"
327 15 {
328 15 $yyval = { $yyvs[$yyvsp-2], [$yyvs[$yyvsp-0]] };
329
330 15 last switch;
331 } }
332 State4: {
333 # 116 "parser.y"
334 123 {
335 123 $yyval=$yyvs[$yyvsp-3];
336 123 $yyval->{$yyvs[$yyvsp-2]} = [$yyvs[$yyvsp-0]];
337
338 123 last switch;
339 } }
340 State5: {
341 # 123 "parser.y"
342 138 {
343 138 $yyvs[$yyvsp-1]->[cTAG] = $yyvs[$yyvsp-3];
344 138 ▶ $yyval = need_explicit($yyvs[$yyvsp-3],$yyvs[$yyvsp-2]) ? explicit($yyvs[$yyvsp-1]) : $yyvs[$yyvsp-1];
Branch: 1 branch
BranchTrueFalseTotal
need_explicit($Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 3], $Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 2]) ? : 5 133 138
345
346 138 last switch;
347 } }
348 State11: {
349 # 137 "parser.y"
350 0 {
351 0 @{$yyval = []}[cTYPE,cCHILD] = ('COMPONENTS', $yyvs[$yyvsp-0]);
352
353 0 last switch;
354 } }
355 State14: {
356 # 147 "parser.y"
357 27 {
358 27 $yyvs[$yyvsp-1]->[cTAG] = $yyvs[$yyvsp-3];
359 27 @{$yyval = []}[cTYPE,cCHILD,cLOOP,cOPT] = ($yyvs[$yyvsp-5], [$yyvs[$yyvsp-1]], 1, $yyvs[$yyvsp-0]);
360 27 ▶ $yyval = explicit($yyval) if need_explicit($yyvs[$yyvsp-3],$yyvs[$yyvsp-2]);
Branch: 1 branch
BranchTrueFalseTotal
if need_explicit($Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 3], $Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 2]) 0 27 27
361
362 27 last switch;
363 } }
364 State18: {
365 # 160 "parser.y"
366 60 {
367 60 @{$yyval = []}[cTYPE,cCHILD] = ('SEQUENCE', $yyvs[$yyvsp-1]);
368
369 60 last switch;
370 } }
371 State19: {
372 # 164 "parser.y"
373 8 {
374 8 @{$yyval = []}[cTYPE,cCHILD] = ('SET', $yyvs[$yyvsp-1]);
375
376 8 last switch;
377 } }
378 State20: {
379 # 168 "parser.y"
380 46 {
381 46 @{$yyval = []}[cTYPE,cCHILD] = ('CHOICE', $yyvs[$yyvsp-1]);
382
383 46 last switch;
384 } }
385 State21: {
386 # 174 "parser.y"
387 0 {
388 0 @{$yyval = []}[cTYPE] = ('ENUM');
389
390 0 last switch;
391 } }
392 State22: {
393 # 179 "parser.y"
394 379 { @{$yyval = []}[cTYPE] = $yyvs[$yyvsp-0];
395 379 last switch;
396 } }
397 State23: {
398 # 180 "parser.y"
399 0 { @{$yyval = []}[cTYPE] = $yyvs[$yyvsp-0];
400 0 last switch;
401 } }
402 State24: {
403 # 181 "parser.y"
404 0 { @{$yyval = []}[cTYPE] = $yyvs[$yyvsp-0];
405 0 last switch;
406 } }
407 State25: {
408 # 183 "parser.y"
409 22 {
410 22 @{$yyval = []}[cTYPE,cCHILD,cDEFINE] = ('ANY',undef,$yyvs[$yyvsp-0]);
411
412 22 last switch;
413 } }
414 State26: {
415 # 186 "parser.y"
416 3 { @{$yyval = []}[cTYPE] = $yyvs[$yyvsp-0];
417 3 last switch;
418 } }
419 State27: {
420 # 189 "parser.y"
421 21 { $yyval=undef;
422 21 last switch;
423 } }
424 State28: {
425 # 190 "parser.y"
426 1 { $yyval=$yyvs[$yyvsp-0];
427 1 last switch;
428 } }
429 State30: {
430 # 196 "parser.y"
431 46 { $yyval = $yyvs[$yyvsp-0];
432 46 last switch;
433 } }
434 State31: {
435 # 197 "parser.y"
436 0 { $yyval = $yyvs[$yyvsp-1];
437 0 last switch;
438 } }
439 State32: {
440 # 201 "parser.y"
441 46 {
442 46 $yyval = [ $yyvs[$yyvsp-0] ];
443
444 46 last switch;
445 } }
446 State33: {
447 # 205 "parser.y"
448 0 {
449 0 push @{$yyval=$yyvs[$yyvsp-2]}, $yyvs[$yyvsp-0];
450
451 0 last switch;
452 } }
453 State34: {
454 # 209 "parser.y"
455 60 {
456 60 push @{$yyval=$yyvs[$yyvsp-2]}, $yyvs[$yyvsp-0];
457
458 60 last switch;
459 } }
460 State35: {
461 # 215 "parser.y"
462 103 {
463 103 @{$yyval=$yyvs[$yyvsp-0]}[cVAR,cTAG] = ($yyvs[$yyvsp-3],$yyvs[$yyvsp-2]);
464 103 ▶ $yyval = explicit($yyval) if need_explicit($yyvs[$yyvsp-2],$yyvs[$yyvsp-1]);
Branch: 1 branch
BranchTrueFalseTotal
if need_explicit($Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 2], $Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 1]) 0 103 103
465
466 103 last switch;
467 } }
468 State36: {
469 # 220 "parser.y"
470 3 {
471 3 @{$yyval=[]}[cTYPE] = 'EXTENSION_MARKER';
472
473 3 last switch;
474 } }
475 State37: {
476 # 226 "parser.y"
477 0 { $yyval = [];
478 0 last switch;
479 } }
480 State38: {
481 # 228 "parser.y"
482 141 {
483 141 my $extension = 0;
484 141 $yyval = [];
485 141 for my $i (@{$yyvs[$yyvsp-0]}) {
486 257 ▶ $extension = 1 if $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
if $i->[1] eq "EXTENSION_MARKER" 8 249 257
487 257 $i->[cEXT] = $i->[cOPT];
488 257 ▶ $i->[cEXT] = 1 if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 12 245 257
489 257 ▶ push @{$yyval}, $i unless $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
unless $i->[1] eq "EXTENSION_MARKER" 249 8 257
490 }
491 141 my $e = []; $e->[cTYPE] = 'EXTENSION_MARKER';
492 141 ▶ push @{$yyval}, $e if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 8 133 141
493
494 141 last switch;
495 } }
496 State39: {
497 # 241 "parser.y"
498 28 {
499 28 my $extension = 0;
500 28 $yyval = [];
501 28 for my $i (@{$yyvs[$yyvsp-1]}) {
502 28 ▶ $extension = 1 if $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
if $i->[1] eq "EXTENSION_MARKER" 0 28 28
503 28 $i->[cEXT] = $i->[cOPT];
504 28 ▶ $i->[cEXT] = 1 if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 0 28 28
505 28 ▶ push @{$yyval}, $i unless $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
unless $i->[1] eq "EXTENSION_MARKER" 28 0 28
506 }
507 28 my $e = []; $e->[cTYPE] = 'EXTENSION_MARKER';
508 0 ▶ push @{$yyval}, $e if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 0 28 28
509
510 28 last switch;
511 } }
512 State40: {
513 # 256 "parser.y"
514 169 {
515 169 $yyval = [ $yyvs[$yyvsp-0] ];
516
517 169 last switch;
518 } }
519 State41: {
520 # 260 "parser.y"
521 116 {
522 116 push @{$yyval=$yyvs[$yyvsp-2]}, $yyvs[$yyvsp-0];
523
524 116 last switch;
525 } }
526 State42: {
527 # 264 "parser.y"
528 0 {
529 0 push @{$yyval=$yyvs[$yyvsp-2]}, $yyvs[$yyvsp-0];
530
531 0 last switch;
532 } }
533 State43: {
534 # 270 "parser.y"
535 241 {
536 241 @{$yyval=$yyvs[$yyvsp-1]}[cOPT] = ($yyvs[$yyvsp-0]);
537
538 241 last switch;
539 } }
540 State47: {
541 # 279 "parser.y"
542 256 {
543 256 @{$yyval=$yyvs[$yyvsp-0]}[cVAR,cTAG] = ($yyvs[$yyvsp-3],$yyvs[$yyvsp-2]);
544 256 ▶ $yyval->[cOPT] = $yyvs[$yyvsp-3] if $yyval->[cOPT];
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yyval->[4] 37 219 256
545 256 ▶ $yyval = explicit($yyval) if need_explicit($yyvs[$yyvsp-2],$yyvs[$yyvsp-1]);
Branch: 1 branch
BranchTrueFalseTotal
if need_explicit($Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 2], $Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 1]) 14 242 256
546
547 256 last switch;
548 } }
549 State49: {
550 # 286 "parser.y"
551 21 {
552 21 @{$yyval=$yyvs[$yyvsp-0]}[cTAG] = ($yyvs[$yyvsp-2]);
553 21 ▶ $yyval = explicit($yyval) if need_explicit($yyvs[$yyvsp-2],$yyvs[$yyvsp-1]);
Branch: 1 branch
BranchTrueFalseTotal
if need_explicit($Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 2], $Convert::ASN1::parser::yyvs[$Convert::ASN1::parser::yyvsp - 1]) 0 21 21
554
555 21 last switch;
556 } }
557 State50: {
558 # 291 "parser.y"
559 8 {
560 8 @{$yyval=[]}[cTYPE] = 'EXTENSION_MARKER';
561
562 8 last switch;
563 } }
564 State51: {
565 # 296 "parser.y"
566 231 { $yyval = undef;
567 231 last switch;
568 } }
569 State52: {
570 # 297 "parser.y"
571 37 { $yyval = 1;
572 37 last switch;
573 } }
574 State53: {
575 # 301 "parser.y"
576 456 { $yyval = undef;
577 456 last switch;
578 } }
579 State55: {
580 # 305 "parser.y"
581 527 { $yyval = undef;
582 527 last switch;
583 } }
584 State56: {
585 # 306 "parser.y"
586 13 { $yyval = 1;
587 13 last switch;
588 } }
589 State57: {
590 # 307 "parser.y"
591 5 { $yyval = 0;
592 5 last switch;
593 } }
594 State58: {
595 # 310 "parser.y"
596 0 {
597 0 last switch;
598 } }
599 State59: {
600 # 311 "parser.y"
601 0 {
602 0 last switch;
603 } }
604 State60: {
605 # 314 "parser.y"
606 0 {
607 0 last switch;
608 } }
609 State61: {
610 # 317 "parser.y"
611 52 {
612 52 last switch;
613 } }
614 State62: {
615 # 318 "parser.y"
616 86 {
617 86 last switch;
618 } }
619 } # switch
620 4407 $yyssp -= $yym;
621 4407 $yystate = $yyss[$yyssp];
622 4407 $yyvsp -= $yym;
623 4407 $yym = $yylhs[$yyn];
624 4407 ▶ if ($yystate == 0 && $yym == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yystate == 0 and $Convert::ASN1::parser::yym == 0) 116 4291 4407
Condition100%3/3
$Convert::ASN1::parser::yystate == 0 and $Convert::ASN1::parser::yym == 0
!ll&&!rl&&r
3827464116
MC/DC100%2/2
$Convert::ASN1::parser::yystate == 0 and $Convert::ASN1::parser::yym == 0
$Convert::ASN1::parser::yystate == 0 $Convert::ASN1::parser::yym == 0
Truth table100%3/3
A and B
A= $Convert::ASN1::parser::yystate == 0B= $Convert::ASN1::parser::yym == 0
ABresult
0X0
100
111
625 {
626  
627  
628  
629  
630 116 $yystate = constYYFINAL();
631 116 $yyss[++$yyssp] = constYYFINAL();
632 116 $yyvs[++$yyvsp] = $yyval;
633 116 ▶ if ($yychar < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yychar < 0) 0 116 116
634 {
635 0 ▶ if (($yychar = &yylex) < 0) { $yychar = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (($Convert::ASN1::parser::yychar = &yylex) < 0) 0 0 0
636 }
637 116 ▶ return $yyvs[$yyvsp] if $yychar == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yychar == 0 116 0 116
638 0 next yyloop;
639 }
640 4291 ▶ if (($yyn = $yygindex[$yym]) && ($yyn += $yystate) >= 0 &&
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yystate) { } 1849 2442 4291
Condition100%9/9
$Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yystate
!ll&&!rl&&r
14889541849
$Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck
!ll&&!rl&&r
1470182803
$Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0
!ll&&!rl&&r
1449212821
MC/DC100%4/4
$Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0 and $Convert::ASN1::parser::yyn <= $#yycheck and $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yystate
$Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym] ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0 $Convert::ASN1::parser::yyn <= $#yycheck $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yystate
Truth table100%5/5
A and B and C and D
A= $Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym]B= ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0C= $Convert::ASN1::parser::yyn <= $#yycheckD= $yycheck[$Convert::ASN1::parser::yyn] == $Convert::ASN1::parser::yystate
ABCDresult
0XXX0
10XX0
110X0
11100
11111
641 $yyn <= $#yycheck && $yycheck[$yyn] == $yystate)
642 {
643 1849 $yystate = $yytable[$yyn];
644 } else {
645 2442 $yystate = $yydgoto[$yym];
646 }
647  
648  
649  
650  
651 4291 $yyss[++$yyssp] = $yystate;
652 4291 $yyvs[++$yyvsp] = $yyval;
653 } # yyloop
654 } # yyparse
655 # 322 "parser.y"
656  
657 32 my %reserved = (
658 'OPTIONAL' => constOPTIONAL(),
659 'CHOICE' => constCHOICE(),
660 'OF' => constOF(),
661 'IMPLICIT' => constIMPLICIT(),
662 'EXPLICIT' => constEXPLICIT(),
663 'SEQUENCE' => constSEQUENCE(),
664 'SET' => constSET(),
665 'ANY' => constANY(),
666 'ENUM' => constENUM(),
667 'ENUMERATED' => constENUM(),
668 'COMPONENTS' => constCOMPONENTS(),
669 '{' => constLBRACE(),
670 '}' => constRBRACE(),
671 ',' => constCOMMA(),
672 '::=' => constASSIGN(),
673 'DEFINED' => constDEFINED(),
674 'BY' => constBY()
675 );
676  
677 32 my $reserved = join("|", reverse sort grep { /\w/ } keys %reserved);
678  
679 32 my %tag_class = (
680 APPLICATION => ASN_APPLICATION,
681 UNIVERSAL => ASN_UNIVERSAL,
682 PRIVATE => ASN_PRIVATE,
683 CONTEXT => ASN_CONTEXT,
684 '' => ASN_CONTEXT # if not specified, its CONTEXT
685 );
686  
687 ;##
688 ;## This is NOT thread safe !!!!!!
689 ;##
690  
691 32 my $pos;
692 my $last_pos;
693 32 my @stacked;
694  
695 116 ▶sub parse {
Subroutine parse: called CC=2 SCAR=6.9
Pod undocumented
696 116 local(*asn) = \($_[0]);
697 116 ▶ $tagdefault = $_[1] eq 'EXPLICIT' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq 'EXPLICIT' ? : 2 114 116
698 116 ($pos,$last_pos,@stacked) = ();
699  
700 116 eval {
701 116 local $SIG{__DIE__};
702 116 compile(verify(yyparse()));
703 }
704 }
705  
706 690 ▶sub compile_one {
Subroutine compile_one: called CC=24 SCAR=32.0
Pod undocumented
707 690 my $tree = shift;
708 690 my $ops = shift;
709 690 my $name = shift;
710 690 foreach my $op (@$ops) {
711 1033 ▶ next unless ref($op) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $op eq "ARRAY" 458 575 1033
712 575 bless $op;
713 575 my $type = $op->[cTYPE];
714 575 ▶ if (exists $base_type{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $base_type{$type}) { } 414 161 575
715 414 $op->[cTYPE] = $base_type{$type}->[1];
716 414 ▶ $op->[cTAG] = defined($op->[cTAG]) ? asn_encode_tag($op->[cTAG]): $base_type{$type}->[0];
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[0] ? : 65 349 414
717 }
718 else {
719 161 ▶ die "Unknown type '$type'\n" unless exists $tree->{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $tree->{$type} 0 161 161
720 my $ref = compile_one(
721 $tree,
722 161 ▶ $tree->{$type},
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[2] ? : 133 28 161
723 defined($op->[cVAR]) ? $name . "." . $op->[cVAR] : $name
724 );
725 161 ▶ if (defined($op->[cTAG]) && $ref->[0][cTYPE] == opCHOICE) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $op->[0] and $ref->[0][1] == 15) { } 4 157 161
Condition100%3/3
defined $op->[0] and $ref->[0][1] == 15
!ll&&!rl&&r
137204
MC/DC100%2/2
defined $op->[0] and $ref->[0][1] == 15
defined $op->[0] $ref->[0][1] == 15
Truth table100%3/3
A and B
A= defined $op->[0]B= $ref->[0][1] == 15
ABresult
0X0
100
111
726 4 @{$op}[cTYPE,cCHILD] = (opSEQUENCE,$ref);
727 }
728 else {
729 157 @{$op}[cTYPE,cCHILD,cLOOP] = @{$ref->[0]}[cTYPE,cCHILD,cLOOP];
730 }
731 161 ▶ $op->[cTAG] = defined($op->[cTAG]) ? asn_encode_tag($op->[cTAG]): $ref->[0][cTAG];
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[0] ? : 24 137 161
732 }
733 575 ▶ $op->[cTAG] |= pack("C",ASN_CONSTRUCTOR)
Branch: 1 branch
BranchTrueFalseTotal
if length $op->[0] and $op->[1] == 10 || $op->[1] == 9 || $op->[1] == 8 166 409 575
Condition100%9/9
length $op->[0] and $op->[1] == 10 || $op->[1] == 9 || $op->[1] == 8
!ll&&!rl&&r
156253166
$op->[1] == 10 or $op->[1] == 9 or $op->[1] == 8
l!l&&r!l&&!r
34132253
$op->[1] == 10 or $op->[1] == 9
l!l&&r!l&&!r
1222385
MC/DC100%4/4
length $op->[0] and $op->[1] == 10 || $op->[1] == 9 || $op->[1] == 8
length $op->[0] $op->[1] == 10 $op->[1] == 9 $op->[1] == 8
Truth table100%5/5
A and B or C or D
A= length $op->[0]B= $op->[1] == 10C= $op->[1] == 9D= $op->[1] == 8
ABCDresult
0XXX0
10000
11XX1
101X1
10011
734 if length $op->[cTAG] && ($op->[cTYPE] == opSET || $op->[cTYPE] == opEXPLICIT || $op->[cTYPE] == opSEQUENCE);
735  
736 575 ▶ if ($op->[cCHILD]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->[6]) 290 285 575
737 ;# If we have children we are one of
738 ;# opSET opSEQUENCE opCHOICE opEXPLICIT
739  
740 290 ▶ compile_one($tree, $op->[cCHILD], defined($op->[cVAR]) ? $name . "." . $op->[cVAR] : $name);
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[2] ? : 122 168 290
741  
742 ;# If a CHOICE is given a tag, then it must be EXPLICIT
743 290 ▶ if ($op->[cTYPE] == opCHOICE && defined($op->[cTAG]) && length($op->[cTAG])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->[1] == 15 and defined $op->[0] and length $op->[0]) 0 290 290
Condition66%4/6
$op->[1] == 15 and defined $op->[0] and length $op->[0]
!ll&&!rl&&r
1661240
$op->[1] == 15 and defined $op->[0]
!ll&&!rl&&r
1660124
MC/DC0%0/3
$op->[1] == 15 and defined $op->[0] and length $op->[0]
$op->[1] == 15 defined $op->[0] length $op->[0]
Truth table50%2/4
A and B and C
A= $op->[1] == 15B= defined $op->[0]C= length $op->[0]
ABCresult
0XX0
10X0
1100
1111
744 0 $op = bless explicit($op);
745 0 $op->[cTYPE] = opSEQUENCE;
746 }
747  
748 290 ▶ if ( @{$op->[cCHILD]} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$op->[6];} > 1) { } 206 84 290
749 ;#if ($op->[cTYPE] != opSEQUENCE) {
750 ;# Here we need to flatten CHOICEs and check that SET and CHOICE
751 ;# do not contain duplicate tags
752 ;#}
753 206 ▶ if ($op->[cTYPE] == opSET) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->[1] == 10) 8 198 206
754 ;# In case we do CER encoding we order the SET elements by their tags
755 my @tags = map {
756 length($_->[cTAG])
757 ? $_->[cTAG]
758 : $_->[cTYPE] == opCHOICE
759 0 ▶ ? (sort map { $_->[cTAG] } $_->[cCHILD])[0]
Branch: 2 branches
BranchTrueFalseTotal
length $_->[0] ? : 26 4 30
$_->[1] == 15 ? : 0 4 4
760 : ''
761 8 } @{$op->[cCHILD]};
762 8 @{$op->[cCHILD]} = @{$op->[cCHILD]}[sort { $tags[$a] cmp $tags[$b] } 0..$#tags];
763 }
764 }
765 else {
766 ;# A SET of one element can be treated the same as a SEQUENCE
767 84 ▶ $op->[cTYPE] = opSEQUENCE if $op->[cTYPE] == opSET;
Branch: 1 branch
BranchTrueFalseTotal
if $op->[1] == 10 4 80 84
768 }
769 }
770 }
771 690 $ops;
772 }
773  
774 116 ▶sub compile {
Subroutine compile: called CC=2 SCAR=6.9
Pod undocumented
775 116 my $tree = shift;
776  
777 ;# The tree should be valid enough to be able to
778 ;# - resolve references
779 ;# - encode tags
780 ;# - verify CHOICEs do not contain duplicate tags
781  
782 ;# once references have been resolved, and also due to
783 ;# flattening of COMPONENTS, it is possible for an op
784 ;# to appear in multiple places. So once an op is
785 ;# compiled we bless it. This ensure we don't try to
786 ;# compile it again.
787  
788 116 ▶ while(my($k,$v) = each %$tree) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tree) 239 116 355
789 239 compile_one($tree,$v,$k);
790 }
791  
792 116 $tree;
793 }
794  
795 116 ▶sub verify {
Subroutine verify: called CC=13 SCAR=26.3
Pod undocumented
796 116 ▶ my $tree = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tree = shift() or return 116 0 116
797 116 my $err = "";
798  
799 ;# Well it parsed correctly, now we
800 ;# - check references exist
801 ;# - flatten COMPONENTS OF (checking for loops)
802 ;# - check for duplicate var names
803  
804 116 ▶ while(my($name,$ops) = each %$tree) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tree) 239 116 355
805 239 my $stash = {};
806 239 my @scope = ();
807 239 my $path = "";
808 239 my $idx = 0;
809  
810 239 ▶ while($ops) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ops) 974 0 974
811 974 ▶ if ($idx < @$ops) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < @$ops) { } 575 399 974
812 575 my $op = $ops->[$idx++];
813 575 my $var;
814 575 ▶ if (defined ($var = $op->[cVAR])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($var = $op->[2])) 359 216 575
815
816 $err .= "$name: $path.$var used multiple times\n"
817 359 ▶ if $stash->{$var}++;
Branch: 1 branch
BranchTrueFalseTotal
if $stash->{$var}++ 0 359 359
818  
819 }
820 575 ▶ if (defined $op->[cCHILD]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $op->[6]) 160 415 575
821 160 ▶ if (ref $op->[cCHILD]) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $op->[6]) { } 160 0 160
elsif ($op->[1] eq 'COMPONENTS') { } 0 0 0
822 160 push @scope, [$stash, $path, $ops, $idx];
823 160 ▶ if (defined $var) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $var) 15 145 160
824 15 $stash = {};
825 15 $path .= "." . $var;
826 }
827 160 $idx = 0;
828 160 $ops = $op->[cCHILD];
829 }
830 elsif ($op->[cTYPE] eq 'COMPONENTS') {
831 0 splice(@$ops,--$idx,1,expand_ops($tree, $op->[cCHILD]));
832 }
833 else {
834 0 die "Internal error\n";
835 }
836 }
837 }
838 else {
839 399 ▶ my $s = pop @scope
Branch: 1 branch
BranchTrueFalseTotal
my $s = pop @scope or last 160 239 399
840 or last;
841 160 ($stash,$path,$ops,$idx) = @$s;
842 }
843 }
844 }
845 116 ▶ die $err if length $err;
Branch: 1 branch
BranchTrueFalseTotal
if length $err 0 116 116
846 116 $tree;
847 }
848  
849 0 ▶sub expand_ops {
Subroutine expand_ops: not called CC=10 SCAR=47.0
Pod undocumented
850 0 my $tree = shift;
851 0 my $want = shift;
852 0 ▶ my $seen = shift || { };
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
853
854 0 ▶ die "COMPONENTS OF loop $want\n" if $seen->{$want}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen->{$want}++ 0 0 0
855 0 ▶ die "Undefined macro $want\n" unless exists $tree->{$want};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $tree->{$want} 0 0 0
856 0 my $ops = $tree->{$want};
857 0 ▶ die "Bad macro for COMPUNENTS OF '$want'\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @$ops == 1 and $ops->[0][1] eq "SEQUENCE" || $ops->[0][1] eq "SET" and ref $ops->[0][6] 0 0 0
Condition0%0/9
@$ops == 1 and $ops->[0][1] eq "SEQUENCE" || $ops->[0][1] eq "SET" and ref $ops->[0][6]
!ll&&!rl&&r
000
@$ops == 1 and $ops->[0][1] eq "SEQUENCE" || $ops->[0][1] eq "SET"
!ll&&!rl&&r
000
$ops->[0][1] eq "SEQUENCE" or $ops->[0][1] eq "SET"
l!l&&r!l&&!r
000
MC/DC0%0/4
@$ops == 1 and $ops->[0][1] eq "SEQUENCE" || $ops->[0][1] eq "SET" and ref $ops->[0][6]
@$ops == 1 $ops->[0][1] eq "SEQUENCE" $ops->[0][1] eq "SET" ref $ops->[0][6]
Truth table0%0/6
A and B or C and D
A= @$ops == 1B= $ops->[0][1] eq "SEQUENCE"C= $ops->[0][1] eq "SET"D= ref $ops->[0][6]
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
858 unless @$ops == 1
859 && ($ops->[0][cTYPE] eq 'SEQUENCE' || $ops->[0][cTYPE] eq 'SET')
860 && ref $ops->[0][cCHILD];
861 0 $ops = $ops->[0][cCHILD];
862 0 ▶ for(my $idx = 0 ; $idx < @$ops ; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < @$ops) 0 0 0
863 0 my $op = $ops->[$idx++];
864 0 ▶ if ($op->[cTYPE] eq 'COMPONENTS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->[1] eq "COMPONENTS") 0 0 0
865 0 splice(@$ops,--$idx,1,expand_ops($tree, $op->[cCHILD], $seen));
866 }
867 }
868  
869 0 @$ops;
870 }
871  
872 0 ▶sub _yylex {
Subroutine _yylex: not called CC=1 SCAR=6.9
873 0 my $ret = &_yylex;
874 0 warn $ret;
875 0 $ret;
876 }
877  
878 2117 ▶sub yylex {
Subroutine yylex: called CC=14 SCAR=26.6
Pod undocumented
879 2117 ▶ return shift @stacked if @stacked;
Branch: 1 branch
BranchTrueFalseTotal
if @stacked 114 2003 2117
880  
881 2003 ▶ while ($asn =~ /\G(?:
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::asn =~ /\G(?: (\s+|--[^\n]*) | ([,{}]|::=) | ($reserved)\b | ( (?:OCTET|BIT)\s+STRING | OBJECT\s+IDENTIFIER | RELATIVE-OID )\b | (\w+(?:-\w+)*) | \[\s* ( (?:(?:APPLICATION|PRIVATE|UNIVERSAL|CONTEXT)\s+)? \d+ ) \s*\] | \((\d+)\) | (\.\.\.) )/gosx) 3809 154 3963
882 (\s+|--[^\n]*)
883 |
884 ([,{}]|::=)
885 |
886 ($reserved)\b
887 |
888 (
889 (?:OCTET|BIT)\s+STRING
890 |
891 OBJECT\s+IDENTIFIER
892 |
893 RELATIVE-OID
894 )\b
895 |
896 (\w+(?:-\w+)*)
897 |
898 \[\s*
899 (
900 (?:(?:APPLICATION|PRIVATE|UNIVERSAL|CONTEXT)\s+)?
901 \d+
902 )
903 \s*\]
904 |
905 \((\d+)\)
906 |
907 (\.\.\.)
908 )/sxgo
909 ) {
910  
911 3809 ($last_pos,$pos) = ($pos,pos($asn));
912  
913 3809 ▶ next if defined $1; # comment or whitespace
Branch: 1 branch
BranchTrueFalseTotal
if defined $1 1960 1849 3809
914  
915 1849 ▶ if (defined $2 or defined $3) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $2 or defined $3) 796 1053 1849
Condition100%3/3
defined $2 or defined $3
l!l&&r!l&&!r
5462501053
MC/DC100%2/2
defined $2 or defined $3
defined $2 defined $3
Truth table100%3/3
A or B
A= defined $2B= defined $3
ABresult
1X1
011
000
916 796 my $ret = $+;
917  
918 # A comma is not required after a '}' so to aid the
919 # parser we insert a fake token after any '}'
920 796 ▶ if ($ret eq '}') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret eq "}") 118 678 796
921 118 my $p = pos($asn);
922 118 my @tmp = @stacked;
923 118 @stacked = ();
924 118 ▶ pos($asn) = $p if yylex() != constCOMMA(); # swallow it
Branch: 1 branch
BranchTrueFalseTotal
if yylex() != 12 118 0 118
925 118 @stacked = (@tmp, constPOSTRBRACE());
926 }
927  
928 796 return $reserved{$yylval = $ret};
929 }
930  
931 1053 ▶ if (defined $4) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $4) 42 1011 1053
932 42 ($yylval = $+) =~ s/\s+/_/g;
933 42 return constWORD();
934 }
935  
936 1011 ▶ if (defined $5) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $5) 911 100 1011
937 911 $yylval = $+;
938 911 return constWORD();
939 }
940  
941 100 ▶ if (defined $6) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $6) 89 11 100
942 89 my($class,$num) = ($+ =~ /^([A-Z]*)\s*(\d+)$/);
943 89 $yylval = asn_tag($tag_class{$class}, $num);
944 89 return constCLASS();
945 }
946  
947 11 ▶ if (defined $7) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $7) 0 11 11
948 0 $yylval = $+;
949 0 return constNUMBER();
950 }
951  
952 11 ▶ if (defined $8) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $8) 11 0 11
953 11 return constEXTENSION_MARKER();
954 }
955  
956 0 die "Internal error\n";
957  
958 }
959  
960 154 ▶ die "Parse error before ",substr($asn,$pos,40),"\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $pos == length $Convert::ASN1::parser::asn 0 154 154
961 unless $pos == length($asn);
962  
963 154 0
964 }
965  
966 0 ▶sub yyerror {
Subroutine yyerror: not called CC=1 SCAR=6.9
Pod undocumented
967 0 die @_," ",substr($asn,$last_pos,40),"\n";
968 }
969  
970 32 1;
971  
972 32 %yystate = ('State51','','State34','','State11','','State33','','State24',
973 '','State47','','State40','','State31','','State37','','State23','',
974 'State22','','State21','','State57','','State39','','State56','','State20',
975 '','State25','','State38','','State62','','State14','','State19','',
976 'State5','','State53','','State26','','State27','','State50','','State36',
977 '','State4','','State3','','State32','','State49','','State43','','State30',
978 '','State35','','State52','','State55','','State42','','State28','',
979 'State58','','State61','','State41','','State18','','State59','','State1',
980 '','State60','');
981  
982 32 1;
« ASN1/Debug.pm ↑ Summary ASN1/IO.pm »