Perlito Archives

Perlito - reviewing some older code

Today I've finally updated the Perlito compiler ChangeLog, this covers a little more than a year of commits.

The most significant update was the new Perlito5-to-Java backend, which is work-in-progress. It covers a lot of ground, but there is a lot more.

There were also some interesting new Perlito5-to-Javascript features, such as regex /e modifier, and file operators support in nodejs.

The Perl6 backends have not been updated, but things still work.

While reviewing the README-perlito6 file, I've found some interesting stuff that I haven't touched in a while - here is a piece of generated code that goes through 3 different languages:

Perl5 to Java compiler is 1 month old, and we have a hackathon

We are having a hackathon at work, and Bosko, John and I have hacked together a working Perl script that executes in a Java environment (HBase).

a perl5 to Java compiler - first benchmark

I've written a small performance test. And it is not bad!

First perl:

$ time perl misc/Java/
done 64000000

real    0m3.964s
user    0m3.963s
sys     0m0.004s

And then Perl-in-Java:

$ touch Test.class ; rm Test.class ; perl -Isrc5/lib -I. -It -Cjava misc/Java/ > ; javac ; time java Test
done 64000000

real    0m0.840s
user    0m0.584s
sys     0m0.302s

a perl5 to Java compiler - week 3

The compiler now has a small test suite. The main additions in the last 10 days were implementing global variables, better support for references, data structures, string interpolation, and a few new subroutines in the CORE namespace and operators.

a perl5 to perl6 translator

The "perlito" perl5 to perl6 compiler is online at:

It is also available as an irc bot for snippets and as a command line script.

formats added to perlito5

perlito5 is a Perl compiler written in Perl.

The format statement was required in the grammar for completeness. The 'format' command is not supported at the emitter side - it compiles, but it doesn't run yet.

Some other features are still marked as TODO and are simple to implement:

- dot-decimal strings (without the 'v'),
- "'" meaning "::",
- using 'CORE::' in odd places - 'CORE::if' in place of 'if' and 'CORE::and' in place of 'and'.

With these in place, the grammar will be "100% complete" - the tests will eventually tell if we got there or not.…

indirect-object added to perlito5

perlito5 is a Perl compiler written in Perl.

The tests* for indirect-object and bareword disambiguation can be run online at (you need to copy-paste the tests, it is not automated).

* t5/01-perlito/27-syntax-indirect-object.t

tie() in perlito5

I've just added a small tie() example to the perlito5-in-the-browser page.

This was implemented today, and it only supports a few methods for now.

tie() does not make perlito5 any slower - the tied containers use a separate class, while the non-tied perl5 containers are javascript native array and hash objects.

Perl5 in the browser update

Perlito5 is an ongoing implementation of perl5, with a javascript backend. The compiler is written in perl5. It compiles itself to javascript, so it can run in a browser.

The test suite can be run with node.js. It now passes 288 tests. About a hundred of these tests are from the official perl5 test suite.

$ prove -r -e 'node perlito5.js -Bjs' t
t/base/cond.t ...................................... ok
t/base/if.t .......…

Perlito Perl6 in .NET

There is a new article about the Perlito Perl 6 compiler, published by the São Paulo Perl Mongers. The article is mostly focused on the Javascript backend, and all code snippets can be run in the browser. There are also instructions on how to install the Perl 5 backend from CPAN. The article finishes with an overview of the compiler internals.

In the development front, Perlito now passes all it'…

About Flávio S. Glock

user-pic I blog about Perl.