line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# DESCRIPTION: Make objectx from syntax tree |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, |
6
|
|
|
|
|
|
|
#=============================================================================== |
7
|
|
|
|
|
|
|
package Perl6::Pod::Lex::RawText; |
8
|
6
|
|
|
6
|
|
31
|
use base 'Perl6::Pod::Lex::Block'; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
1593
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Perl6::Pod::Lex::Text; |
12
|
6
|
|
|
6
|
|
34
|
use base 'Perl6::Pod::Lex::RawText'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
3088
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Perl6::Pod::Lex; |
16
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
17
|
6
|
|
|
6
|
|
37
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
158
|
|
18
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
527
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
17
|
|
|
17
|
0
|
263172
|
my $class = shift; |
21
|
17
|
50
|
33
|
|
|
159
|
my $self = bless( ( $#_ == 0 ) ? shift : {@_}, ref($class) || $class ); |
22
|
17
|
|
|
|
|
79
|
$self; |
23
|
|
|
|
|
|
|
} |
24
|
6
|
|
|
6
|
|
84
|
use v5.10; |
|
6
|
|
|
|
|
20
|
|
25
|
6
|
|
|
6
|
|
32
|
use Perl6::Pod::Utl; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
4338
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub make_block { |
28
|
53
|
|
|
53
|
0
|
79
|
my $self = shift; |
29
|
53
|
|
|
|
|
213
|
my %ref = @_; |
30
|
|
|
|
|
|
|
#save original bloack name |
31
|
53
|
|
|
|
|
122
|
my $name = $ref{src_name} = $ref{name}; |
32
|
|
|
|
|
|
|
#for items1,2 and heads |
33
|
53
|
50
|
|
|
|
168
|
if ($name =~ /(item|head)(\d+)/ ) { |
34
|
0
|
|
|
|
|
0
|
$name = $ref{name} = $1; |
35
|
0
|
|
|
|
|
0
|
$ref{level} = $2 |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
53
|
|
100
|
|
|
150
|
my $childs = $ref{content} || []; |
39
|
53
|
|
100
|
|
|
200
|
my $vmargin = length( $ref{spaces} // '' ); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#is first para if item|defn ? |
42
|
53
|
|
|
|
|
66
|
my $is_first = 1; |
43
|
|
|
|
|
|
|
|
44
|
53
|
|
|
|
|
103
|
foreach my $node (@$childs) { |
45
|
56
|
100
|
|
|
|
269
|
if ( $node->{type} eq 'block' ) { |
|
|
100
|
|
|
|
|
|
46
|
29
|
|
|
|
|
122
|
$node = $self->make_block(%$node); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ( $node->{type} =~ /text|raw/ ) { |
50
|
20
|
|
|
|
|
36
|
my $type = $node->{type}; |
51
|
20
|
100
|
|
|
|
107
|
if ( $type eq 'text' ) { |
52
|
15
|
|
|
|
|
120
|
$node = Perl6::Pod::Lex::Text->new(%$node); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
5
|
|
|
|
|
70
|
$node = Perl6::Pod::Lex::RawText->new(%$node); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
|
|
|
|
|
|
|
61
|
7
|
|
|
|
|
34
|
$node = $self->make_block(%$node); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
next |
65
|
56
|
100
|
100
|
|
|
606
|
unless UNIVERSAL::isa( $node, 'Perl6::Pod::Lex::Text' ) |
66
|
|
|
|
|
|
|
|| UNIVERSAL::isa( $node, 'Perl6::Pod::Lex::RawText' ); |
67
|
20
|
|
|
|
|
57
|
my $content = delete $node->{''}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#remove virual margin |
70
|
20
|
|
|
|
|
69
|
$content = Perl6::Pod::Utl::strip_vmargin( $vmargin, $content ); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#skip first text block for item| defn |
73
|
20
|
100
|
66
|
|
|
84
|
if ( $name =~ 'item|defn' and $is_first ) { |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#always ordinary text |
76
|
1
|
|
|
|
|
5
|
$content =~ s/^\s+//; |
77
|
1
|
|
|
|
|
3
|
$node = $content; |
78
|
1
|
|
|
|
|
8
|
$is_first=0; |
79
|
1
|
|
|
|
|
4
|
next; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#convert paragraph's to blocks |
84
|
|
|
|
|
|
|
my $is_implicit_code_and_para_blocks = |
85
|
|
|
|
|
|
|
$ref{force_implicit_code_and_para_blocks} |
86
|
19
|
|
100
|
|
|
639
|
|| $name =~ /(pod|item|defn|nested|finish|\U $name\E )/x; |
87
|
19
|
100
|
|
|
|
62
|
if ($is_implicit_code_and_para_blocks) { |
88
|
11
|
100
|
|
|
|
40
|
my $block_name = $content =~ /^\s+/ ? 'code' : 'para'; |
89
|
11
|
|
|
|
|
71
|
$node = Perl6::Pod::Lex::Block->new( |
90
|
|
|
|
|
|
|
%$node, |
91
|
|
|
|
|
|
|
name => $block_name, |
92
|
|
|
|
|
|
|
srctype => 'implicit', |
93
|
|
|
|
|
|
|
content => [$content] |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
8
|
100
|
|
|
|
24
|
if ( $name eq 'para' ) { |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#para blocks always |
101
|
|
|
|
|
|
|
# ordinary text |
102
|
3
|
|
|
|
|
9
|
$content =~ s/^\s+//; |
103
|
|
|
|
|
|
|
} |
104
|
8
|
|
|
|
|
50
|
$node = $content; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
53
|
|
|
|
|
271
|
return Perl6::Pod::Lex::Block->new(%ref); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub process_file { |
112
|
17
|
|
|
17
|
0
|
33
|
my $self = shift; |
113
|
17
|
|
|
|
|
26
|
my $ref = shift; |
114
|
17
|
|
|
|
|
41
|
$ref->{force_implicit_code_and_para_blocks} = 1; |
115
|
17
|
|
|
|
|
79
|
my $block = $self->make_block( %$ref, name => 'File' ); |
116
|
17
|
100
|
|
|
|
73
|
unless ($self->{default_pod} ) { |
117
|
|
|
|
|
|
|
# filter all implicit blocks |
118
|
12
|
|
|
|
|
23
|
my @result = (); |
119
|
12
|
|
|
|
|
16
|
foreach my $node (@ { $block->childs}) { |
|
12
|
|
|
|
|
42
|
|
120
|
13
|
|
100
|
|
|
49
|
my $type = $node->{srctype} || 'UNKNOWN'; |
121
|
13
|
100
|
|
|
|
47
|
push @result, $node unless $type eq 'implicit'; |
122
|
|
|
|
|
|
|
} |
123
|
12
|
|
|
|
|
39
|
$block->childs(\@result) |
124
|
|
|
|
|
|
|
} |
125
|
17
|
|
|
|
|
52
|
return $block->childs; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub make_tree { |
129
|
17
|
|
|
17
|
0
|
30
|
my $self = shift; |
130
|
17
|
|
|
|
|
34
|
my $tree = shift; |
131
|
17
|
|
|
|
|
33
|
my $type = $tree->{type}; |
132
|
17
|
|
|
|
|
43
|
my $method = "process_" . $type; |
133
|
17
|
|
|
|
|
69
|
return $self->$method($tree); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|