Parsing C

Sean Ross sross at connectmail.carleton.ca
Mon Mar 31 21:33:42 EST 2003


Hi.
PLY does not generate an AST(although it does include some examples in the
documentation on how to make your own). SPARK, however, can be used to
generate an AST automatically, but you'll have to code the scanner and
parser. The PLY C example will probably be a useful guide for that.

I'm using SPARK now for a small language and I've been pleased with how easy
it's been to work with. So, I'd like to recommend it. For one thing, you can
make your C parser class as a subclass of GenericASTBuilder and the parser
will build your tree for you, just specify the grammar(which you can get
from PLY).

OK, then, good luck, and have fun
Sean

"Daniel Timothy Bentley" <dbentley at stanford.edu> wrote in message
news:Pine.GSO.4.44.0303311743400.19083-100000 at amy4.Stanford.EDU...
> Hey,
> I find myself having to write a C interpreter in Jython.  Are there any
> useful C compilers that are open-source in python?
>
> Or compiler-compilers that have files for a C compiler available?
>
> Or, compiler-compiler-compilers that have files for a compiler-compiler
> that have files for a C compiler available available?
>
> 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.
>
> Thanks in advance,
> Dan
>






More information about the Python-list mailing list