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   480 use strict; use warnings;
  2     2   5  
  2         53  
  2         8  
  2         4  
  2         60  
2             package Inline::C::Parser::Pegex::AST;
3 2     2   7 use Pegex::Base;
  2         4  
  2         9  
4              
5             extends 'Pegex::Tree';
6              
7             has data => {};
8              
9             sub initial {
10 24     24 1 37155 my ($self) = @_;
11 24         117 my $data = {
12             functions => [],
13             function => {},
14             done => {},
15             };
16 24         89 $self->data($data);
17             }
18              
19             sub final {
20 24     24 1 25934 my ($self, $got) = @_;
21 24         95 return $self->{data};
22             }
23              
24             sub got_function_definition {
25 11     11 0 1672 my ($self, $ast) = @_;
26 11         29 my ($rtype, $name, $args) = @$ast;
27 11         22 my ($rname, $rstars) = @$rtype;
28 11         30 my $data = $self->data;
29 11         61 my $def = $data->{function}{$name} = {};
30 11         22 push @{$data->{functions}}, $name;
  11         28  
31 11 100       45 $def->{return_type} = $rname . ($rstars ? " $rstars" : '');
32 11         27 $def->{arg_names} = [];
33 11         24 $def->{arg_types} = [];
34 11         26 for my $arg (@$args) {
35 14         38 my ($type, $stars, $name) = @$arg;
36 14         22 push @{$def->{arg_names}}, $name;
  14         32  
37 14 100       22 push @{$def->{arg_types}}, $type . ($stars ? " $stars" : '');
  14         45  
38             }
39 11         27 $data->{done}{$name} = 1;
40 11         42 return;
41             }
42              
43              
44             sub got_arg {
45 21     21 0 9345 my ($self, $ast) = @_;
46 21         41 pop @$ast;
47 21         57 return $ast;
48             }
49              
50             1;