C language processing.

S

stephen henry

Hi all,

I'm looking for a python module that would allow me to take an input
file written in 'c' and modify the contents to allow me to, for
example, add arguments to functions, insert macros at specific
locations etc. I have no formal education in computer science , but,
what I believe I'm looking for is somesort of parser (or lexer?).

So far, I found a bunch of pasers (SimpleParse and SPARK) but these
seem to be quite generic -non-language specifc. I was hoping that the
'c' langauge was sufficiently well known to be supported natively,
meaning that I would't need to enter the grammar rules into the
parser.

Does anybody know of a way of doing this in python? (Or, for that
matter, with Perl, as I would be learning either language to carry
this out.)

Stephen Henry
 
E

Eugene Oden

stephen said:
Hi all,

I'm looking for a python module that would allow me to take an input
file written in 'c' and modify the contents to allow me to, for
example, add arguments to functions, insert macros at specific
locations etc. I have no formal education in computer science , but,
what I believe I'm looking for is somesort of parser (or lexer?).

So far, I found a bunch of pasers (SimpleParse and SPARK) but these
seem to be quite generic -non-language specifc. I was hoping that the
'c' langauge was sufficiently well known to be supported natively,
meaning that I would't need to enter the grammar rules into the
parser.

Does anybody know of a way of doing this in python? (Or, for that
matter, with Perl, as I would be learning either language to carry
this out.)

Stephen Henry


i've had some luck using pybison (http://www.freenet.org.nz/python/pybison/)
using a freely available c grammar which is now included in the pybison
distribution. it'll do the work of building a parse tree but you'll have
to take it from there.

later,

gene
 
M

Miki Tebeka

Hello stephen,
I'm looking for a python module that would allow me to take an input
file written in 'c' and modify the contents to allow me to, for
example, add arguments to functions, insert macros at specific
locations etc. I have no formal education in computer science , but,
what I believe I'm looking for is somesort of parser (or lexer?).

So far, I found a bunch of pasers (SimpleParse and SPARK) but these
seem to be quite generic -non-language specifc. I was hoping that the
'c' langauge was sufficiently well known to be supported natively,
meaning that I would't need to enter the grammar rules into the
parser.

Does anybody know of a way of doing this in python? (Or, for that
matter, with Perl, as I would be learning either language to carry
this out.)
There an ANSI C parser that comes with PLY (http://systems.cs.uchicago.edu/ply/).
There is also a mini_c compiler somewhere that is based on PLY.

HTH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,058
Members
47,668
Latest member
SamiraShac

Latest Threads

Top