This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Python transformer for Guile?
i was serious when i said:
> i am very interested, but doubt how useful i would be ;-) but i'd love
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> to learn what might be involved. may be i can continue the trend of
> over-committing...
but, we'll see what happens.
> one thing i have wondered about in the past is whether the parsing
> code used to implement the source language (in this case python) can't
> be re-used for the task -- at least from a technical perspective.
mdj> This is an excellent idea. Please check if you can extract this code
mdj> from the Python sources.
my first pass through part of the sources for python lead me to a
directory called "Parser". the name seemed suggestive, so i had a look
inside:
Makefile.in
acceler.c
assert.h
bitset.c
firstsets.c
grammar.c
grammar1.c
intrcheck.c
listnode.c
metagrammar.c
myreadline.c
node.c
parser.c
parser.h
parsetok.c
pgen.c
pgen.h
pgenmain.c
printgrammar.c
tokenizer.c
tokenizer.h
the final goals of make-ing in this directory appear to be
-an executable called pgen
-two object files named myreadline.o and intrcheck.o
the comments in pgen.c suggest that pgen is a parser generator.
are you familiar w/ typical uses of pgen?
from another angle, looking through pythonrun.c, lead me to
PyParser_ParseFile (parsetok.c), which in turn lead me to
PyTokenizer_FromFile (tokenizer.c). i have a feeling i may at least
be in the ballpark here.
mdj> It might be a good idea to let it generate an intermediate
mdj> representation (Python with Scheme syntax) and then use a
mdj> translator, written in Scheme, to generate the Scheme code. (The
mdj> translator can have the shape of an evaluator (see e.g. SICP) but
mdj> instead of computing values, it computes code.)
i think i just barely follow your idea. i guess an intermediate
representation needs to be thought up. i'll have to order sicp as i
don't have a copy -- any other suggested reading? there's a good deal on
international shipping until the end of this month at a non-amazon
book store that i was thinking of taking advantage of anyway.
mdj> You'll also have to write a library with basic Python procedure
mdj> and data types.
i'm not sure i quite follow you here -- if i understood your idea
correctly, there are basically two large steps:
1) python-code -> python-with-scheme-syntax
performed by code resulting from modifying existing python parser (c)
2) python-with-scheme-syntax -> scheme
performed by translator code (scheme)
is it in step 2 that i will need this library?
> in python's case there might be licensing issues, i guess.
mdj> Python's license is compatible with GPL, so I don't think it'll be a
mdj> problem.
i guess all that is needed is to include the copyright and permission
notices are included. does this count as compatible w/ gpl?
oops, my time/effort quota for this project for today has expired ;-)