pypreprocessor
pypreprocessor copied to clipboard
Friendly project
Hi Evan!
Cool project! I also recently started with a C preprocessor in python, can be seen here: https://github.com/windelbouwman/ppci-mirror/blob/master/examples/c/hello/demo_pycparser.py
Maybe it is a good idea to add some travis integration to your project? I also can recommend the test suite from mcpp to test the preprocessor, especially the test snippet directory is very handy: https://github.com/h8liu/mcpp/tree/master/test-t
Regards, Windel
Hi Windel,
This project just came out of a dormancy. CI will be coming soon. Thanks for test fixture link, that'll be a huge help. If you'd like to contribute, PRs are always welcome.
I may look into adding macro support at some point. To make that work the parser needs to be updated to include an a actual lexer capable of look ahead matching.
Anyway, if you'd like to help let me know.
For what its worth, when looking into macro's, the way I did it in ppci is located here: https://github.com/windelbouwman/ppci-mirror/blob/master/ppci/lang/c/preprocessor.py
Anyway, good luck! We really need python preprocessors that are full standard compliant!
@windelbouwman @evanplaice Nice work, but I would really like to see the macro component of the self described c-style macro preprocessor. #include would be the next most useful thing, given execfiles absense in Python 3.
Actually, what I really want is to be able to still use:
print "Look Ma, no brackets"
In python 3. Which admittedly couldn't be done with a C #define macro as they require brackets :)
And if I am being honest, C #define macros often end up being kludge-ridden in order to achieve anything truly useful. Given you are using python, being able to write the macros in python too would be easier and more powerful.
#define A a
#define B b
#def STRINGIZE(*args):
return "_".join(args)
def #STRINGIZE(A, B):
print "Hello"
a_b()
result: "Hello"
Sorry -- just thinking aloud really. But if you believe it wouldn't be terribly difficult to modify your project to support a non-functional (non-bracket requiring) print, then I will take a look myself.