Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v6.0
Fetching contributors…

Cannot retrieve contributors at this time

181 lines (109 sloc) 4.828 kb
MiniPerl6 "Perlito" compiler
This is Perlito, a compiler that implements a subset of Perl 6.
Backends
Perlito can compile Perl 6 programs into one of the 'backend'
languages:
Go, Common Lisp, Perl 5, Javascript, Python 2, and Ruby 1.9
Web
Main Perlito repository: http://github.com/fglock/Perlito
Main Project web page: http://www.perlito.org
Run Perlito online, in the browser: http://perlcabal.org/~fglock/perlito.html
Source code
The source code for Perlito can be found in the 'lib' directory.
Perlito is written in Perl 6.
USING PERLITO
Using the Go backend
perl mp6.pl -Bgo t/04-op.t
Creating a bootstrapped compiler:
# create a "6.out" binary, using mp6.pl
perl mp6.pl -Bgo util/mp6.pl
# test the binary
./6.out -Cgo t/04-op.t
# recompile the compiler using itself
./6.out -Cgo util/mp6.pl > mp6-go.go
6g mp6-go.go
6l mp6-go.6
./6.out -Cgo util/mp6.pl > mp6-go-new.go
# "mp6-go.go" and "mp6-go-new.go" should be identical
See also: Go homepage at http://golang.org
Using the Java class backend
perl mp6.pl -Bjava-class -e 'class Main { say "hello, World!" }'
java tmp
Creating a bootstrapped compiler:
# create a Java class, using mp6.pl:
perl mp6.pl -v -Bjava-class util/mp6.pl
# test "tmp.class"
java tmp -Cjs t/04-op.t
Requires Rhino's js.jar in CLASSPATH, see also: http://www.mozilla.org/rhino
Using the Javascript backend in the browser
Open the file 'perlito.html' in a browser (Firefox, Chrome, or Safari).
Alternately, browse to:
http://perlcabal.org/~fglock/perlito.html
Using the Javascript backend in the command line
Executing from the command line requires Perl 5 and a javascript compiler (V8 or Rhino):
perl mp6.pl -Bv8 -e 'class Main { say "hello, World!" }'
perl mp6.pl -Brhino -e 'class Main { say "hello, World!" }'
Creating a bootstrapped compiler:
# compile util/mp6.pl to Javascript, using mp6.pl:
perl mp6.pl -Bperl5 util/mp6.pl -Cjs util/mp6.pl > util-js/mp6.js
# testing the bootstrap with Rhino
java org.mozilla.javascript.tools.shell.Main util-js/mp6.js -Cjs util/mp6.pl > mp6-new.js
See also:
V8 homepage at http://code.google.com/apis/v8
Rhino homepage at http://www.mozilla.org/rhino
Using the Lisp backend
perl mp6.pl -Blisp -e 'class Main { say "hello, World!" }'
Creating an executable image:
perl mp6.pl -Clisp-bin util/mp6.pl
mv tmp.out mp6-lisp
./mp6-lisp -Clisp t/04-op.t
See also: SBCL homepage at http://www.sbcl.org
Using the Parrot backend
The parrot backend is not bootstrapped, and it doesn't pass all tests.
The perl 5 backend can be used to compile MiniPerl6 to parrot:
perl mp6.pl -Bparrot -e 'class Main { say "hello, World!" }'
See also: Parrot homepage at http://www.parrot.org
Using the Perl 5 backend
perl mp6.pl -e 'class Main { say "hello, World!" }'
See also: Perl 5 homepage at http://www.perl.org
Creating a bootstrapped compiler:
# compile util/mp6.pl using mp6.pl:
perl mp6.pl -Cperl5 util/mp6.pl > mp6-perl5.pl
# testing the bootstrap
perl -Ilib5 mp6-perl5.pl -Cperl5 util/mp6.pl > mp6-new.pl
Using the Python backend
# initialize "./libpy" and compile "mp6.py"
. util-python/build-python.sh
# using the mp6.py compiler
PYTHONPATH=libpy python mp6.py -Cpython -e 'class Main { say "hello, World!" }' | PYTHONPATH=libpy python
# using the mp6.pl compiler
perl mp6.pl -Bpython -e 'class Main { say "hello, World!" }'
Using the Ruby backend
# initialize "./librb" and compile "mp6.rb"
. util-ruby/build-ruby.sh
# using the mp6.rb compiler
RUBYLIB=librb ruby1.9 mp6.rb -Cruby -e 'class Main { say "hello, World!" }' | RUBYLIB=librb ruby1.9
# using the mp6.pl compiler
perl mp6.pl -Bruby1.9 -e 'class Main { say "hello, World!" }'
Producing AST output
perl mp6.pl -Cast-json -e 'class Main { say "hello, World!" }'
RUNNING TESTS
Testing a backend using the Perl5 based compiler
prove -e "perl mp6.pl -Bjs"
prove -e "perl mp6.pl -Bperl5"
prove -e "perl mp6.pl -Blisp"
prove -e "perl mp6.pl -Bgo"
prove -e "perl mp6.pl -Bpython"
prove -e "perl mp6.pl -Bruby1.9"
AUTHORS
Flavio Soibelmann Glock - fglock@gmail.com
The Pugs Team - perl6-compiler@perl.org
SEE ALSO
The Perl 6 homepage at http://dev.perl.org/perl6
The Pugs homepage at http://pugscode.org
The Perlito homepage at http://perlito.org
COPYRIGHT
Copyright 2006, 2009, 2010 by Flavio Soibelmann Glock, Audrey Tang and others.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
Jump to Line
Something went wrong with that request. Please try again.