Categories

Posts in this category

Sun, 04 Oct 2009

Sprixel, a 6 compiler powered by JavaScript


Permanent link

Today I want to announce sprixel, a new Perl 6 compiler in its early stage of development, written in JavaScript and using the standard Perl 6 grammar STD.pm.

Sprixel (an anagram of perlsix) development was initiated by Matthew Wilson, aka diakopter. It traverses the Abstract Syntax Tree as produced by STD.pm, transforms it into an intermediate JavaScript data structure similar to JSON (but with some enhancements to handle cyclic structures), and has a small, continuation based runloop that executes the JavaScript. Currently the only backend is the V8 compiler and virtual machine - but if/when the STD grammar is implemented, you'll be able to run Perl 6 in your browser.

Currently sprixel supports scalar and list variables, numbers (including bigint), strings, string interpolation, basic control flow, closures, named sub declaration (with parameters), and map.

Sprixel development is optimized for fun, and already picked up some contributors (notably, mberends implemented many infix operators, a makefile, and a test harness). The source code can be found in the pugs repository (but is completely independent of the pugs compiler project). The main communication medium so far has been the #perl6 IRC channel on irc.freenode.net.

Motivation

Why yet another Perl 6 implementation? you might ask. A few reasons actually:

  • Sprixel exercises STD.pm, which so far is mostly tested only for parse successes or failures. Relying on the underlying AST structure in a real compiler helps to reveal tricky bugs and unnecessarily difficult interfaces.
  • Most existing Perl 6 compilers either implement only a minimal subset of Perl 6, or rely heavily on a rather large stack of underlying software, thus making substantial contributions non-trivial.
  • Implementing a compiler helps one to understand the language better.

[/perl-6] Permanent link

Comments / Trackbacks:

Trackback URL: /blog-en.trackback

Write a comment

 
Name:
URL: [http://www.example.com/] (optional)
Title: (optional)
Comments:
Save my Name and URL/Email for next time