You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Given a fixed-form Fortran file that has a comment line which includes a semicolon, all text after the semicolon in the comment line is parsed as regular code. This can confuse the parser if the comment includes text that makes up Fortran keywords.
To Reproduce
Given the following code in a file called invalid_comment.f:
c ; do not treat this as codesubroutinefooendsubroutine foo
=== Parsing Pass ===
do not treat this as code !!! DO - Ln:1
subroutine foo !!! SUBROUTINE - Ln:2
end subroutine foo !!! END SUBROUTINE Scope - Ln:3
which shows that the do in the first comment line is parsed as a do-statement.
This can lead to many follow up errors, e.g. in the code above we will get an "Invalid parent for "SUBROUTINE" declaration" diagnostic being generated in line 2, since for the parser it seems that the subroutine is defined within a "do" loop.
Expected behavior
Comments should never be parsed as code.
Screenshots & Animations
Setup information (please complete the following information):
OS: Windows
Python Version 3.11
fortls Version 3.1.1
VS Code
The text was updated successfully, but these errors were encountered:
I think I have located the problem, however it interferes with the spaghetti code for parsing Doxygen-like and FORD-like docstrings. I might have to rewrite those 2 parsers first, before I fix this.
I
Describe the bug
Given a fixed-form Fortran file that has a comment line which includes a semicolon, all text after the semicolon in the comment line is parsed as regular code. This can confuse the parser if the comment includes text that makes up Fortran keywords.
To Reproduce
Given the following code in a file called
invalid_comment.f
:Then, calling
fortls --debug_filepath invalid_comment.f --debug_parser
giveswhich shows that the
do
in the first comment line is parsed as a do-statement.This can lead to many follow up errors, e.g. in the code above we will get an "Invalid parent for "SUBROUTINE" declaration" diagnostic being generated in line 2, since for the parser it seems that the subroutine is defined within a "do" loop.
Expected behavior
Comments should never be parsed as code.
Screenshots & Animations
Setup information (please complete the following information):
The text was updated successfully, but these errors were encountered: