ClassFile/BNF/TypeAnnotation.pm

filter: Statementstmt 32.6% 15 / 46 Branchbran 0.0% 0 / 44 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 41.6% 5 / 12 Podpod n/a totaltotal 19.6% 20 / 102 SCAR 58.0
CC
23
Cov
17%
__ANON__
552.0
grammar
2.0
__ANON__
2.0
CRAP 329.1
« ClassFile/Struct/_Base.pm ↑ Summary ClassFile/BNF/ConstantPoolArray.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package MarpaX::Java::ClassFile::BNF::TypeAnnotation;
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: Parsing of a type_annotation
8  
9 our $VERSION = '0.008'; # VERSION
10  
11 our $AUTHORITY = 'cpan:JDDPAUSE'; # AUTHORITY
12  
13 #
14 # Note: this union is easy, no need to subclass the BNFs
15 #
16  
17 1 ▶use Data::Section -setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use MarpaX::Java::ClassFile::Util::BNF qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 #
20 # require because we do not import ANYTHING from these module, just require they are loaded
21 #
22 require Marpa::R2;
23 require MarpaX::Java::ClassFile::Struct::TypeAnnotation;
24 require MarpaX::Java::ClassFile::BNF::TypeParameterTarget;
25 require MarpaX::Java::ClassFile::BNF::SupertypeTarget;
26 require MarpaX::Java::ClassFile::BNF::TypeParameterBoundTarget;
27 # require MarpaX::Java::ClassFile::BNF::EmptyTarget; Special case: nothing to parse
28 require MarpaX::Java::ClassFile::Struct::EmptyTarget;
29 require MarpaX::Java::ClassFile::BNF::FormalParameterTarget;
30 require MarpaX::Java::ClassFile::BNF::ThrowsTarget;
31 require MarpaX::Java::ClassFile::BNF::LocalvarTarget;
32 require MarpaX::Java::ClassFile::BNF::CatchTarget;
33 require MarpaX::Java::ClassFile::BNF::OffsetTarget;
34 require MarpaX::Java::ClassFile::BNF::TypeArgumentTarget;
35 require MarpaX::Java::ClassFile::BNF::TypePath;
36 require MarpaX::Java::ClassFile::BNF::ElementValuePairArray;
37  
38 my $_data = ${ __PACKAGE__->section_data('bnf') };
39 my $_grammar = Marpa::R2::Scanless::G->new( { source => \__PACKAGE__->bnf($_data) } );
40  
41 # --------------------------------------------------------
42 # What role MarpaX::Java::ClassFile::Role::Parser requires
43 # --------------------------------------------------------
44 0 ▶sub grammar { $_grammar }
Subroutine grammar: not called CC=1 SCAR=6.9
45 sub callbacks { return {
46 0 ▶ "'exhausted" => sub { $_[0]->exhausted },
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 'target_type$' => sub {
48 0 ▶ my $target_type = $_[0]->literalU1('target_type');
Subroutine __ANON__: not called CC=23 SCAR=63.1
49 0 ▶ if ($target_type == 0x00) { $_[0]->inner('TypeParameterTarget') }
Branch: 22 branches
BranchTrueFalseTotal
if ($target_type == 0) { } 0 0 0
elsif ($target_type == 1) { } 0 0 0
elsif ($target_type == 16) { } 0 0 0
elsif ($target_type == 17) { } 0 0 0
elsif ($target_type == 18) { } 0 0 0
elsif ($target_type == 19) { } 0 0 0
elsif ($target_type == 20) { } 0 0 0
elsif ($target_type == 21) { } 0 0 0
elsif ($target_type == 22) { } 0 0 0
elsif ($target_type == 23) { } 0 0 0
elsif ($target_type == 64) { } 0 0 0
elsif ($target_type == 65) { } 0 0 0
elsif ($target_type == 66) { } 0 0 0
elsif ($target_type == 67) { } 0 0 0
elsif ($target_type == 68) { } 0 0 0
elsif ($target_type == 69) { } 0 0 0
elsif ($target_type == 70) { } 0 0 0
elsif ($target_type == 71) { } 0 0 0
elsif ($target_type == 72) { } 0 0 0
elsif ($target_type == 73) { } 0 0 0
elsif ($target_type == 74) { } 0 0 0
elsif ($target_type == 75) { } 0 0 0
50 0 elsif ($target_type == 0x01) { $_[0]->inner('TypeParameterTarget') }
51 0 elsif ($target_type == 0x10) { $_[0]->inner('SupertypeTarget') }
52 0 elsif ($target_type == 0x11) { $_[0]->inner('TypeParameterBoundTarget') }
53 0 elsif ($target_type == 0x12) { $_[0]->inner('TypeParameterBoundTarget') }
54 0 elsif ($target_type == 0x13) { $_[0]->lexeme_read('MANAGED', 0, MarpaX::Java::ClassFile::Struct::EmptyTarget->new) }
55 0 elsif ($target_type == 0x14) { $_[0]->lexeme_read('MANAGED', 0, MarpaX::Java::ClassFile::Struct::EmptyTarget->new) }
56 0 elsif ($target_type == 0x15) { $_[0]->lexeme_read('MANAGED', 0, MarpaX::Java::ClassFile::Struct::EmptyTarget->new) }
57 0 elsif ($target_type == 0x16) { $_[0]->inner('FormalParameterTarget') }
58 0 elsif ($target_type == 0x17) { $_[0]->inner('ThrowsTarget') }
59 0 elsif ($target_type == 0x40) { $_[0]->inner('LocalvarTarget') }
60 0 elsif ($target_type == 0x41) { $_[0]->inner('LocalvarTarget') }
61 0 elsif ($target_type == 0x42) { $_[0]->inner('CatchTarget') }
62 0 elsif ($target_type == 0x43) { $_[0]->inner('OffsetTarget') }
63 0 elsif ($target_type == 0x44) { $_[0]->inner('OffsetTarget') }
64 0 elsif ($target_type == 0x45) { $_[0]->inner('OffsetTarget') }
65 0 elsif ($target_type == 0x46) { $_[0]->inner('OffsetTarget') }
66 0 elsif ($target_type == 0x47) { $_[0]->inner('TypeArgumentTarget') }
67 0 elsif ($target_type == 0x48) { $_[0]->inner('TypeArgumentTarget') }
68 0 elsif ($target_type == 0x49) { $_[0]->inner('TypeArgumentTarget') }
69 0 elsif ($target_type == 0x4A) { $_[0]->inner('TypeArgumentTarget') }
70 0 elsif ($target_type == 0x4B) { $_[0]->inner('TypeArgumentTarget') }
71 0 else { $_[0]->fatalf('Unmanaged target tye %d', $target_type) }
72 },
73 '^target_path' => sub {
74 0 ▶ $_[0]->inner('TypePath')
Subroutine __ANON__: not called CC=1 SCAR=6.9
75 },
76 'num_element_value_pairs$' => sub {
77 0 ▶ $_[0]->inner('ElementValuePairArray', size => $_[0]->literalU2('num_element_value_pairs'))
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 }
79 }
80 0 ▶ }
Subroutine callbacks: not called CC=1 SCAR=6.9
81  
82 # ---------------
83 # Grammar actions
84 # ---------------
85 sub _typeAnnotation {
86 # my ($self, $target_type, $target_info, $target_path, $type_index, $num_element_value_pairs, $element_value_pairs) = @_;
87  
88 0 ▶ MarpaX::Java::ClassFile::Struct::TypeAnnotation->new(
Subroutine _typeAnnotation: not called CC=1 SCAR=6.9
89 _constant_pool => $_[0]->constant_pool,
90 target_type => $_[1],
91 target_info => $_[2],
92 target_path => $_[3],
93 type_index => $_[4],
94 num_element_value_pairs => $_[5],
95 element_value_pairs => $_[6]
96 )
97 }
98  
99 with 'MarpaX::Java::ClassFile::Role::Parser';
100  
101 1;
102  
103 =pod
104  
105 =encoding UTF-8
106  
107 =head1 NAME
108  
109 MarpaX::Java::ClassFile::BNF::TypeAnnotation - Parsing of a type_annotation
110  
111 =head1 VERSION
112  
113 version 0.008
114  
115 =head1 AUTHOR
116  
117 Jean-Damien Durand <jeandamiendurand@free.fr>
118  
119 =head1 COPYRIGHT AND LICENSE
120  
121 This software is copyright (c) 2016 by Jean-Damien Durand.
122  
123 This is free software; you can redistribute it and/or modify it under
124 the same terms as the Perl 5 programming language system itself.
125  
126 =cut
127  
128 __DATA__
129 __[ bnf ]__
130 event 'target_type$' = completed target_type
131 event '^target_path' = predicted target_path
132 event 'num_element_value_pairs$' = completed num_element_value_pairs
133 type_annotation ::= target_type target_info target_path type_index num_element_value_pairs action => _typeAnnotation
134 target_type ::= U1 action => u1
135 target_info ::= MANAGED action => ::first
136 target_path ::= MANAGED action => ::first
137 type_index ::= U2 action => u2
138 num_element_value_pairs ::= U2
139 element_value_pairs ::= MANAGED action => ::first
« ClassFile/Struct/_Base.pm ↑ Summary ClassFile/BNF/ConstantPoolArray.pm »