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

Do not require parentheses for the 'defined' preprocessor operator #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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
@phil-blain
Copy link
Contributor Author

@hansec gentle bump :)

@phil-blain
Copy link
Contributor Author

@hansec another bump :) I had to patch the package on a new system since I need this fix and there has been no new releases since 2020..

@gnikit
Copy link

gnikit commented Mar 4, 2022

@phil-blain not sure if I have already fixed this on my implementation of LSP fortls but you can give it a go and let me know. (named has remained fortls for people to be able to transition with ease from fortran-language-server to my version).

If not I can fix it during the weekend.

@phil-blain
Copy link
Contributor Author

@gnikit thanks for the pointer, I was not aware of your fortls ! No need to fix it yourself though ;) fortran-lang/fortls#67

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