Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I once wrote a C parser & interpreter in Python. :)

https://github.com/albertz/PyCParser



This is neat. I used Eli Bendersky's pycparser a few years back to create a static analysis suite for C. Does your project support C99?


What parts of C99?

It is quite incomplete. But on the other side a bit loosely on the grammar, so it might work.

I wasn't able yet to interpret any bigger projects. One goal was to interpret CPython (https://github.com/albertz/PyCPython) and I got pretty far but I lost interest in it a bit (I remember that I got stuck when interpreting `goto` because there was no easy equivalent in Python, but I found a solution recently: https://github.com/albertz/playground/blob/master/py_goto.py).

I successfully used this however to create ctypes interfaces for header files on the fly. E.g. https://github.com/albertz/PySDL uses it.

And for doing some analytics, it might also work good enough.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: