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
update fortran keywords #3656
update fortran keywords #3656
Conversation
When will this PR be merged? |
"Somebody" who knows Fortran should check it, but none of the devs use Fortran AFAIK so its waiting for any contributor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things look fine, albeit a bit hard to read.
@gnikit thanks. I just noticed a comment on the OP that some names are in more than one list. That won't break anything, but it will have performance effects. The lexer has to search all lists for every identifier it finds (so all your variable names, function names, etc as well as keywords, it doesn't know they are keywords until it finds them in a list) so duplicating names makes lists bigger which will slow the lexer down searching them, especially for those identifiers not in a list (it does a linear search of names with the same start character in each list). Maybe somebody might want to "optimise" it, it won't hurt to delay for a bit since there is no release on the horizon. |
@elextr Truth be told a lot of these intrinsic variables/methods should be conditional to module imports, exactly in order to alleviate pressure from the lexer/parser. In the fortls language server, we only start parsing for certain tokens only if the modules are |
The code doing highlighting is called lexers because they are just that, pure syntax, no semantics is available, so no knowledge of what is imported. Its just whats in the lists. There are some experiments with various LSPs (C/C++, Go, Python, not Fortran, remember what I said above about no devs using it) which replace the lexers for some things, but not basic syntax. But its not merged yet and it doesn't replace the Lexers. |
Completely understandable @elextr about the lexer. We have a GSoC project this year that aims at adding highlighting support in our language server so fingers crossed Fortran can soon join the experiment. |
Don't we want to merge this anyway? Maybe the performance impact is tolerable and then it is still an improvement for Fortran users. |
@eht16 sure, doesn't break anything if nobody wants to fix it. |
This fixes #3362.
I added the keywords from Fortran 2018 with the help of a python script (if this has to be done again in the future).
The current standard and keywords can be found here:
https://j3-fortran.org/doc/year/18/18-007r1.pdf
https://github.com/cdslaborg/FortranKeywords
Script
Some of the keywords are added to both primary and intrinsic_functions, but this was also the case in the past. I mapped keyword categories (from the standard) to "primary" and "intrinsic_functions" like it has been in the past, and new categories like "module_intrinsic" have been added to the most fitting one.
As far as I can tell, it is correct and all keywords are handled. Also, I didn't remove any of the existing keywords to keep compatibility to older Fortran versions.
Category Mapping