Fetching contributors…
Cannot retrieve contributors at this time
110 lines (77 sloc) 2.4 KB
package v6::perlito;
use Filter::Util::Call;
use strict;
sub compile {
my $source = $_[0];
return $source if $source =~ /^\s*$/;
$::_V6_COMPILER_NAME = 'Perlito6';
$::_V6_COMPILER_VERSION = '8.0';
require Perlito6::Perl5::Emitter;
require Perlito6::Grammar;
require Perlito6::Grammar::Regex;
require Perlito6::Emitter::Token;
require Perlito6::Macro;
my @comp_unit;
my $pos = 0;
my $p = Perlito6::Grammar->exp_stmts( $source, $pos );
if (!$p || length($source) > $p->to) {
warn "<$source>\n";
die "Syntax error at pos ", $p->to, "\n";
push @comp_unit,
name => 'GLOBAL',
body => $$p,
# Don't write when we failed to compile, otherwise it never recompiles!
die "Syntax error" unless @comp_unit;
my $result;
$result .= "# Do not edit this file - Generated by $::_V6_COMPILER_NAME $::_V6_COMPILER_VERSION\n";
$result .= CompUnit::emit_perl5_program( \@comp_unit );
return $result;
sub import {
sub {
my $status;
if (($status = filter_read_exact(1e9)) > 0) {
$_ = compile($_);
=head1 NAME
v6::perlito - A Perlito Perl6 front-end for
# file:
use v6-perlito;
"hello, world".say;
$ perl
The C<v6::perlito> module is a front-end to the Perlito6 Perl 6 compiler.
- The source file header must be valid perl5 I<and> perl6 code.
This is a valid header:
use v6-perlito;
* it executes perl5
* perl5 will call the C<> module.
This is an invalid header:
use v6;
* it tells perl5 to execute C</usr/bin/pugs>.
* it tells perl5 that Perl v6.0.0 required.
=head1 AUTHORS
The Pugs Team E<lt>perl6-compiler@perl.orgE<gt>.
=head1 SEE ALSO
The Perl 6 homepage at L<>.
- the Perl 6 Synopsis: L<>.
The Pugs homepage at L<>.
The Parrot homepage at L<>.
Copyright 2006, 2010, 2012 by Flavio Soibelmann Glock and others.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See L<>