Hello!

Here's an update on pirate (the python to parrot compiler) from the
trenches.

Pirate started as an example that fit in one small file and it stayed
in that single file over the years while it grew into a *huge* mess:
one monolithic object performing a variety of transformations on
python's syntax tree, all in one single pass.

Thanks to a Summer of Code grant from Google and the Perl Foundation,
Curtis Hall and I have been working to refactor that mess.  Our long
term goal is to allow pirate to support multiple language front ends
(for example, PyPy and Pugs) but our immediate goal was to make the
refactoring easier to handle.

So far, we've created a generic transformation module that greatly
simplifies the work done by Visitors in the compiler module (it's
called transform.py in the pirate repository - see below)

With the generic Transformer in place, we were able to separate out a
simplification pass, so that list comprehensions (eg: [x for x in
range(10) if x > 5] which evaluates to [6, 7, 8, 9]) are converted
into their corresponding for and if blocks up front, before
PirateVisitor ever sees the tree.

Curt is currently working to use this same principle to separate out
function definitions from generator definitions, another chunk of the
single-pass system that would work much better as a separate pass
through the tree.

The big questions we'v been dealing with, though, is "what will pirate
look like after the refactoring?"  Well, we think we have a good
answer, and we'd like your feedback.

We recognize that there are very few people out there that understand
how pirate works *today* so what we've done is create a much
simplified "toy" version of pirate and shown, though actual code, how
that toy version can be refactored, all in one easy to read narrative
python script. Hopefully, you'll be able to understand what's going on
even if you're not a python developer. So... Without further ado, here
is the plan:

http://pirate.versionhost.com/viewcvs.cgi/pirate/toys/refactor.py?rev=HEAD&content-type=text/vnd.viewcvs-markup

Or, if that's probably mangled:

   http://tinyurl.com/d92f3

It's short, contains test cases, and you can actually run it from
python, or step through it with a debugger.

It does *not* take us all the way to a language-neutral compiler, but
it will make that step much easier.

Anyway, Curt will be using this plan as a guide to actually implement
as much of the refactoring as possible in the time he has left for the
Summer of Code, so if you've got feedback, please share it on the
pirate list:

   http://www.cornerhost.com/mailman/listinfo/pirate

Other links:

The priate home page is here:

  http://pirate.tangentcode.com/

The code for pirate is available for browsing here:

  http://pirate.versionhost.com/viewcvs.cgi/pirate/

Thanks for reading!

Sincerely,
 
Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: [EMAIL PROTECTED]
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
-------------------------------------

Reply via email to