Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Friendly project #9

Open
windelbouwman opened this issue Apr 17, 2017 · 3 comments
Open

Friendly project #9

windelbouwman opened this issue Apr 17, 2017 · 3 comments

Comments

@windelbouwman
Copy link

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

@evanplaice
Copy link
Member

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.

@windelbouwman
Copy link
Author

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!

@sfinktah
Copy link

sfinktah commented Mar 23, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants