pypreprocessor
pypreprocessor copied to clipboard
Optimization, #if, description, python -m executable...
Hi,
I decided to contribute to this project as I had needs for C-preprocessors in Python with support for #if. I split my contribution in one "feature" per commit for easier understanding on the changes.
- I started with rewriting the code in a more pythonic way
- Added support for a real #if which allows handling of #if DEBUG_LVL > 3 for example. preprocessor.define was changed from list to Dict to support values with #define such as in #define DEBUG_LVL 5
- Some optimization such as skipping all the checks in lexer() if the current line doesn't start with Preprocessor.escape
- Documented the methods (class documentation is still missing though..)
- Added support for #elseifdef, #elif, #ifnotdef and #ifndef. It doesn't bring any new features, just new names for directives
- Made backward compatibility support for code written with version prior to my changes
- Added main.py so pypreprocessor can be used in command line with python -m pypreprocessor
- Added overload option to have a possibility to provide manually #define directive that would replace existing similar #define
- Added quiet option to prevent warnings on not understood directives and missing #endif
- solved issue #31
- Added support for #error directive
Thanks for considering my changes and if so, updating Pypi package as well.
Regards, Laurent Pinson