----- Original Message -----
From: "Michal Wallace" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 23, 2003 4:48 PM
Subject: approaching python


>
> Hey all,
>
> I've been thinking about the "compiling python to
> parrot" concept. Right now it looks like the
> approach is to start from scratch, but I'm
> wondering if it might make more sense to
> leverage python itself, at least for now?
>
> Python has a compiler module (written in python
> and standard with the distribution) that can
> take a python parse tree and produce python
> byte code. It basically just walks the tree
> and has a method for each python structure.
>
> The actual parser is written in c, but there's
> a drop-in replacement (or at least a partial one)
> written in python described here:
>
>   http://codespeak.net/moin/pypy/moin.cgi/BytecodeCompiler
>
> Would it make sense to use this to boostrap the
> python parrot compiler? I was thinking about taking
> a shot next week at replacing compiler.pycodegen.CodeGenerator
> with something that produced IMCC.

Correct me if I'm wrong, but there's no bootstrap problem, just a matter of
reimplementing the code generator.

>
> The thing is, I don't have a lot of experience when
> it comes to compilers, but I do know a whole lot about
> python. :) If this approach makes sense, is there
> someone with IMCC experience who'd be willing to do
> some virtual pair programming with me and spike out
> a prototype?
>

If I understood correctly, the codegenerator is isolated to one module,
right? I don't know Python, and I've a little experience with IMC, but it
seems to me only a new code generator module should be written. So, if for
example the Python code generator (generating python byte code) has a method
"gen_assignment(...)" for generating python byte code doing an assignment,
then the new module method (generating IMC) should do the same, but with IMC
instructions. As noted earlier, I've got no experience in Python whatsoever,
but it seems to me it's just a matter of generating the right IMC
instructions for each construct, so when walking the parse tree, calling
"gen_imc_*" methods.

I'm no compiler guru (basic overview + a little experience + much interest
:-), but I find the material very interesting and would gladly help.

Klaas-Jan

Reply via email to