line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package v6::perlito; |
2
|
31
|
|
|
31
|
|
13728
|
use Filter::Util::Call; |
|
31
|
|
|
|
|
20837
|
|
|
31
|
|
|
|
|
1596
|
|
3
|
31
|
|
|
31
|
|
151
|
use strict; |
|
31
|
|
|
|
|
35
|
|
|
31
|
|
|
|
|
8346
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub compile { |
6
|
31
|
|
|
31
|
0
|
51
|
my $source = $_[0]; |
7
|
31
|
50
|
|
|
|
172
|
return $source if $source =~ /^\s*$/; |
8
|
31
|
|
|
|
|
200
|
$::_V6_COMPILER_NAME = 'Perlito6'; |
9
|
31
|
|
|
|
|
35
|
$::_V6_COMPILER_VERSION = '8.0'; |
10
|
31
|
|
|
|
|
13756
|
require Perlito6::Perl5::Emitter; |
11
|
31
|
|
|
|
|
17360
|
require Perlito6::Grammar; |
12
|
31
|
|
|
|
|
316
|
require Perlito6::Grammar::Regex; |
13
|
31
|
|
|
|
|
13873
|
require Perlito6::Emitter::Token; |
14
|
31
|
|
|
|
|
10831
|
require Perlito6::Macro; |
15
|
31
|
|
|
|
|
75
|
my @comp_unit; |
16
|
31
|
|
|
|
|
50
|
my $pos = 0; |
17
|
31
|
|
|
|
|
193
|
my $p = Perlito6::Grammar->exp_stmts( $source, $pos ); |
18
|
31
|
50
|
33
|
|
|
802
|
if (!$p || length($source) > $p->to) { |
19
|
0
|
|
|
|
|
0
|
warn "<$source>\n"; |
20
|
0
|
|
|
|
|
0
|
die "Syntax error at pos ", $p->to, "\n"; |
21
|
|
|
|
|
|
|
} |
22
|
31
|
|
|
|
|
98
|
push @comp_unit, |
23
|
|
|
|
|
|
|
CompUnit->new( |
24
|
|
|
|
|
|
|
name => 'GLOBAL', |
25
|
|
|
|
|
|
|
body => $$p, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
# Don't write when we failed to compile, otherwise it never recompiles! |
28
|
31
|
50
|
|
|
|
163
|
die "Syntax error" unless @comp_unit; |
29
|
31
|
|
|
|
|
45
|
my $result; |
30
|
31
|
|
|
|
|
123
|
$result .= "# Do not edit this file - Generated by $::_V6_COMPILER_NAME $::_V6_COMPILER_VERSION\n"; |
31
|
31
|
|
|
|
|
117
|
$result .= CompUnit::emit_perl5_program( \@comp_unit ); |
32
|
31
|
|
|
|
|
2533
|
return $result; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub import { |
36
|
|
|
|
|
|
|
filter_add( |
37
|
|
|
|
|
|
|
sub { |
38
|
62
|
|
|
62
|
|
14272
|
my $status; |
39
|
62
|
100
|
|
|
|
249
|
if (($status = filter_read_exact(1e9)) > 0) { |
40
|
31
|
|
|
|
|
763
|
$_ = compile($_); |
41
|
|
|
|
|
|
|
} |
42
|
62
|
|
|
|
|
40940
|
$status; |
43
|
|
|
|
|
|
|
}) |
44
|
31
|
|
|
31
|
|
121
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
v6::perlito - A Perlito Perl6 front-end for v6.pm |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# file: hello_world.pl |
55
|
|
|
|
|
|
|
use v6-perlito; |
56
|
|
|
|
|
|
|
"hello, world".say; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$ perl hello_world.pl |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The C module is a front-end to the Perlito6 Perl 6 compiler. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 REQUIREMENTS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
- The source file header must be valid perl5 I perl6 code. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This is a valid header: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#!/usr/bin/perl |
71
|
|
|
|
|
|
|
use v6-perlito; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
* it executes perl5 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
* perl5 will call the C module. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This is an invalid header: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#!/usr/bin/pugs |
80
|
|
|
|
|
|
|
use v6; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
* it tells perl5 to execute C. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
* it tells perl5 that Perl v6.0.0 required. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHORS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The Pugs Team Eperl6-compiler@perl.orgE. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SEE ALSO |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The Perl 6 homepage at L. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
- the Perl 6 Synopsis: L. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The Pugs homepage at L. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The Parrot homepage at L. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright 2006, 2010, 2012 by Flavio Soibelmann Glock and others. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
105
|
|
|
|
|
|
|
under the same terms as Perl itself. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
See L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |