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/IO.pm ↑ Summary ASN1/_encode.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 24 $Convert::ASN1::parser::VERSION = '0.36';
9 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 24 ▶use Convert::ASN1 qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 24 ▶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 24 );
15  
16 24 ▶BEGIN { Convert::ASN1->_internal_syms }
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 24 my $yydebug=0;
19 24 my %yystate;
20  
21 24 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 24 my $tagdefault = 1; # 0:IMPLICIT , 1:EXPLICIT default
64  
65 ;# args: class,plicit
66 434 ▶sub need_explicit {
Subroutine need_explicit: called CC=3 SCAR=11.0
Pod undocumented
67 434 ▶ (defined($_[0]) && (defined($_[1])?$_[1]:$tagdefault));
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] and defined $_[1] ? $_[1] : $tagdefault 89 345 434
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 24 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 24 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 24 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 24 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 24 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 24 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 24 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 24 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 24 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 100 ▶{
Subroutine yyparse: called CC=43 SCAR=42.3
Pod undocumented
261  
262 100 ▶ if ($yys = $ENV{'YYDEBUG'})
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yys = $ENV{"YYDEBUG"}) 0 100 100
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 100 $yynerrs = 0;
269 100 $yyerrflag = 0;
270 100 $yychar = (-1);
271  
272 100 $yyssp = 0;
273 100 $yyvsp = 0;
274 100 $yyss[$yyssp] = $yystate = 0;
275  
276 100 yyloop: while(1)
277 {
278 yyreduce: {
279 5048 ▶ last yyreduce if ($yyn = $yydefred[$yystate]);
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yyn = $yydefred[$Convert::ASN1::parser::yystate] 2295 2753 5048
280 2753 ▶ if ($yychar < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yychar < 0) 1595 1158 2753
281 {
282 0 ▶ if (($yychar = &yylex) < 0) { $yychar = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (($Convert::ASN1::parser::yychar = &yylex) < 0) 0 1595 1595
283 }
284 2753 ▶ 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) 1495 1258 2753
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
012581495
$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
002753
$Convert::ASN1::parser::yyn = $yysindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0
!ll&&!rl&&r
002753
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 1495 $yyss[++$yyssp] = $yystate = $yytable[$yyn];
292 1495 $yyvs[++$yyvsp] = $yylval;
293 1495 $yychar = (-1);
294 1495 ▶ --$yyerrflag if $yyerrflag > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yyerrflag > 0 0 1495 1495
295 1495 next yyloop;
296 }
297 1258 ▶ 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) 1258 0 1258
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
001258
$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
001258
$Convert::ASN1::parser::yyn = $yyrindex[$Convert::ASN1::parser::yystate] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yychar) >= 0
!ll&&!rl&&r
001258
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 1258 $yyn = $yytable[$yyn];
301 1258 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 3553 $yym = $yylen[$yyn];
314 3553 $yyval = $yyvs[$yyvsp+1-$yym];
315 switch:
316 {
317 3553 my $label = "State$yyn";
318 3553 ▶goto $label if exists $yystate{$label};
Branch: 1 branch
BranchTrueFalseTotal
if exists $yystate{$label} 2908 645 3553
319 645 last switch;
320 State1: {
321 # 107 "parser.y"
322 86 { $yyval = { '' => $yyvs[$yyvsp-0] };
323 86 last switch;
324 } }
325 State3: {
326 # 112 "parser.y"
327 14 {
328 14 $yyval = { $yyvs[$yyvsp-2], [$yyvs[$yyvsp-0]] };
329
330 14 last switch;
331 } }
332 State4: {
333 # 116 "parser.y"
334 93 {
335 93 $yyval=$yyvs[$yyvsp-3];
336 93 $yyval->{$yyvs[$yyvsp-2]} = [$yyvs[$yyvsp-0]];
337
338 93 last switch;
339 } }
340 State5: {
341 # 123 "parser.y"
342 107 {
343 107 $yyvs[$yyvsp-1]->[cTAG] = $yyvs[$yyvsp-3];
344 107 ▶ $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 102 107
345
346 107 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 55 {
367 55 @{$yyval = []}[cTYPE,cCHILD] = ('SEQUENCE', $yyvs[$yyvsp-1]);
368
369 55 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 16 {
381 16 @{$yyval = []}[cTYPE,cCHILD] = ('CHOICE', $yyvs[$yyvsp-1]);
382
383 16 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 303 { @{$yyval = []}[cTYPE] = $yyvs[$yyvsp-0];
395 303 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 16 { $yyval = $yyvs[$yyvsp-0];
432 16 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 16 {
442 16 $yyval = [ $yyvs[$yyvsp-0] ];
443
444 16 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 30 {
456 30 push @{$yyval=$yyvs[$yyvsp-2]}, $yyvs[$yyvsp-0];
457
458 30 last switch;
459 } }
460 State35: {
461 # 215 "parser.y"
462 43 {
463 43 @{$yyval=$yyvs[$yyvsp-0]}[cVAR,cTAG] = ($yyvs[$yyvsp-3],$yyvs[$yyvsp-2]);
464 43 ▶ $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 43 43
465
466 43 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 126 {
483 126 my $extension = 0;
484 126 $yyval = [];
485 126 for my $i (@{$yyvs[$yyvsp-0]}) {
486 242 ▶ $extension = 1 if $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
if $i->[1] eq "EXTENSION_MARKER" 8 234 242
487 242 $i->[cEXT] = $i->[cOPT];
488 242 ▶ $i->[cEXT] = 1 if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 12 230 242
489 242 ▶ push @{$yyval}, $i unless $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
unless $i->[1] eq "EXTENSION_MARKER" 234 8 242
490 }
491 126 my $e = []; $e->[cTYPE] = 'EXTENSION_MARKER';
492 126 ▶ push @{$yyval}, $e if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 8 118 126
493
494 126 last switch;
495 } }
496 State39: {
497 # 241 "parser.y"
498 23 {
499 23 my $extension = 0;
500 23 $yyval = [];
501 23 for my $i (@{$yyvs[$yyvsp-1]}) {
502 23 ▶ $extension = 1 if $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
if $i->[1] eq "EXTENSION_MARKER" 0 23 23
503 23 $i->[cEXT] = $i->[cOPT];
504 23 ▶ $i->[cEXT] = 1 if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 0 23 23
505 23 ▶ push @{$yyval}, $i unless $i->[cTYPE] eq 'EXTENSION_MARKER';
Branch: 1 branch
BranchTrueFalseTotal
unless $i->[1] eq "EXTENSION_MARKER" 23 0 23
506 }
507 23 my $e = []; $e->[cTYPE] = 'EXTENSION_MARKER';
508 0 ▶ push @{$yyval}, $e if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 0 23 23
509
510 23 last switch;
511 } }
512 State40: {
513 # 256 "parser.y"
514 149 {
515 149 $yyval = [ $yyvs[$yyvsp-0] ];
516
517 149 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 226 {
536 226 @{$yyval=$yyvs[$yyvsp-1]}[cOPT] = ($yyvs[$yyvsp-0]);
537
538 226 last switch;
539 } }
540 State47: {
541 # 279 "parser.y"
542 236 {
543 236 @{$yyval=$yyvs[$yyvsp-0]}[cVAR,cTAG] = ($yyvs[$yyvsp-3],$yyvs[$yyvsp-2]);
544 236 ▶ $yyval->[cOPT] = $yyvs[$yyvsp-3] if $yyval->[cOPT];
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yyval->[4] 37 199 236
545 236 ▶ $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 222 236
546
547 236 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 216 { $yyval = undef;
567 216 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 345 { $yyval = undef;
577 345 last switch;
578 } }
579 State55: {
580 # 305 "parser.y"
581 416 { $yyval = undef;
582 416 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 51 {
612 51 last switch;
613 } }
614 State62: {
615 # 318 "parser.y"
616 56 {
617 56 last switch;
618 } }
619 } # switch
620 3553 $yyssp -= $yym;
621 3553 $yystate = $yyss[$yyssp];
622 3553 $yyvsp -= $yym;
623 3553 $yym = $yylhs[$yyn];
624 3553 ▶ if ($yystate == 0 && $yym == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yystate == 0 and $Convert::ASN1::parser::yym == 0) 100 3453 3553
Condition100%3/3
$Convert::ASN1::parser::yystate == 0 and $Convert::ASN1::parser::yym == 0
!ll&&!rl&&r
3065388100
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 100 $yystate = constYYFINAL();
631 100 $yyss[++$yyssp] = constYYFINAL();
632 100 $yyvs[++$yyvsp] = $yyval;
633 100 ▶ if ($yychar < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Convert::ASN1::parser::yychar < 0) 0 100 100
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 100 ▶ return $yyvs[$yyvsp] if $yychar == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Convert::ASN1::parser::yychar == 0 100 0 100
638 0 next yyloop;
639 }
640 3453 ▶ 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) { } 1482 1971 3453
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
12207511482
$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
1202182233
$Convert::ASN1::parser::yyn = $yygindex[$Convert::ASN1::parser::yym] and ($Convert::ASN1::parser::yyn += $Convert::ASN1::parser::yystate) >= 0
!ll&&!rl&&r
1181212251
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 1482 $yystate = $yytable[$yyn];
644 } else {
645 1971 $yystate = $yydgoto[$yym];
646 }
647  
648  
649  
650  
651 3453 $yyss[++$yyssp] = $yystate;
652 3453 $yyvs[++$yyvsp] = $yyval;
653 } # yyloop
654 } # yyparse
655 # 322 "parser.y"
656  
657 24 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 24 my $reserved = join("|", reverse sort grep { /\w/ } keys %reserved);
678  
679 24 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 24 my $pos;
692 my $last_pos;
693 24 my @stacked;
694  
695 100 ▶sub parse {
Subroutine parse: called CC=2 SCAR=6.9
Pod undocumented
696 100 local(*asn) = \($_[0]);
697 100 ▶ $tagdefault = $_[1] eq 'EXPLICIT' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq 'EXPLICIT' ? : 2 98 100
698 100 ($pos,$last_pos,@stacked) = ();
699  
700 100 eval {
701 100 local $SIG{__DIE__};
702 100 compile(verify(yyparse()));
703 }
704 }
705  
706 491 ▶sub compile_one {
Subroutine compile_one: called CC=24 SCAR=32.0
Pod undocumented
707 491 my $tree = shift;
708 491 my $ops = shift;
709 491 my $name = shift;
710 491 foreach my $op (@$ops) {
711 746 ▶ next unless ref($op) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $op eq "ARRAY" 282 464 746
712 464 bless $op;
713 464 my $type = $op->[cTYPE];
714 464 ▶ if (exists $base_type{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $base_type{$type}) { } 363 101 464
715 363 $op->[cTYPE] = $base_type{$type}->[1];
716 363 ▶ $op->[cTAG] = defined($op->[cTAG]) ? asn_encode_tag($op->[cTAG]): $base_type{$type}->[0];
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[0] ? : 65 298 363
717 }
718 else {
719 101 ▶ die "Unknown type '$type'\n" unless exists $tree->{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $tree->{$type} 0 101 101
720 my $ref = compile_one(
721 $tree,
722 101 ▶ $tree->{$type},
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[2] ? : 73 28 101
723 defined($op->[cVAR]) ? $name . "." . $op->[cVAR] : $name
724 );
725 101 ▶ if (defined($op->[cTAG]) && $ref->[0][cTYPE] == opCHOICE) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $op->[0] and $ref->[0][1] == 15) { } 4 97 101
Condition100%3/3
defined $op->[0] and $ref->[0][1] == 15
!ll&&!rl&&r
77204
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 97 @{$op}[cTYPE,cCHILD,cLOOP] = @{$ref->[0]}[cTYPE,cCHILD,cLOOP];
730 }
731 101 ▶ $op->[cTAG] = defined($op->[cTAG]) ? asn_encode_tag($op->[cTAG]): $ref->[0][cTAG];
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[0] ? : 24 77 101
732 }
733 464 ▶ $op->[cTAG] |= pack("C",ASN_CONSTRUCTOR)
Branch: 1 branch
BranchTrueFalseTotal
if length $op->[0] and $op->[1] == 10 || $op->[1] == 9 || $op->[1] == 8 161 303 464
Condition100%9/9
length $op->[0] and $op->[1] == 10 || $op->[1] == 9 || $op->[1] == 8
!ll&&!rl&&r
68235161
$op->[1] == 10 or $op->[1] == 9 or $op->[1] == 8
l!l&&r!l&&!r
34127235
$op->[1] == 10 or $op->[1] == 9
l!l&&r!l&&!r
1222362
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 464 ▶ if ($op->[cCHILD]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->[6]) 197 267 464
737 ;# If we have children we are one of
738 ;# opSET opSEQUENCE opCHOICE opEXPLICIT
739  
740 197 ▶ compile_one($tree, $op->[cCHILD], defined($op->[cVAR]) ? $name . "." . $op->[cVAR] : $name);
Branch: 1 branch
BranchTrueFalseTotal
defined $op->[2] ? : 59 138 197
741  
742 ;# If a CHOICE is given a tag, then it must be EXPLICIT
743 197 ▶ 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 197 197
Condition66%4/6
$op->[1] == 15 and defined $op->[0] and length $op->[0]
!ll&&!rl&&r
161360
$op->[1] == 15 and defined $op->[0]
!ll&&!rl&&r
161036
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 197 ▶ if ( @{$op->[cCHILD]} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$op->[6];} > 1) { } 118 79 197
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 118 ▶ if ($op->[cTYPE] == opSET) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->[1] == 10) 8 110 118
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 79 ▶ $op->[cTYPE] = opSEQUENCE if $op->[cTYPE] == opSET;
Branch: 1 branch
BranchTrueFalseTotal
if $op->[1] == 10 4 75 79
768 }
769 }
770 }
771 491 $ops;
772 }
773  
774 100 ▶sub compile {
Subroutine compile: called CC=2 SCAR=6.9
Pod undocumented
775 100 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 100 ▶ while(my($k,$v) = each %$tree) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tree) 193 100 293
789 193 compile_one($tree,$v,$k);
790 }
791  
792 100 $tree;
793 }
794  
795 100 ▶sub verify {
Subroutine verify: called CC=13 SCAR=26.3
Pod undocumented
796 100 ▶ my $tree = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $tree = shift() or return 100 0 100
797 100 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 100 ▶ while(my($name,$ops) = each %$tree) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tree) 193 100 293
805 193 my $stash = {};
806 193 my @scope = ();
807 193 my $path = "";
808 193 my $idx = 0;
809  
810 193 ▶ while($ops) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ops) 782 0 782
811 782 ▶ if ($idx < @$ops) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < @$ops) { } 464 318 782
812 464 my $op = $ops->[$idx++];
813 464 my $var;
814 464 ▶ if (defined ($var = $op->[cVAR])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($var = $op->[2])) 279 185 464
815
816 $err .= "$name: $path.$var used multiple times\n"
817 279 ▶ if $stash->{$var}++;
Branch: 1 branch
BranchTrueFalseTotal
if $stash->{$var}++ 0 279 279
818  
819 }
820 464 ▶ if (defined $op->[cCHILD]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $op->[6]) 125 339 464
821 125 ▶ if (ref $op->[cCHILD]) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $op->[6]) { } 125 0 125
elsif ($op->[1] eq 'COMPONENTS') { } 0 0 0
822 125 push @scope, [$stash, $path, $ops, $idx];
823 125 ▶ if (defined $var) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $var) 10 115 125
824 10 $stash = {};
825 10 $path .= "." . $var;
826 }
827 125 $idx = 0;
828 125 $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 318 ▶ my $s = pop @scope
Branch: 1 branch
BranchTrueFalseTotal
my $s = pop @scope or last 125 193 318
840 or last;
841 125 ($stash,$path,$ops,$idx) = @$s;
842 }
843 }
844 }
845 100 ▶ die $err if length $err;
Branch: 1 branch
BranchTrueFalseTotal
if length $err 0 100 100
846 100 $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 1674 ▶sub yylex {
Subroutine yylex: called CC=14 SCAR=26.6
Pod undocumented
879 1674 ▶ return shift @stacked if @stacked;
Branch: 1 branch
BranchTrueFalseTotal
if @stacked 79 1595 1674
880  
881 1595 ▶ 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) 3081 132 3213
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 3081 ($last_pos,$pos) = ($pos,pos($asn));
912  
913 3081 ▶ next if defined $1; # comment or whitespace
Branch: 1 branch
BranchTrueFalseTotal
if defined $1 1618 1463 3081
914  
915 1463 ▶ if (defined $2 or defined $3) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $2 or defined $3) 626 837 1463
Condition100%3/3
defined $2 or defined $3
l!l&&r!l&&!r
411215837
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 626 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 626 ▶ if ($ret eq '}') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret eq "}") 79 547 626
921 79 my $p = pos($asn);
922 79 my @tmp = @stacked;
923 79 @stacked = ();
924 79 ▶ pos($asn) = $p if yylex() != constCOMMA(); # swallow it
Branch: 1 branch
BranchTrueFalseTotal
if yylex() != 12 79 0 79
925 79 @stacked = (@tmp, constPOSTRBRACE());
926 }
927  
928 626 return $reserved{$yylval = $ret};
929 }
930  
931 837 ▶ if (defined $4) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $4) 37 800 837
932 37 ($yylval = $+) =~ s/\s+/_/g;
933 37 return constWORD();
934 }
935  
936 800 ▶ if (defined $5) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $5) 700 100 800
937 700 $yylval = $+;
938 700 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 132 ▶ die "Parse error before ",substr($asn,$pos,40),"\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $pos == length $Convert::ASN1::parser::asn 0 132 132
961 unless $pos == length($asn);
962  
963 132 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 24 1;
971  
972 24 %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 24 1;
« ASN1/IO.pm ↑ Summary ASN1/_encode.pm »