This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Translators/parsing Python


I think there's reason to be optimistic that it will be possible to use
existing Python interpreter code to parse.  In particular, I'd look to
whatever portion of Python compiles to .pyc.

Though I haven't looked at it specifically, my impression of compiled
Python code is that it speeds up loading by parsing the code into
something fast to read, without performing any other fancy compiling.  I
would imagine that it would be possible to retarget this to create SCM
objects instead of .pyc files, but in the short term it would probably
be a good place to start by taking a .pyc file and parsing it into a
Scheme object -- no doubt a bunch of lists.  I'd even go so far as to
imagine that this will look very much like Scheme code, as the compiled
Python is probably in a tree representation, and Scheme is conveniently
tree like.

Since someone on this list seems to know something about what that .pyc
file looks like (I'm afraid I don't have his name in front of me), that
would probably be the place to start.  I'd expect that once you got the
.pyc reader working you could whip up something that evaluated it in a
couple hours.  Of course, it would only be Scheme with a Python syntax,
but I'm sure that will be quite satisfying anyway :)  Then you get to
write things like "display(cons('a', 10+10))".  At that point you'll
have done nearly as much as CTAX did, as CTAX didn't really match C's
symantics at all.

Then you can get to the harder, but probably more enjoyable part of
trying to match Python's symatics.  No doubt that would give all
involved a greater appreciation of both languages :)

Well, that's my prediction of how it could go... I almost feel like
trying to do it myself now :)

  -- Ian

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]