hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
294 stars 57 forks source link

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

Open phil-blain opened 3 years ago

phil-blain commented 3 years ago

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 commented 3 years ago

@hansec gentle bump :)

phil-blain commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

@gnikit thanks for the pointer, I was not aware of your fortls ! No need to fix it yourself though ;) https://github.com/gnikit/fortls/pull/67