File Coverage

blib/lib/Inline/C/Parser/Pegex/AST.pm
Criterion Covered Total %
statement 35 35 100.0
branch 4 4 100.0
condition n/a
subroutine 7 7 100.0
pod 2 4 50.0
total 48 50 96.0


line stmt bran cond sub pod time code
1 2     2   400 use strict; use warnings;
  2     2   3  
  2         53  
  2         9  
  2         3  
  2         60  
2             package Inline::C::Parser::Pegex::AST;
3 2     2   9 use Pegex::Base;
  2         4  
  2         9  
4              
5             extends 'Pegex::Tree';
6              
7             has data => {};
8              
9             sub initial {
10 24     24 1 37700 my ($self) = @_;
11 24         112 my $data = {
12             functions => [],
13             function => {},
14             done => {},
15             };
16 24         97 $self->data($data);
17             }
18              
19             sub final {
20 24     24 1 26617 my ($self, $got) = @_;
21 24         78 return $self->{data};
22             }
23              
24             sub got_function_definition {
25 11     11 0 1697 my ($self, $ast) = @_;
26 11         40 my ($rtype, $name, $args) = @$ast;
27 11         30 my ($rname, $rstars) = @$rtype;
28 11         33 my $data = $self->data;
29 11         63 my $def = $data->{function}{$name} = {};
30 11         24 push @{$data->{functions}}, $name;
  11         32  
31 11 100       49 $def->{return_type} = $rname . ($rstars ? " $rstars" : '');
32 11         22 $def->{arg_names} = [];
33 11         23 $def->{arg_types} = [];
34 11         29 for my $arg (@$args) {
35 14         33 my ($type, $stars, $name) = @$arg;
36 14         22 push @{$def->{arg_names}}, $name;
  14         31  
37 14 100       19 push @{$def->{arg_types}}, $type . ($stars ? " $stars" : '');
  14         57  
38             }
39 11         21 $data->{done}{$name} = 1;
40 11         46 return;
41             }
42              
43              
44             sub got_arg {
45 21     21 0 9538 my ($self, $ast) = @_;
46 21         48 pop @$ast;
47 21         81 return $ast;
48             }
49              
50             1;