Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 110 lines (77 sloc) 2.461 kB
07f774f @fglock v6.pm - added changes by pmurias; uses Perlito instead of P::C::Perl6
authored
1 package v6::perlito;
2 use Filter::Util::Call;
3 use strict;
4
5 sub compile {
6 my $source = $_[0];
7 return $source if $source =~ /^\s*$/;
9a32c60 @fglock Perlito6 - rename namespace from Perlito to Perlito6 (fix cpan-v6)
authored
8 $::_V6_COMPILER_NAME = 'Perlito6';
8f67bea @fglock Perlito version 8.0
authored
9 $::_V6_COMPILER_VERSION = '8.0';
9a32c60 @fglock Perlito6 - rename namespace from Perlito to Perlito6 (fix cpan-v6)
authored
10 require Perlito6::Perl5::Emitter;
11 require Perlito6::Grammar;
12 require Perlito6::Grammar::Regex;
13 require Perlito6::Emitter::Token;
14 require Perlito6::Macro;
07f774f @fglock v6.pm - added changes by pmurias; uses Perlito instead of P::C::Perl6
authored
15 my @comp_unit;
16 my $pos = 0;
9a32c60 @fglock Perlito6 - rename namespace from Perlito to Perlito6 (fix cpan-v6)
authored
17 my $p = Perlito6::Grammar->exp_stmts( $source, $pos );
07f774f @fglock v6.pm - added changes by pmurias; uses Perlito instead of P::C::Perl6
authored
18 if (!$p || length($source) > $p->to) {
19 warn "<$source>\n";
20 die "Syntax error at pos ", $p->to, "\n";
21 }
22 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 die "Syntax error" unless @comp_unit;
29 my $result;
30 $result .= "# Do not edit this file - Generated by $::_V6_COMPILER_NAME $::_V6_COMPILER_VERSION\n";
31 $result .= CompUnit::emit_perl5_program( \@comp_unit );
32 return $result;
33 }
34
35 sub import {
36 filter_add(
37 sub {
38 my $status;
39 if (($status = filter_read_exact(1e9)) > 0) {
40 $_ = compile($_);
41 }
42 $status;
43 })
44 }
45
46 1;
47
48 =head1 NAME
49
9a32c60 @fglock Perlito6 - rename namespace from Perlito to Perlito6 (fix cpan-v6)
authored
50 v6::perlito - A Perlito Perl6 front-end for v6.pm
07f774f @fglock v6.pm - added changes by pmurias; uses Perlito instead of P::C::Perl6
authored
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
9a32c60 @fglock Perlito6 - rename namespace from Perlito to Perlito6 (fix cpan-v6)
authored
62 The C<v6::perlito> module is a front-end to the Perlito6 Perl 6 compiler.
07f774f @fglock v6.pm - added changes by pmurias; uses Perlito instead of P::C::Perl6
authored
63
64 =head1 REQUIREMENTS
65
66 - The source file header must be valid perl5 I<and> 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<v6.pm> module.
76
77 This is an invalid header:
78
79 #!/usr/bin/pugs
80 use v6;
81
82 * it tells perl5 to execute C</usr/bin/pugs>.
83
84 * it tells perl5 that Perl v6.0.0 required.
85
86 =head1 AUTHORS
87
88 The Pugs Team E<lt>perl6-compiler@perl.orgE<gt>.
89
90 =head1 SEE ALSO
91
92 The Perl 6 homepage at L<http://dev.perl.org/perl6>.
93
94 - the Perl 6 Synopsis: L<http://dev.perl.org/perl6/doc/synopsis.html>.
95
96 The Pugs homepage at L<http://pugscode.org/>.
97
98 The Parrot homepage at L<http://www.parrotcode.org>.
99
100 =head1 COPYRIGHT
101
9a32c60 @fglock Perlito6 - rename namespace from Perlito to Perlito6 (fix cpan-v6)
authored
102 Copyright 2006, 2010, 2012 by Flavio Soibelmann Glock and others.
07f774f @fglock v6.pm - added changes by pmurias; uses Perlito instead of P::C::Perl6
authored
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<http://www.perl.com/perl/misc/Artistic.html>
108
109 =cut
Something went wrong with that request. Please try again.