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

Optimization, #if, description, python -m executable... #30

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

elrandira
Copy link

@elrandira elrandira commented Dec 20, 2021

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 several #elseif expect as many #endif #31
  • Added support for #error directive

Thanks for considering my changes and if so, updating Pypi package as well.

Regards,
Laurent Pinson

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

Successfully merging this pull request may close these issues.

1 participant