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

Highlighting of variables and functions with fortran keywords as name #401

Open
plevold opened this issue Mar 15, 2022 · 3 comments
Open

Comments

@plevold
Copy link

plevold commented Mar 15, 2022

Functions or variables named the same as a fortran keyword is highlighted differently than other functions or arrays in some situations. I appreciate that this might be a quite challenging task, but it would be really nice if the syntax highlighting could identify if the token is actually a reserved keyword or if it's a variable or function with the same name.

Screenshots
image

Code sample

program main
    integer :: module
    integer :: if

    if = format()
    if (if == 1) then
        if (format() == 1) then
            module = 3
        end if
    end if

contains

    integer function format()
        format = 1
    end function
end program

To Reproduce
Paste code above

Fortran Form
Free form, but strictly speaking also fixed form

Build info (please complete the following information):

  • OS: Windows 10
  • Extension Version 2.6.2
  • Visual Studio Code Version 1.65.1
@gnikit
Copy link
Member

gnikit commented Mar 18, 2022

@plevold thanks for the bug report. I will have a look, but I think it might be challenging to tell these two apart without a considerable performance hit. I will check it out

@gnikit gnikit self-assigned this Apr 27, 2022
@gnikit gnikit added this to the v3.0 milestone Apr 27, 2022
@gnikit
Copy link
Member

gnikit commented Apr 29, 2022

I had a look at this and I am afraid the normal syntax highlighting will not suffice to solve this. As far as I can tell there is no way to create a regex that will distinguish between a user defined format and the format statement. For that we will need to use the AST scopes, luckily the language server knows about scopes but I will have to implement a semantics token provider to allow this.

This looks like it's going to be a pretty big piece of work so I won't probably get around to it for quite some time.

@Divyansh200102
Copy link

@plevold is this issue still open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants