Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Removes need for matching begin-end scope names #509

Merged
merged 2 commits into from
Jun 3, 2022
Merged

Conversation

gnikit
Copy link
Member

@gnikit gnikit commented Jun 3, 2022

Removes need for matching begin-end scope names

Previously nested scopes had to be closed in the reverse order than they
were opened e.g.

subroutine scope_1()
    subroutine scope_2()
    subroutine scope_3()
    end subroutine scope_3
    end subroutine scope_2
end subroutine scope_1

However with preprocessor conditionals that would be an issue since

subroutine scope_1()
#ifdef DEF
    subroutine scope_2()
#else
    subroutine scope_3()
#endif

#ifdef DEF
    end subroutine scope_2()
#else
    end subroutine scope_3()
#endif
end subroutine scope_1

scope_2 and scope_3 would be in the same level on the AST, so it is
no longer valid to expect scope_3 to close before scope_2.

The solution to this is removing the strict requirement for scopes to
have matching begin-end names from the regex. The type of scopes
where this requirement is removed are:

  • Functions
  • Modules
  • Programs
  • Module Procedures
  • Subroutines
  • Submodules

Fixes Erroneous syntax highlighting with subroutine names and preprocessor conditionals #278

gnikit added 2 commits June 3, 2022 13:54
Previously nested scopes had to be closed in the reverse order than they
were opened e.g.

```f90
subroutine scope_1()
  subroutine scope_2()
    subroutine scope_3()
    end subroutine scope_3
  end subroutine scope_2
end subroutine scope_1
```

However with preprocessor conditionals that would be an issue since

```f90
subroutine scope_1()
#ifdef DEF
  subroutine scope_2()
#else
  subroutine scope_3()
#endif

#ifdef DEF
  end subroutine scope_2()
#else
  end subroutine scope_3()
#endif
end subroutine scope_1
```

`scope_2` and `scope_3`  would be in the same level on the AST, so it is
no longer valid to expect `scope_3` to close before `scope_2`.

The solution to this is removing the strict requirement for scopes to
have matching begin-end names from the regex. The type of scopes
where this requirement is removed are:

- Functions
- Modules
- Programs
- Module Procedures
- Subroutines
- Submodules

Fixes Erroneous syntax highlighting with subroutine names and preprocessor conditionals #278
@gnikit gnikit added this to the v3.0 milestone Jun 3, 2022
@gnikit gnikit merged commit 3eac8fd into master Jun 3, 2022
@gnikit gnikit deleted the gnikit/issue278 branch June 3, 2022 13:02
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Erroneous syntax highlighting with subroutine names and preprocessor conditionals
1 participant