UDC/Parser.pm

filter: Statementstmt 94.8% 311 / 328 Branchbran 86.6% 156 / 180 Conditioncond 81.1% 73 / 90 MC/DCmcdc 69.0% 38 / 55 Subroutinesub 100% 32 / 32 Podpod 0.0% 0 / 1 totaltotal 88.9% 610 / 686 CC 126 SCAR 26.6
CC
126
Cov
90%
_check_parentheses
34.3
_parse_expression
18.0
_parse_term
15.9
CRAP 14.2
« UDC/Tokenizer.pm ↑ Summary UDC/Grammar.pm »
1 package Business::UDC::Parser;
2  
3 10 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Business::UDC::Grammar qw(can_follow_operator can_follow_primary can_precede_number
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 is_operator_token is_primary_token is_valid_operator);
9 10 ▶use Business::UDC::Tokenizer qw(tokenize);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use List::Util 1.33 qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 10 Readonly::Array our @EXPORT_OK => qw(parse);
15  
16 10 our $VERSION = 0.12;
17  
18 142 ▶sub parse {
Subroutine parse: called CC=5 SCAR=16.1
Pod undocumented
19 142 my $input = shift;
20  
21 142 ▶ if (! defined $input) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $input) 3 139 142
22 3 err 'No input provided.';
23 }
24 139 ▶ if ($input !~ /\S/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($input =~ /\S/) 2 137 139
25 2 err 'Empty input.';
26 }
27  
28 137 my $tokens_ar = tokenize($input);
29 113 _check_parentheses($tokens_ar, length($input));
30 99 my $has_alpha_spec = _has_alpha_spec($tokens_ar);
31 99 my $normalized_tokens_ar = [];
32 99 foreach my $tok_hr (@{$tokens_ar}) {
33 321 my %parse_tok = %{$tok_hr};
34 321 _check_whitespace_token(\%parse_tok, $has_alpha_spec);
35 307 _check_apos_aux_tokens(\%parse_tok);
36 302 _check_aux_time_tokens(\%parse_tok);
37 299 _check_number_token(\%parse_tok);
38 296 _check_aux_group_token(\%parse_tok, 0, $has_alpha_spec);
39 293 _normalize_alpha_spec_token(\%parse_tok);
40 293 push @{$normalized_tokens_ar}, \%parse_tok;
41 }
42 71 my $state_hr = {
43 'tokens' => $normalized_tokens_ar,
44 'pos' => 0,
45 };
46  
47 71 my $ast = _parse_expression($state_hr);
48  
49 53 ▶ if ($state_hr->{'pos'} < @{$state_hr->{'tokens'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state_hr->{"pos"} < @{$state_hr->{"tokens"};}) 2 51 53
50 2 my $tok = $state_hr->{'tokens'}[$state_hr->{'pos'}];
51 err "Unexpected token '$tok->{'value'}'.",
52 2 'position' => $tok->{'pos'},
53 ;
54 }
55  
56 return {
57 51 'tokens' => $tokens_ar,
58 'ast' => $ast,
59 };
60 }
61  
62 113 ▶sub _check_parentheses {
Subroutine _check_parentheses: called CC=34 SCAR=35.3
63 113 my ($tokens_ar, $input_length) = @_;
64  
65 113 my (@left, $previous, $has_operator_after_left, $operator_position,
66 $has_alpha_after_left, $has_time_after_left, $time_position);
67 113 foreach my $tok (@{$tokens_ar}) {
68 436 ▶ if ($tok->{'type'} eq 'LPAREN') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "LPAREN") 12 424 436
69 12 push @left, $tok;
70 12 $previous = $tok;
71 12 $has_operator_after_left = 0;
72 12 $operator_position = undef;
73 12 $has_alpha_after_left = 0;
74 12 $has_time_after_left = 0;
75 12 $time_position = undef;
76 12 next;
77 }
78 424 ▶ if ($tok->{'type'} eq 'RPAREN') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "RPAREN") 4 420 424
79 4 ▶ if (! @left) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@left) 4 0 4
80 return if $tokens_ar->[0]
81 4 ▶ && $tokens_ar->[0]{'type'} eq 'OP';
Branch: 1 branch
BranchTrueFalseTotal
if $tokens_ar->[0] and $tokens_ar->[0]{"type"} eq "OP" 1 3 4
Condition66%2/3
$tokens_ar->[0] and $tokens_ar->[0]{"type"} eq "OP"
!ll&&!rl&&r
031
MC/DC50%1/2
$tokens_ar->[0] and $tokens_ar->[0]{"type"} eq "OP"
$tokens_ar->[0] $tokens_ar->[0]{"type"} eq "OP"
Truth table66%2/3
A and B
A= $tokens_ar->[0]B= $tokens_ar->[0]{"type"} eq "OP"
ABresult
0X0
100
111
82 3 ▶ my $missing_opening = ! $previous || $previous->{'type'} ne 'AUX_GROUP';
Condition66%2/3
!$previous || $previous->{'type'} ne 'AUX_GROUP'
l!l&&r!l&&!r
021
MC/DC50%1/2
!$previous || $previous->{'type'} ne 'AUX_GROUP'
!$previous $previous->{'type'} ne 'AUX_GROUP'
Truth table66%2/3
not(A) || B
A= !$previousB= $previous->{'type'} ne 'AUX_GROUP'
ABresult
1X1
011
000
83 3 ▶ my $message = $missing_opening
Branch: 1 branch
BranchTrueFalseTotal
$missing_opening ? : 2 1 3
84 ? "Missing opening parenthesis '('."
85 : "Extra closing parenthesis ')'.";
86 err $message,
87 3 ▶ 'position' => $missing_opening ? $tokens_ar->[0]{'pos'} : $tok->{'pos'},
Branch: 2 branches
BranchTrueFalseTotal
$missing_opening ? : 2 1 3
$missing_opening ? : 2 1 3
88 'character' => $missing_opening ? '(' : ')',
89 ;
90 }
91 0 pop @left;
92 }
93 420 ▶ if (@left && $tok->{'type'} eq 'OP') {
Branch: 1 branch
BranchTrueFalseTotal
if (@left and $tok->{"type"} eq "OP") 1 419 420
Condition100%3/3
@left and $tok->{"type"} eq "OP"
!ll&&!rl&&r
392271
MC/DC100%2/2
@left and $tok->{"type"} eq "OP"
@left $tok->{"type"} eq "OP"
Truth table100%3/3
A and B
A= @leftB= $tok->{"type"} eq "OP"
ABresult
0X0
100
111
94 1 $has_operator_after_left = 1;
95 1 ▶ if (! defined $operator_position) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $operator_position) 1 0 1
96 1 $operator_position = $tok->{'pos'};
97 }
98 }
99 420 ▶ if (@left && $tok->{'type'} eq 'ALPHA_SPEC'
Branch: 1 branch
BranchTrueFalseTotal
if (@left and $tok->{"type"} eq "ALPHA_SPEC" and $tok->{"value"} =~ m[([+:/])]) 1 419 420
Condition100%6/6
@left and $tok->{"type"} eq "ALPHA_SPEC" and $tok->{"value"} =~ m[([+:/])]
!ll&&!rl&&r
41811
@left and $tok->{"type"} eq "ALPHA_SPEC"
!ll&&!rl&&r
392262
MC/DC100%3/3
@left and $tok->{"type"} eq "ALPHA_SPEC" and $tok->{"value"} =~ m[([+:/])]
@left $tok->{"type"} eq "ALPHA_SPEC" $tok->{"value"} =~ m[([+:/])]
Truth table100%4/4
A and B and C
A= @leftB= $tok->{"type"} eq "ALPHA_SPEC"C= $tok->{"value"} =~ m[([+:/])]
ABCresult
0XX0
10X0
1100
1111
100 && $tok->{'value'} =~ /([+:\/])/) {
101 1 $has_operator_after_left = 1;
102 1 ▶ $operator_position = $tok->{'pos'} + index($tok->{'value'}, $1)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $operator_position 1 0 1
103 if ! defined $operator_position;
104 }
105 420 ▶ $has_alpha_after_left = 1 if @left && $tok->{'type'} eq 'ALPHA_SPEC';
Branch: 1 branch
BranchTrueFalseTotal
if @left and $tok->{"type"} eq "ALPHA_SPEC" 2 418 420
Condition100%3/3
@left and $tok->{"type"} eq "ALPHA_SPEC"
!ll&&!rl&&r
392262
MC/DC100%2/2
@left and $tok->{"type"} eq "ALPHA_SPEC"
@left $tok->{"type"} eq "ALPHA_SPEC"
Truth table100%3/3
A and B
A= @leftB= $tok->{"type"} eq "ALPHA_SPEC"
ABresult
0X0
100
111
106 $has_time_after_left = 1
107 420 ▶ if @left && $tok->{'type'} eq 'AUX_TIME';
Branch: 1 branch
BranchTrueFalseTotal
if @left and $tok->{"type"} eq "AUX_TIME" 3 417 420
Condition100%3/3
@left and $tok->{"type"} eq "AUX_TIME"
!ll&&!rl&&r
392253
MC/DC100%2/2
@left and $tok->{"type"} eq "AUX_TIME"
@left $tok->{"type"} eq "AUX_TIME"
Truth table100%3/3
A and B
A= @leftB= $tok->{"type"} eq "AUX_TIME"
ABresult
0X0
100
111
108 420 ▶ $time_position = $tok->{'pos'}
Branch: 1 branch
BranchTrueFalseTotal
if $has_time_after_left and not defined $time_position 3 417 420
Condition100%3/3
$has_time_after_left and not defined $time_position
!ll&&!rl&&r
41253
MC/DC100%2/2
$has_time_after_left and not defined $time_position
$has_time_after_left not defined $time_position
Truth table100%3/3
A and not(B)
A= $has_time_after_leftB= not defined $time_position
ABresult
0X0
100
111
109 if $has_time_after_left && ! defined $time_position;
110 420 $previous = $tok;
111 }
112  
113 109 ▶ if (@left) {
Branch: 1 branch
BranchTrueFalseTotal
if (@left) 11 98 109
114 11 my $left = $left[-1];
115 11 ▶ my $missing_closing = $has_operator_after_left || $has_time_after_left;
Condition100%3/3
$has_operator_after_left || $has_time_after_left
l!l&&r!l&&!r
236
MC/DC100%2/2
$has_operator_after_left || $has_time_after_left
$has_operator_after_left $has_time_after_left
Truth table100%3/3
A || B
A= $has_operator_after_leftB= $has_time_after_left
ABresult
1X1
011
000
116 my $extra_opening = @left > 1
117 || ! $missing_closing
118 11 ▶ && $previous && $previous->{'type'} eq 'AUX_GROUP';
Condition88%8/9
@left > 1 || !$missing_closing && $previous && $previous->{'type'} eq 'AUX_GROUP'
l!l&&r!l&&!r
155
not $missing_closing and $previous and $previous->{"type"} eq "AUX_GROUP"
!ll&&!rl&&r
415
not $missing_closing and $previous
!ll&&!rl&&r
406
MC/DC75%3/4
@left > 1 || !$missing_closing && $previous && $previous->{'type'} eq 'AUX_GROUP'
@left > 1 not $missing_closing $previous $previous->{"type"} eq "AUX_GROUP"
Truth table80%4/5
A || not(B) and C and D
A= @left > 1B= not $missing_closingC= $previousD= $previous->{"type"} eq "AUX_GROUP"
ABCDresult
1XXX1
01111
00XX0
010X0
01100
119 11 ▶ my $message = $extra_opening
Branch: 1 branch
BranchTrueFalseTotal
$extra_opening ? : 6 5 11
120 ? "Extra opening parenthesis '('."
121 : "Missing closing parenthesis ')'.";
122 err $message,
123 'position' => $extra_opening
124 11 ▶ ? $left->{'pos'}
Branch: 4 branches
BranchTrueFalseTotal
$extra_opening ? : 6 5 11
defined $time_position ? : 2 3 5
defined $operator_position ? : 2 1 3
$extra_opening ? : 6 5 11
125 : defined $time_position ? $time_position
126 : defined $operator_position ? $operator_position
127 : $input_length,
128 'character' => $extra_opening ? '(' : ')',
129 ;
130 }
131  
132 98 return;
133 }
134  
135 323 ▶sub _check_whitespace_token {
Subroutine _check_whitespace_token: called CC=3 SCAR=11.0
136 323 my ($tok, $has_alpha_spec) = @_;
137  
138 323 ▶ if ($tok->{'type'} ne 'WHITESPACE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} ne "WHITESPACE") 307 16 323
139 307 return;
140 }
141  
142 16 ▶ my $message = $has_alpha_spec
Branch: 1 branch
BranchTrueFalseTotal
$has_alpha_spec ? : 7 9 16
143 ? 'Whitespace is not allowed in UDC string with alphabetical specification.'
144 : 'Whitespace is not allowed in UDC string.';
145 err $message,
146 'position' => $tok->{'pos'},
147 16 'character' => substr($tok->{'value'}, 0, 1),
148 ;
149 }
150  
151 174 ▶sub _has_alpha_spec {
Subroutine _has_alpha_spec: called CC=5 SCAR=16.1
152 174 my $tokens_ar = shift;
153  
154 174 foreach my $token (@{$tokens_ar}) {
155 452 ▶ return 1 if $token->{'type'} eq 'ALPHA_SPEC';
Branch: 1 branch
BranchTrueFalseTotal
if $token->{"type"} eq "ALPHA_SPEC" 26 426 452
156 426 ▶ if ($token->{'tokens'} && _has_alpha_spec($token->{'tokens'})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"tokens"} and _has_alpha_spec($token->{"tokens"})) 4 422 426
Condition66%2/3
$token->{"tokens"} and _has_alpha_spec($token->{"tokens"})
!ll&&!rl&&r
380460
MC/DC0%0/2
$token->{"tokens"} and _has_alpha_spec($token->{"tokens"})
$token->{"tokens"} _has_alpha_spec($token->{"tokens"})
Truth table66%2/3
A and B
A= $token->{"tokens"}B= _has_alpha_spec($token->{"tokens"})
ABresult
0X0
100
111
157 4 return 1;
158 }
159 }
160  
161 144 return 0;
162 }
163  
164 299 ▶sub _check_aux_group_token {
Subroutine _check_aux_group_token: called CC=7 SCAR=19.5
165 299 my ($tok, $position_offset, $has_alpha_spec) = @_;
166  
167 299 ▶ $position_offset //= 0;
Condition50%1/2
$position_offset //= 0
l!l
2990
MC/DC0%0/1
$position_offset //= 0
$position_offset
Truth table50%1/2
A
A= $position_offset
Aresult
11
00
168  
169 299 ▶ if ($tok->{'type'} ne 'AUX_GROUP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} ne "AUX_GROUP") 257 42 299
170 257 return;
171 }
172  
173 42 my $inner_tokens = $tok->{'tokens'};
174 42 my $inner_position_offset = 0;
175 42 ▶ $has_alpha_spec ||= _has_alpha_spec($inner_tokens);
Condition66%2/3
$has_alpha_spec ||= _has_alpha_spec($inner_tokens)
l!l&&r!l&&!r
13029
MC/DC50%1/2
$has_alpha_spec ||= _has_alpha_spec($inner_tokens)
$has_alpha_spec _has_alpha_spec($inner_tokens)
Truth table66%2/3
A ||= B
A= $has_alpha_specB= _has_alpha_spec($inner_tokens)
ABresult
1X1
011
000
176  
177 42 foreach my $inner_tok (@{$inner_tokens}) {
178 61 ▶ if ($inner_tok->{'type'} eq 'WHITESPACE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inner_tok->{"type"} eq "WHITESPACE") 2 59 61
179 2 _check_whitespace_token($inner_tok, $has_alpha_spec);
180 0 next;
181 }
182 59 ▶ if ($inner_tok->{'type'} eq 'AUX_GROUP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inner_tok->{"type"} eq "AUX_GROUP") 3 56 59
183 3 _check_aux_group_token($inner_tok, $inner_position_offset, $has_alpha_spec);
184 3 next;
185 }
186  
187 56 _check_aux_time_tokens($inner_tok, $inner_position_offset);
188 56 _check_number_token($inner_tok, $inner_position_offset);
189 }
190  
191 39 return;
192 }
193  
194 307 ▶sub _check_apos_aux_tokens {
Subroutine _check_apos_aux_tokens: called CC=3 SCAR=11.0
195 307 my $tok = shift;
196  
197 307 ▶ if ($tok->{'type'} ne 'APOS_AUX') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} ne "APOS_AUX") 286 21 307
198 286 return;
199 }
200 21 ▶ if (substr($tok->{'value'}, 0, 1) eq "'") {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($tok->{"value"}, 0, 1) eq "'") 16 5 21
201 16 return;
202 }
203  
204 5 my ($character) = $tok->{'value'} =~ /^(&apos;|.)/us;
205 err 'Bad apostrophe character.',
206 'character' => $character,
207 5 'position' => $tok->{'pos'},
208 ;
209  
210 0 return;
211 }
212  
213 358 ▶sub _check_aux_time_tokens {
Subroutine _check_aux_time_tokens: called CC=5 SCAR=16.1
214 358 my ($tok, $position_offset) = @_;
215  
216 358 ▶ $position_offset //= 0;
Condition100%2/2
$position_offset //= 0
l!l
56302
MC/DC100%1/1
$position_offset //= 0
$position_offset
Truth table100%2/2
A
A= $position_offset
Aresult
11
00
217  
218 358 ▶ if ($tok->{'type'} ne 'AUX_TIME') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} ne "AUX_TIME") 348 10 358
219 348 return;
220 }
221  
222 10 my ($left, $left_length) = _time_quote_at_start($tok->{'value'});
223 10 ▶ if ($left ne '"') {
Branch: 1 branch
BranchTrueFalseTotal
if ($left ne "\"") 2 8 10
224 err 'Bad quotation mark character.',
225 'character' => $left,
226 2 'position' => $position_offset + $tok->{'pos'},
227 ;
228 }
229  
230 8 my ($right, $right_length) = _time_quote_at_end($tok->{'value'});
231 8 ▶ if ($right ne '"') {
Branch: 1 branch
BranchTrueFalseTotal
if ($right ne "\"") 1 7 8
232 err 'Bad quotation mark character.',
233 'character' => $right,
234 1 'position' => $position_offset + $tok->{'pos'} + length($tok->{'value'}) - $right_length,
235 ;
236 }
237  
238 7 return;
239 }
240  
241 355 ▶sub _check_number_token {
Subroutine _check_number_token: called CC=5 SCAR=16.1
242 355 my ($tok, $position_offset) = @_;
243  
244 355 ▶ $position_offset //= 0;
Condition100%2/2
$position_offset //= 0
l!l
56299
MC/DC100%1/1
$position_offset //= 0
$position_offset
Truth table100%2/2
A
A= $position_offset
Aresult
11
00
245  
246 355 ▶ if ($tok->{'type'} ne 'NUMBER' && $tok->{'type'} ne 'FORM') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} ne "NUMBER" and $tok->{"type"} ne "FORM") 162 193 355
Condition100%3/3
$tok->{"type"} ne "NUMBER" and $tok->{"type"} ne "FORM"
!ll&&!rl&&r
16231162
MC/DC100%2/2
$tok->{"type"} ne "NUMBER" and $tok->{"type"} ne "FORM"
$tok->{"type"} ne "NUMBER" $tok->{"type"} ne "FORM"
Truth table100%3/3
A and B
A= $tok->{"type"} ne "NUMBER"B= $tok->{"type"} ne "FORM"
ABresult
0X0
100
111
247 162 return;
248 }
249 193 ▶ if ($tok->{'value'} !~ /,/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tok->{"value"} =~ /,/) 189 4 193
250 189 return;
251 }
252  
253 err 'Bad dot character in number.',
254 4 'position' => $position_offset + $tok->{'pos'} + index($tok->{'value'}, ','),
255 'character' => ',',
256 ;
257 }
258  
259 10 ▶sub _time_quote_at_start {
Subroutine _time_quote_at_start: called CC=2 SCAR=6.9
260 10 my $value = shift;
261  
262 10 ▶ if (substr($value, 0, 2) eq "''") {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($value, 0, 2) eq "''") 1 9 10
263 1 return ("''", 2);
264 }
265  
266 9 return (substr($value, 0, 1), 1);
267 }
268  
269 8 ▶sub _time_quote_at_end {
Subroutine _time_quote_at_end: called CC=2 SCAR=6.9
270 8 my $value = shift;
271  
272 8 ▶ if (substr($value, -2) eq "''") {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($value, -2) eq "''") 1 7 8
273 1 return ("''", 2);
274 }
275  
276 7 return (substr($value, -1), 1);
277 }
278  
279 207 ▶sub _consume {
Subroutine _consume: called CC=1 SCAR=0.0
280 207 my $state_hr = shift;
281  
282 207 return $state_hr->{'tokens'}[$state_hr->{'pos'}++];
283 }
284  
285 4 ▶sub _expect {
Subroutine _expect: called CC=3 SCAR=12.3
286 4 my ($state_hr, $type) = @_;
287  
288 4 my $tok = _peek($state_hr);
289 4 ▶ if (! $tok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tok) 0 4 4
290 0 err "Expected '$type' but reached end of input.";
291 }
292 4 ▶ if ($tok->{'type'} ne $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} ne $type) 0 4 4
293 err "Expected $type but got $tok->{'type'} ('$tok->{'value'}').",
294 0 'position' => $tok->{'pos'},
295 ;
296 }
297  
298 4 return _consume($state_hr);
299 }
300  
301 75 ▶sub _parse_expression {
Subroutine _parse_expression: called CC=18 SCAR=28.9
302 75 my $state_hr = shift;
303  
304 75 my $left = _parse_term($state_hr);
305 65 ▶ while (my $tok = _peek($state_hr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tok = _peek($state_hr)) 44 51 95
306 44 ▶ if (! is_operator_token($tok->{'type'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_operator_token($tok->{"type"})) 9 35 44
307 9 ▶ if ($tok->{'type'} eq 'NUMBER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "NUMBER") 3 6 9
308 3 ▶ if (_term_ends_with_auxiliary($left)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_term_ends_with_auxiliary($left)) 3 0 3
309 err 'Missing operator.',
310 3 'position' => $tok->{'pos'},
311 ;
312 }
313 }
314 6 last;
315 }
316 35 ▶ if (! is_valid_operator($tok->{'value'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_operator($tok->{"value"})) 0 35 35
317 0 last;
318 }
319  
320 35 my $op = _consume($state_hr);
321 35 ▶ my $next = _peek($state_hr)
Branch: 1 branch
BranchTrueFalseTotal
my $next = _peek($state_hr) or err(qq[Expected term after operator '$op->{"value"}'.]) 34 1 35
322 or err "Expected term after operator '$op->{'value'}'.";
323 err "Token '$next->{'value'}' is not allowed after operator '$op->{'value'}'."
324 if $next->{'type'} ne 'LBRACK'
325 34 ▶ && ! can_follow_operator($op->{'value'}, $next->{'type'});
Branch: 1 branch
BranchTrueFalseTotal
if $next->{"type"} ne "LBRACK" and not can_follow_operator($op->{"value"}, $next->{"type"}) 2 32 34
Condition100%3/3
$next->{"type"} ne "LBRACK" and not can_follow_operator($op->{"value"}, $next->{"type"})
!ll&&!rl&&r
1312
MC/DC100%2/2
$next->{"type"} ne "LBRACK" and not can_follow_operator($op->{"value"}, $next->{"type"})
$next->{"type"} ne "LBRACK" not can_follow_operator($op->{"value"}, $next->{"type"})
Truth table100%3/3
A and not(B)
A= $next->{"type"} ne "LBRACK"B= not can_follow_operator($op->{"value"}, $next->{"type"})
ABresult
0X0
100
111
326 32 my $right = _parse_term_after_operator($state_hr, $op->{'value'});
327  
328 32 ▶ if ($op->{'value'} eq '/' && $right->{'type'} eq 'APOS_AUX') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{"value"} eq "/" and $right->{"type"} eq "APOS_AUX") 5 27 32
Condition100%3/3
$op->{"value"} eq "/" and $right->{"type"} eq "APOS_AUX"
!ll&&!rl&&r
1895
MC/DC100%2/2
$op->{"value"} eq "/" and $right->{"type"} eq "APOS_AUX"
$op->{"value"} eq "/" $right->{"type"} eq "APOS_AUX"
Truth table100%3/3
A and B
A= $op->{"value"} eq "/"B= $right->{"type"} eq "APOS_AUX"
ABresult
0X0
100
111
329 5 my ($base, $from) = _split_trailing_apos_aux($left);
330 5 ▶ if (! $from) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($from) 2 3 5
331 err "Apostrophe auxiliary range shorthand '$op->{'value'}$right->{'value'}' ".
332 "requires apostrophe auxiliary on the left side.",
333  
334 2 'position' => $op->{'pos'},
335 ;
336 }
337  
338 my $range = {
339 type => 'APOS_RANGE',
340 base => $base,
341 from => $from->{'value'},
342 3 to => $right->{'value'},
343 };
344 3 ▶ if (my $modifier = _peek($state_hr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $modifier = _peek($state_hr)) 1 2 3
345 1 ▶ if ($modifier->{'type'} eq 'FORM') {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier->{"type"} eq "FORM") 1 0 1
346 1 _consume($state_hr);
347 $range->{'modifiers'} = [{
348 type => $modifier->{'type'},
349 1 value => $modifier->{'value'},
350 }];
351 }
352 }
353 3 $left = $range;
354  
355 3 next;
356 }
357  
358 $left = {
359 type => 'BINARY_OP',
360 27 operator => $tok->{'value'},
361 left => $left,
362 right => $right,
363 };
364  
365 27 ▶ if ($op->{'value'} eq '/') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{"value"} eq "/") 9 18 27
366 9 my @modifiers;
367 9 my $current_type = 'NUMBER';
368 9 my $current_value = undef;
369  
370 9 ▶ while (my $next_tok = _peek($state_hr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $next_tok = _peek($state_hr)) 3 8 11
371 3 ▶ if (! can_follow_primary(
Branch: 1 branch
BranchTrueFalseTotal
unless (can_follow_primary($next_tok->{"type"}, $next_tok->{"value"}, $current_type, $current_value)) 1 2 3
372 $next_tok->{'type'},
373 $next_tok->{'value'},
374 $current_type,
375 $current_value,
376 )) {
377 1 last;
378 }
379  
380 push @modifiers, {
381 type => $next_tok->{'type'},
382 2 value => $next_tok->{'value'},
383 };
384  
385 2 $current_type = $next_tok->{'type'};
386 2 $current_value = $next_tok->{'value'};
387  
388 2 _consume($state_hr);
389 }
390 9 ▶ if (@modifiers) {
Branch: 1 branch
BranchTrueFalseTotal
if (@modifiers) 2 7 9
391 2 $left = {
392 type => 'TERM',
393 primary => $left,
394 modifiers => \@modifiers,
395 };
396 }
397 }
398 }
399  
400 57 return $left;
401 }
402  
403 3 ▶sub _term_ends_with_auxiliary {
Subroutine _term_ends_with_auxiliary: called CC=9 SCAR=25.4
404 3 my $node = shift;
405  
406 3 ▶ while ($node && $node->{'type'} eq 'BINARY_OP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($node and $node->{"type"} eq "BINARY_OP") 2 3 5
Condition66%2/3
$node and $node->{"type"} eq "BINARY_OP"
!ll&&!rl&&r
032
MC/DC50%1/2
$node and $node->{"type"} eq "BINARY_OP"
$node $node->{"type"} eq "BINARY_OP"
Truth table66%2/3
A and B
A= $nodeB= $node->{"type"} eq "BINARY_OP"
ABresult
0X0
100
111
407 2 $node = $node->{'right'};
408 }
409 3 ▶ return if ! $node || $node->{'type'} ne 'TERM';
Branch: 1 branch
BranchTrueFalseTotal
if not $node or $node->{"type"} ne "TERM" 0 3 3
Condition33%1/3
not $node or $node->{"type"} ne "TERM"
l!l&&r!l&&!r
003
MC/DC0%0/2
not $node or $node->{"type"} ne "TERM"
not $node $node->{"type"} ne "TERM"
Truth table33%1/3
not(A) or B
A= not $nodeB= $node->{"type"} ne "TERM"
ABresult
1X1
011
000
410 3 ▶ return if ! $node->{'modifiers'} || ! @{$node->{'modifiers'}}
Condition66%2/3
$node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
!ll&&!rl&&r
210
MC/DC0%0/2
$node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
$node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
Truth table66%2/3
A and B
A= $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME"B= $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
ABresult
0X0
100
111
411 || $node->{'modifiers'}[-1]{'type'} ne 'AUX_TIME'
412 3 ▶ && $node->{'modifiers'}[-1]{'type'} ne 'AUX_GROUP';
Branch: 1 branch
BranchTrueFalseTotal
if not $node->{"modifiers"} && @{$node->{"modifiers"};} or $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP" 0 3 3
Condition33%2/6
not $node->{"modifiers"} && @{$node->{"modifiers"};} or $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
l!l&&r!l&&!r
003
$node->{'modifiers'} && @{$node->{'modifiers'};}
!ll&&!rl&&r
003
MC/DC33%1/3
not $node->{"modifiers"} && @{$node->{"modifiers"};} or $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
$node->{'modifiers'} @{$node->{'modifiers'};} $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
Truth table50%2/4
not(A && B) or C
A= $node->{'modifiers'}B= @{$node->{'modifiers'};}C= $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
ABCresult
0XX1
10X1
1111
1100
413  
414 3 return 1;
415 }
416  
417 99 ▶sub _parse_primary {
Subroutine _parse_primary: called CC=6 SCAR=17.9
418 99 my $state_hr = shift;
419  
420 99 ▶ my $tok = _peek($state_hr)
Branch: 1 branch
BranchTrueFalseTotal
my $tok = _peek($state_hr) or err("Expected term but reached end of input.") 99 0 99
421 or err 'Expected term but reached end of input.';
422  
423 99 ▶ if ($tok->{'type'} eq 'LBRACK') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "LBRACK") 4 95 99
424 4 return _parse_subgroup($state_hr);
425 }
426  
427 95 ▶ if (is_primary_token($tok->{'type'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_primary_token($tok->{"type"})) 85 10 95
428 85 _consume($state_hr);
429 return {
430 'type' => $tok->{'type'},
431 85 'value' => $tok->{'value'},
432 };
433 }
434  
435 10 ▶ if ($tok->{'type'} eq 'ALPHA_SPEC') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "ALPHA_SPEC") 3 7 10
436 err "Alphabetical specification cannot appear standalone.",
437 'position' => $tok->{'pos'},
438 3 'value' => $tok->{'value'},
439 ;
440 }
441  
442 7 ▶ if ($tok->{'type'} eq 'APOS_AUX') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "APOS_AUX") 1 6 7
443 1 err "Apostrophe auxiliary '$tok->{'value'}' must follow a valid UDC notation.";
444 }
445  
446 err "Expected NUMBER, subgroup, or standalone auxiliary but got $tok->{'type'} ('$tok->{'value'}').",
447 6 'position' => $tok->{'pos'},
448 ;
449 }
450  
451 4 ▶sub _parse_subgroup {
Subroutine _parse_subgroup: called CC=3 SCAR=11.7
452 4 my $state_hr = shift;
453  
454 4 my $lbrack = _expect($state_hr, 'LBRACK');
455 4 my $expr = _parse_expression($state_hr);
456  
457 4 my $end = _peek($state_hr);
458 4 ▶ if (! $end) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($end) 0 4 4
459 err "Unclosed subgroup '['.",
460 0 'position' => $lbrack->{'pos'},
461 ;
462 }
463 4 ▶ if ($end->{'type'} ne 'RBRACK') {
Branch: 1 branch
BranchTrueFalseTotal
if ($end->{"type"} ne "RBRACK") 0 4 4
464 err "Expected closing ']' for subgroup but got '$end->{'value'}'.",
465 0 'position' => $end->{'pos'},
466 ;
467 }
468 4 _consume($state_hr);
469  
470 return {
471 4 'type' => 'SUBGROUP',
472 'expression' => $expr,
473 };
474 }
475  
476 98 ▶sub _parse_term {
Subroutine _parse_term: called CC=15 SCAR=27.7
477 98 my $state_hr = shift;
478  
479 98 my $primary = _parse_primary($state_hr);
480 88 ▶ if ($primary->{'type'} ne 'NUMBER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($primary->{"type"} ne "NUMBER") 13 75 88
481 13 my $next = _peek($state_hr);
482 13 ▶ if ($next && $next->{'type'} eq 'NUMBER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and $next->{"type"} eq "NUMBER") 4 9 13
Condition100%3/3
$next and $next->{"type"} eq "NUMBER"
!ll&&!rl&&r
364
MC/DC100%2/2
$next and $next->{"type"} eq "NUMBER"
$next $next->{"type"} eq "NUMBER"
Truth table100%3/3
A and B
A= $nextB= $next->{"type"} eq "NUMBER"
ABresult
0X0
100
111
483 4 ▶ if (! can_precede_number($primary->{'type'}, $primary->{'value'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (can_precede_number($primary->{"type"}, $primary->{"value"})) 0 4 4
484 0 ▶ my $what = defined $primary->{'value'} ? $primary->{'value'} : $primary->{'type'};
Branch: 1 branch
BranchTrueFalseTotal
defined $primary->{'value'} ? : 0 0 0
485 0 err "NUMBER cannot follow '$what'.";
486 }
487  
488 4 my $number = _consume($state_hr);
489  
490 4 my @modifiers;
491 4 my $current_type = 'NUMBER';
492 4 my $current_value = $number->{'value'};
493 4 my $has_main_number = 1;
494 4 ▶ while (my $tok = _peek($state_hr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tok = _peek($state_hr)) 1 4 5
495 1 ▶ if (any { $tok->{'type'} eq $_ } qw(APOS_AUX AUX_DOT)) {
Subroutine __ANON__: called CC=1 SCAR=0.4
Branch: 2 branches
BranchTrueFalseTotal
if (&any(sub { $tok->{'type'} eq $_; } , 'APOS_AUX', 'AUX_DOT')) { } 0 1 1
elsif (not can_follow_primary($tok->{'type'}, $tok->{'value'}, $current_type, $current_value)) { } 0 1 1
496 0 ▶ if (! $has_main_number) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_main_number) 0 0 0
497 0 last;
498 }
499 } elsif (! can_follow_primary(
500 $tok->{'type'},
501 $tok->{'value'},
502 $current_type,
503 $current_value,
504 )) {
505 0 last;
506 }
507  
508 push @modifiers, {
509 'type' => $tok->{'type'},
510 1 'value' => $tok->{'value'},
511 };
512  
513 1 $current_type = $tok->{'type'};
514 1 $current_value = $tok->{'value'};
515  
516 1 _consume($state_hr);
517 }
518  
519 return {
520 'type' => 'TERM',
521 'prefixes' => [
522 {
523 'type' => $primary->{'type'},
524 'value' => $primary->{'value'},
525 },
526 ],
527 'primary' => {
528 'type' => 'NUMBER',
529 4 'value' => $number->{'value'},
530 },
531 'modifiers' => \@modifiers,
532 };
533 }
534 }
535  
536 84 my @modifiers;
537 84 my $current_type = $primary->{'type'};
538 84 my $current_value = $primary->{'value'};
539 84 ▶ my $allow_dot_aux = any { $primary->{'type'} eq $_ } qw(NUMBER SUBGROUP);
Subroutine __ANON__: called CC=1 SCAR=0.0
540 84 ▶ while (my $tok = _peek($state_hr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tok = _peek($state_hr)) 106 41 147
541 106 ▶ if ($tok->{'type'} eq 'LBRACK') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "LBRACK") 1 105 106
542 1 my $subgroup = _parse_primary($state_hr);
543  
544 1 push @modifiers, $subgroup;
545  
546 1 $current_type = $subgroup->{'type'};
547 1 $current_value = undef;
548  
549 1 next;
550 }
551  
552 105 ▶ if ($tok->{'type'} eq 'AUX_DOT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} eq "AUX_DOT") 4 101 105
553 4 ▶ if (! $allow_dot_aux) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($allow_dot_aux) 1 3 4
554 1 last;
555 }
556 }
557 104 ▶ if (! can_follow_primary(
Branch: 1 branch
BranchTrueFalseTotal
unless (can_follow_primary($tok->{"type"}, $tok->{"value"}, $current_type, $current_value)) 42 62 104
558 $tok->{'type'},
559 $tok->{'value'},
560 $current_type,
561 $current_value,
562 )) {
563 42 last;
564 }
565  
566 push @modifiers, {
567 'type' => $tok->{'type'},
568 62 'value' => $tok->{'value'},
569 };
570  
571 62 $current_type = $tok->{'type'};
572 62 $current_value = $tok->{'value'};
573  
574 62 _consume($state_hr);
575 }
576  
577 return {
578 84 'type' => 'TERM',
579 'primary' => $primary,
580 'modifiers' => \@modifiers,
581 };
582 }
583  
584 32 ▶sub _parse_term_after_operator {
Subroutine _parse_term_after_operator: called CC=8 SCAR=20.8
585 32 my ($state_hr, $op) = @_;
586  
587 32 ▶ my $tok = _peek($state_hr)
Branch: 1 branch
BranchTrueFalseTotal
my $tok = _peek($state_hr) or err("Expected term after operator '${op}'.") 32 0 32
588 or err "Expected term after operator '$op'.";
589  
590 32 ▶ if ($op eq '/' && $tok->{'type'} eq 'AUX_DOT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "/" and $tok->{"type"} eq "AUX_DOT") 3 29 32
Condition100%3/3
$op eq "/" and $tok->{"type"} eq "AUX_DOT"
!ll&&!rl&&r
18113
MC/DC100%2/2
$op eq "/" and $tok->{"type"} eq "AUX_DOT"
$op eq "/" $tok->{"type"} eq "AUX_DOT"
Truth table100%3/3
A and B
A= $op eq "/"B= $tok->{"type"} eq "AUX_DOT"
ABresult
0X0
100
111
591 3 _consume($state_hr);
592 return {
593 type => 'PARTIAL_NUMBER',
594 3 value => $tok->{'value'},
595 };
596 }
597  
598 29 ▶ if ($op eq '/' && $tok->{'type'} eq 'FORM') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "/" and $tok->{"type"} eq "FORM") 1 28 29
Condition100%3/3
$op eq "/" and $tok->{"type"} eq "FORM"
!ll&&!rl&&r
18101
MC/DC100%2/2
$op eq "/" and $tok->{"type"} eq "FORM"
$op eq "/" $tok->{"type"} eq "FORM"
Truth table100%3/3
A and B
A= $op eq "/"B= $tok->{"type"} eq "FORM"
ABresult
0X0
100
111
599 1 _consume($state_hr);
600 return {
601 type => 'PARTIAL_FORM',
602 1 value => $tok->{'value'},
603 };
604 }
605  
606 28 ▶ if ($op eq '/' && $tok->{'type'} eq 'APOS_AUX') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "/" and $tok->{"type"} eq "APOS_AUX") 5 23 28
Condition100%3/3
$op eq "/" and $tok->{"type"} eq "APOS_AUX"
!ll&&!rl&&r
1855
MC/DC100%2/2
$op eq "/" and $tok->{"type"} eq "APOS_AUX"
$op eq "/" $tok->{"type"} eq "APOS_AUX"
Truth table100%3/3
A and B
A= $op eq "/"B= $tok->{"type"} eq "APOS_AUX"
ABresult
0X0
100
111
607 5 _consume($state_hr);
608 return {
609 type => 'APOS_AUX',
610 5 value => $tok->{'value'},
611 };
612 }
613  
614 23 return _parse_term($state_hr);
615 }
616  
617 448 ▶sub _peek {
Subroutine _peek: called CC=1 SCAR=0.0
618 448 my $state_hr = shift;
619  
620 448 return $state_hr->{'tokens'}[$state_hr->{'pos'}];
621 }
622  
623 293 ▶sub _normalize_alpha_spec_token {
Subroutine _normalize_alpha_spec_token: called CC=2 SCAR=6.9
624 293 my $tok = shift;
625  
626 293 ▶ if ($tok->{'type'} ne 'ALPHA_SPEC') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tok->{"type"} ne "ALPHA_SPEC") 273 20 293
627 273 return;
628 }
629  
630 20 my ($value, $pos) = _trim_alpha_spec_value($tok);
631 20 $tok->{'pos'} = $pos;
632 20 $tok->{'value'} = $value;
633  
634 20 return;
635 }
636  
637 20 ▶sub _trim_alpha_spec_value {
Subroutine _trim_alpha_spec_value: called CC=2 SCAR=6.9
638 20 my $tok = shift;
639  
640 20 my $value = $tok->{'value'};
641 20 my $pos = $tok->{'pos'};
642  
643 20 ▶ if ($value =~ s/^(\s+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ s/^(\s+)//) 9 11 20
644 9 $pos += length($1);
645 }
646 20 $value =~ s/\s+\z//;
647  
648 20 return ($value, $pos);
649 }
650  
651 5 ▶sub _split_trailing_apos_aux {
Subroutine _split_trailing_apos_aux: called CC=8 SCAR=22.5
652 5 my $node = shift;
653  
654 5 ▶ if (! defined $node) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $node) 0 5 5
655 0 return;
656 }
657 5 ▶ if ($node->{'type'} ne 'TERM') {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"type"} ne "TERM") 1 4 5
658 1 return;
659 }
660 4 ▶ if (! $node->{'modifiers'} || ! @{$node->{'modifiers'}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($node->{"modifiers"} and @{$node->{"modifiers"};}) 1 3 4
Condition66%2/3
$node->{"modifiers"} and @{$node->{"modifiers"};}
!ll&&!rl&&r
013
MC/DC50%1/2
$node->{"modifiers"} and @{$node->{"modifiers"};}
$node->{"modifiers"} @{$node->{"modifiers"};}
Truth table66%2/3
A and B
A= $node->{"modifiers"}B= @{$node->{"modifiers"};}
ABresult
0X0
100
111
661 1 return;
662 }
663  
664 3 my @modifiers = @{$node->{'modifiers'}};
665 3 my $last = $modifiers[-1];
666 3 ▶ if (! defined $last || $last->{'type'} ne 'APOS_AUX') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $last or $last->{"type"} ne "APOS_AUX") 0 3 3
Condition33%1/3
not defined $last or $last->{"type"} ne "APOS_AUX"
l!l&&r!l&&!r
003
MC/DC0%0/2
not defined $last or $last->{"type"} ne "APOS_AUX"
not defined $last $last->{"type"} ne "APOS_AUX"
Truth table33%1/3
not(A) or B
A= not defined $lastB= $last->{"type"} ne "APOS_AUX"
ABresult
1X1
011
000
667 0 return;
668 }
669  
670 3 pop @modifiers;
671  
672 my $base = {
673 type => 'TERM',
674 3 primary => $node->{'primary'},
675 modifiers => \@modifiers,
676 };
677  
678 3 ▶ if (exists $node->{'prefixes'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{"prefixes"}) 0 3 3
679 0 $base->{'prefixes'} = [ @{$node->{'prefixes'}} ];
680 }
681  
682 3 return ($base, $last);
683 }
684  
685 10 1;
686  
687 __END__
« UDC/Tokenizer.pm ↑ Summary UDC/Grammar.pm »