Parsing C

Francois Pinard pinard at iro.umontreal.ca
Tue Apr 1 08:24:02 EST 2003


[Daniel Timothy Bentley]

> I find myself having to write a C interpreter in Jython.  Really, I'm
> looking for a way to get a C compiler and mildly painlessly build it
> to create the AST that my program will look for.  Oh, and the lexer
> in addition to the parser would be nice, but I bet it's all easy and
> fully of re-goodness in {p|j}ython.

I am not sure if I'm really replying to your desire.

I have this project where I needed to read C source code from Python,
and for it, I recycled a yacc/lex grammar for C, making it available to
Python through a Pyrex interface.  That project not being so important for
me, I merely put it aside unfinished when other emergencies popped up,
with the vague intent of revising it later, one of these days...  Yet,
it might help you getting started, who knows.  Just tell me if you feel
adventurous enough to peruse this previous effort of mine. :-)

A word of warning, though.  I really program for Python and happily rely
on its timely finalisation.  This is my choice.  So, you would need some
revision work if you wanted to use my code in a Jython environment.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list