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 syntax highlighting bug for labelled `if` and `where` constructs
([#1241](https://github.com/fortran-lang/vscode-fortran-support/pull/1241))
- Fixed bug where formatting arguments would not be updated from settings.json
([[#1007](https://github.com/fortran-lang/vscode-fortran-support/issues/1007)])
- Fixed bug where specifying `-ffree-line-length-X` and `-ffixed-line-length-X`
Expand Down
15 changes: 12 additions & 3 deletions syntaxes/fortran_free-form.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,11 +1642,11 @@
{
"comment": "rest of else line",
"begin": "(?!(\\s*(;|!|\\n)))",
"end": "(?=[;!\\n])",
"end": "\\s*(?=[;!\\n])",
"patterns": [
{
"comment": "capture the label if present",
"match": "\\s*([a-z]\\w*)?\\s*\\b(\\w*)\\b",
"match": "(?i)\\s*([a-z]\\w*)?\\s*\\b(\\w*)\\b",
"captures": {
"1": {
"name": "meta.label.else.fortran"
Expand Down Expand Up @@ -1882,11 +1882,20 @@
"name": "keyword.control.elsewhere.fortran"
}
},
"end": "(?=[;!\\n])",
"end": "\\s*(?=[;!\\n])",
"patterns": [
{
"include": "#parentheses"
},
{
"comment": "capture the label if present",
"match": "(?i)(\\s*[a-z]\\w*)?",
"captures": {
"1": {
"name": "meta.label.elsewhere.fortran"
}
}
},
{
"include": "#invalid-word"
}
Expand Down
8 changes: 4 additions & 4 deletions test/fortran/syntax/conditionals.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
end if label2

! labelled if-else-if-else
label3: if (1 > 2) then
else if (2 < 1) then label3
else label3
end if label3
label3: if (1 > 2) then ! comment1
else if (2 < 1) then label3 ! comment2
else label3 ! comment3
end if label3 ! comment4

! labelled if with whitespace after end label
label4: if (1 > 2) then
Expand Down
20 changes: 16 additions & 4 deletions test/fortran/syntax/conditionals.f90.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
>! labelled if-else-if-else
#^ source.fortran.free comment.line.fortran
# ^^^^^^^^^^^^^^^^^^^^^^^^^ source.fortran.free comment.line.fortran
>label3: if (1 > 2) then
>label3: if (1 > 2) then ! comment1
#^^^^^^^ source.fortran.free
# ^ source.fortran.free meta.named-construct.fortran.modern
# ^^ source.fortran.free meta.named-construct.fortran.modern keyword.control.if.fortran
Expand All @@ -133,7 +133,10 @@
# ^ source.fortran.free meta.named-construct.fortran.modern meta.expression.control.logical.fortran punctuation.parentheses.right.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern
# ^^^^ source.fortran.free meta.named-construct.fortran.modern keyword.control.then.fortran
>else if (2 < 1) then label3
# ^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran comment.line.fortran
# ^^^^^^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran comment.line.fortran
>else if (2 < 1) then label3 ! comment2
#^^^^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran keyword.control.elseif.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran punctuation.parentheses.left.fortran
Expand All @@ -146,14 +149,23 @@
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran
# ^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran keyword.control.then.fortran
# ^^^^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran meta.label.elseif.fortran
>else label3
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran comment.line.fortran
# ^^^^^^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran comment.line.fortran
>else label3 ! comment3
#^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran keyword.control.else.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran
# ^^^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran meta.label.else.fortran
>end if label3
# ^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran comment.line.fortran
# ^^^^^^^^^ source.fortran.free meta.named-construct.fortran.modern meta.block.if.fortran comment.line.fortran
>end if label3 ! comment4
#^^^^^^ source.fortran.free meta.named-construct.fortran.modern keyword.control.endif.fortran
# ^ source.fortran.free meta.named-construct.fortran.modern meta.statement.control.if.fortran
# ^^^^^^ source.fortran.free meta.named-construct.fortran.modern meta.statement.control.if.fortran meta.parameter.fortran
# ^^ source.fortran.free meta.named-construct.fortran.modern meta.statement.control.if.fortran
# ^ source.fortran.free comment.line.fortran
# ^^^^^^^^^ source.fortran.free comment.line.fortran
>
>! labelled if with whitespace after end label
#^ source.fortran.free comment.line.fortran
Expand Down
11 changes: 0 additions & 11 deletions test/fortran/syntax/preprocessor.f90

This file was deleted.

57 changes: 0 additions & 57 deletions test/fortran/syntax/preprocessor.f90.snap

This file was deleted.

95 changes: 95 additions & 0 deletions test/fortran/syntax/where.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
program where_test
implicit none
real :: a(10), b(10)

! where statement
where (a > 0) a = a + 1

! where construct
where (a > 0)
a = a + 1
end where

! where with elsewhere
where (a > 0)
a = a + 1
elsewhere
a = 0
end where

! where with elsewhere mask
where (a > 0)
a = a + 1
elsewhere (a < -1)
a = a - 1
elsewhere
a = 0
end where

! labelled where
label1: where (a > 0)
a = a + 1
end where label1

! labelled where with elsewhere
label2: where (a > 0)
a = a + 1
elsewhere label2
a = 0
end where label2

! labelled where with elsewhere mask
label3: where (a > 0)
a = a + 1
elsewhere (a < -1) label3
a = a - 1
elsewhere label3
a = 0
end where label3

! nested where
where (a > 0)
where (b > 0)
a = a + 1
end where
end where

! where with continuation
where (a > &
0)
a = a + 1
end where

! multiple elsewhere
where (a > 0)
a = a + 1
elsewhere (a == 0)
a = 0
else where (a < 0)
a = a - 1
elsewhere
a = 0
end where

! where with comments
where (a > 0) ! comment
a = a + 1
elsewhere ! comment
a = 0
end where

! labelled where with whitespace
label4: where (a > 0)
a = a + 1
end where label4

! nested labels
where (a > 0)
label5: where (b > 0)
a = a + 1
end where label5
elsewhere
a = 0
end where

end program where_test
Loading