Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fixed nested syntax highlighting for derived type component accessors
([#1114](https://github.com/fortran-lang/vscode-fortran-support/issues/1114))
- Fixed inconsistent syntax highlighting of comments in Fixed Form
([#923](https://github.com/fortran-lang/vscode-fortran-support/issues/923))
- Fixed various bugs with syntax highlighting and `FORMAT` statements
Expand Down
46 changes: 29 additions & 17 deletions syntaxes/fortran_free-form.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2056,28 +2056,40 @@
}
},
"end": "(?=[;!\\n])",
"applyEndPatternLast": 1,
"patterns": [
{
"comment": "type-bound subroutines",
"begin": "(?ix)\\G\\s*([a-z]\\w*)(%)([a-z]\\w*)\\b\\s*(?=\\()",
"beginCaptures": {
"1": {
"name": "variable.other.fortran"
"begin": "(?ix)(?=\\s*[a-z]\\w*\\s*%)",
"end": "(?=[;!\\n])",
"patterns": [
{
"include": "#comments"
},
"2": {
"name": "keyword.accessor.fortran"
{
"include": "#line-continuation-operator"
},
{
"comment": "Variable and accessor",
"match": "(?ix)\\s*([a-z]\\w*)\\s*(%)",
"captures": {
"1": {
"name": "variable.other.fortran"
},
"2": {
"name": "keyword.accessor.fortran"
}
}
},
{
"comment": "Final function",
"match": "(?ix)\\s*([a-z]\\w*)",
"captures": {
"1": {
"name": "entity.name.function.subroutine.fortran"
}
}
},
"3": {
"name": "entity.name.function.subroutine.fortran"
}
},
"end": "(?<!\\G)",
"endCaptures": {
"1": {
"name": "punctuation.parentheses.right.fortran"
}
},
"patterns": [
{
"include": "#parentheses-dummy-variables"
}
Expand Down
46 changes: 46 additions & 0 deletions test/fortran/syntax/nested-types.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module nested_types
implicit none
type :: A
integer :: x
contains
procedure :: foo
procedure :: bar
end type A

type :: B
type(A) :: a
end type B

type :: C
type(B) :: b
end type C

contains
subroutine foo(this)
class(A), intent(inout) :: this
print *, "Value of x is:", this%x
end subroutine foo

subroutine bar(this, some_value)
class(A), intent(inout) :: this
integer, intent(in) :: some_value
this%x = this%x + some_value
print *, "Value of x after bar is:", this%x
end subroutine bar

end module nested_types

program mwe
use nested_types
implicit none
type(A) :: a_inst
type(C) :: c_inst
c_inst%b%a%x = 42
call a_inst%foo()
call c_inst%b%a%foo()
call &
c_inst%b%a%bar(&
! some comment
8 + c_inst%b%a%x &
)
end program mwe
Loading