Comments (8)
It'd be even easier, since pycparser's own lexer can (largely) be reused.
from pycparser.
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.
from pycparser.
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.
from pycparser.
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.
from pycparser.
I'm curious about you usage scenario, can you provide more details? Shipping pycparser in a game... that sounds interesting 😄
from pycparser.
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.
from pycparser.
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.
from pycparser.
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.
from pycparser.
Related Issues (20)
- Uncaught exception ValueError in CParser.parse HOT 1
- Create a Security Policy
- Cast an empty compound literal raises ParserError HOT 1
- offsetof parsing fails due to TYPEID as offsetof_member_designator HOT 1
- Hash Pin Github Action on Workflows HOT 1
- is it possible to parse in-complete C code snippet? HOT 1
- c_generator returning a dict mapping the nodes to their position in the resulting code HOT 1
- Support for __attribute__((weak)) HOT 1
- pycparser.plyparser.ParseError: xx/include/vadefs.h:24:28: before: __gnuc_va_list HOT 4
- Enable OpenSSF Scorecard Action and Badge HOT 2
- make pycparser work with linux kernel code HOT 4
- Missing ; when generating code for extern functions
- Can
- Can't parse incomplete types and other syntactically valid but non-compilable code HOT 1
- Curly braces inside braced-group throws ParseError HOT 2
- AssertionError
- Two-dimensional array binding type problem HOT 1
- Is there a release plan for the next version of pycparser?
- parser error with typedef HOT 10
- assertion error on gcc-9 stddef.h
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycparser.