Skip to content

Do not require parentheses for the defined preprocessor operator #67

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

Merged
merged 2 commits into from
Mar 6, 2022

Conversation

phil-blain
Copy link
Contributor

The regex that checks for preprocessor macros using the 'defined'
operator assumes that the macro that follows the operator is between
parenthesis. However, the syntax for the 'defined' operator does not
require parenthesis, at least in GNU Cpp [1] and Intel fpp [2], arguably
the two most commonly used Fortran preprocessors.

Tweak the regex by allowing the opening and closing parenthesis zero or
once.

[1] https://gcc.gnu.org/onlinedocs/gcc-10.2.0/cpp/Defined.html#Defined
[2] https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/optimization-and-programming-guide/fpp-preprocessing/using-fpp-preprocessor-directives.html

@codecov
Copy link

codecov bot commented Mar 5, 2022

Codecov Report

Merging #67 (fe9d389) into master (085092c) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
+ Coverage   81.69%   81.71%   +0.02%     
==========================================
  Files           9        9              
  Lines        4338     4338              
==========================================
+ Hits         3544     3545       +1     
+ Misses        794      793       -1     
Impacted Files Coverage Δ
fortls/regex_patterns.py 100.00% <100.00%> (ø)
fortls/parse_fortran.py 86.42% <0.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 085092c...fe9d389. Read the comment docs.

@gnikit
Copy link
Member

gnikit commented Mar 5, 2022

Awesome @phil-blain, thanks for the contribution. I will add a unittest and I think this is ready to merge.

@phil-blain
Copy link
Contributor Author

I checked the tests before submitting and saw there was no tests yet for defined, so I thought I'd see what you'd say... Let me know if I can help!

phil-blain and others added 2 commits March 6, 2022 21:39
The regex that checks for preprocessor macros using the 'defined'
operator assumes that the macro that follows the operator is between
parenthesis. However, the syntax for the 'defined' operator does not
require parenthesis, at least in GNU Cpp [1] and Intel fpp [2], arguably
the two most commonly used Fortran preprocessors.

Tweak the regex by allowing the opening and closing parenthesis zero or
once.

[1] https://gcc.gnu.org/onlinedocs/gcc-10.2.0/cpp/Defined.html#Defined
[2] https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/optimization-and-programming-guide/fpp-preprocessing/using-fpp-preprocessor-directives.html
@gnikit gnikit force-pushed the pp-defined-without-parens branch from 5fc1c14 to fe9d389 Compare March 6, 2022 21:45
@gnikit gnikit merged commit 65bfb20 into fortran-lang:master Mar 6, 2022
@gnikit
Copy link
Member

gnikit commented Mar 6, 2022

Thanks @phil-blain for the contribution. Your fix is now available in version 2.2.5 available for download through PyPi

@phil-blain
Copy link
Contributor Author

Super ! Thanks for the added test:)

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.

2 participants