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

Feature: built-in ply based preprocessor? #38

Closed
paniq opened this issue Aug 17, 2014 · 8 comments
Closed

Feature: built-in ply based preprocessor? #38

paniq opened this issue Aug 17, 2014 · 8 comments

Comments

@paniq
Copy link

paniq commented Aug 17, 2014

A friend happened to come upon this code in the ply distribution which implements an ANSI-C compatible preprocessor.

Would that be a suitable replacement for using cpp.exe? Pycparser could support it transparently.

@refi64
Copy link

refi64 commented Aug 17, 2014

It'd be even easier, since pycparser's own lexer can (largely) be reused.

@eliben
Copy link
Owner

eliben commented Aug 19, 2014

I'm aware of the preprocessor in the PLY repo - it's been there for a long time! I actually once asked Dave what is its status, and he told me it's just a prototype. I don't believe it changed much since then.

FWIW, I'm not really into developing a preprocessor of my own at this time, since my main aim is Unix-like systems, where this is a non-problem. There are good options out there even for Windows folks - for example Clang for Windows: http://llvm.org/releases/download.html

... perhaps I should add this to the README file.

@paniq
Copy link
Author

paniq commented Aug 19, 2014

The Clang executable is 28 MB in size. That's a little much just for a preprocessor, esp. when we're shipping it with a game that is about the same size ;-). I also looked at mcpp as an alternative but it looks like cpp.py could be a compact solution to our issues. I'll experiment and report back.

@paniq
Copy link
Author

paniq commented Aug 19, 2014

Yeah. It looks like cpp.py has an issue with including files correctly and resolving macros within the included files. I'm closing the issue since the original topic is covered.

@paniq paniq closed this as completed Aug 19, 2014
@eliben
Copy link
Owner

eliben commented Aug 19, 2014

I'm curious about you usage scenario, can you provide more details? Shipping pycparser in a game... that sounds interesting 😄

@paniq
Copy link
Author

paniq commented Aug 20, 2014

I'm using pycparser in combination with cffi to parse and generate struct definitions (with metadata) for soil, a transparent serialization library that I developed for our game Nowhere. It's being used for both editing and savegame data, and it will ship on Windows, OSX and Linux.

The engine provides introspection and editing UI for stored C types once it has their type declarations, which is where pycparser comes in. People modding the game have access to engine internals.

@eliben
Copy link
Owner

eliben commented Aug 21, 2014

Thanks for sharing, that definitely sounds interesting.

FWIW, CFFI uses a regex-based hack to get rid of all preprocessor-y stuff. Often this is sufficient to just parse struct definitions and function declarations.

@paniq
Copy link
Author

paniq commented Aug 21, 2014

Actually, it doesn't; it has the same "clean your crap first" policy as pycparser, so I used to use cpp.exe for that; as it's a problem shipping GPL code with our game, and we can't count on cpp.exe being available everywhere, we now resorted to mcpp, which appears to work well everywhere and is BSD licensed.

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