line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package v6::perlito; |
2
|
31
|
|
|
31
|
|
479651
|
use Filter::Util::Call; |
|
31
|
|
|
|
|
93253
|
|
|
31
|
|
|
|
|
2863
|
|
3
|
31
|
|
|
31
|
|
276
|
use strict; |
|
31
|
|
|
|
|
98
|
|
|
31
|
|
|
|
|
27042
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub compile { |
6
|
31
|
|
|
31
|
0
|
88
|
my $source = $_[0]; |
7
|
31
|
50
|
|
|
|
225
|
return $source if $source =~ /^\s*$/; |
8
|
31
|
|
|
|
|
306
|
$::_V6_COMPILER_NAME = 'Perlito'; |
9
|
31
|
|
|
|
|
61
|
$::_V6_COMPILER_VERSION = '7.0'; |
10
|
31
|
|
|
|
|
28229
|
require Perlito::Perl5::Emitter; |
11
|
31
|
|
|
|
|
64271
|
require Perlito::Grammar; |
12
|
31
|
|
|
|
|
778
|
require Perlito::Grammar::Regex; |
13
|
31
|
|
|
|
|
28136
|
require Perlito::Emitter::Token; |
14
|
31
|
|
|
|
|
24629
|
require Perlito::Macro; |
15
|
31
|
|
|
|
|
125
|
my @comp_unit; |
16
|
31
|
|
|
|
|
82
|
my $pos = 0; |
17
|
31
|
|
|
|
|
485
|
my $p = Perlito::Grammar->exp_stmts( $source, $pos ); |
18
|
31
|
50
|
33
|
|
|
123
|
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
|
|
|
|
|
136
|
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
|
|
|
|
177
|
die "Syntax error" unless @comp_unit; |
29
|
31
|
|
|
|
|
64
|
my $result; |
30
|
31
|
|
|
|
|
191
|
$result .= "# Do not edit this file - Generated by $::_V6_COMPILER_NAME $::_V6_COMPILER_VERSION\n"; |
31
|
31
|
|
|
|
|
181
|
$result .= CompUnit::emit_perl5_program( \@comp_unit ); |
32
|
31
|
|
|
|
|
7203
|
return $result; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub import { |
36
|
|
|
|
|
|
|
filter_add( |
37
|
|
|
|
|
|
|
sub { |
38
|
62
|
|
|
62
|
|
25308
|
my $status; |
39
|
62
|
100
|
|
|
|
303
|
if (($status = filter_read_exact(1e9)) > 0) { |
40
|
31
|
|
|
|
|
1592
|
$_ = compile($_); |
41
|
|
|
|
|
|
|
} |
42
|
62
|
|
|
|
|
96853
|
$status; |
43
|
|
|
|
|
|
|
}) |
44
|
31
|
|
|
31
|
|
222
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
v6::perlito - A Perlito 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 Perlito 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 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 |