Skip to content

Commit 5bfe588

Browse files
authored
Merge pull request #887 from fortran-lang/feat/han190/images
sytax-highlight: Image control statement
2 parents 6e2abfc + dc8ba26 commit 5bfe588

File tree

5 files changed

+406
-1
lines changed

5 files changed

+406
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- Added syntax highlighting support for `sync` and `event` image control statements
13+
([#874](https://github.com/fortran-lang/vscode-fortran-support/pull/874))
1214
- Added schema support for fortls configuration files with autocopmletions
1315
([#745](https://github.com/fortran-lang/vscode-fortran-support/issues/745))
1416
- Added Nightly Release Channel for the extension that triggers every day at 00:00 UTC.

schemas/fortls.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,4 @@
184184
"type": "boolean"
185185
}
186186
}
187-
}
187+
}

syntaxes/fortran_free-form.tmLanguage.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,9 @@
20012001
},
20022002
{
20032003
"include": "#where-statement"
2004+
},
2005+
{
2006+
"include": "#image-control-statement"
20042007
}
20052008
]
20062009
},
@@ -2853,6 +2856,131 @@
28532856
}
28542857
]
28552858
},
2859+
"image-control-statement": {
2860+
"patterns": [
2861+
{
2862+
"include": "#sync-all-statement"
2863+
},
2864+
{
2865+
"include": "#sync-statement"
2866+
},
2867+
{
2868+
"include": "#event-statement"
2869+
},
2870+
{
2871+
"include": "#form-team-statement"
2872+
},
2873+
{
2874+
"include": "#fail-image-statement"
2875+
}
2876+
]
2877+
},
2878+
"sync-all-statement": {
2879+
"comment": "Introduced in the Fortran 2018 standard.",
2880+
"name": "meta.statement.sync-all-memory.fortran",
2881+
"begin": "(?i)\\b(sync all|sync memory)(\\s*(?=\\())?",
2882+
"beginCaptures": {
2883+
"1": {
2884+
"name": "keyword.control.sync-all-memory.fortran"
2885+
},
2886+
"2": {
2887+
"name": "punctuation.parentheses.left.fortran"
2888+
}
2889+
},
2890+
"end": "(?<!\\G)",
2891+
"endCaptures": {
2892+
"1": {
2893+
"name": "punctuation.parentheses.right.fortran"
2894+
}
2895+
},
2896+
"patterns": [
2897+
{
2898+
"include": "#parentheses-dummy-variables"
2899+
}
2900+
]
2901+
},
2902+
"sync-statement": {
2903+
"comment": "Introduced in the Fortran 2018 standard.",
2904+
"name": "meta.statement.sync-images-team.fortran",
2905+
"begin": "(?i)\\b(sync images|sync team)\\s*(?=\\()",
2906+
"beginCaptures": {
2907+
"1": {
2908+
"name": "keyword.control.sync-images-team.fortran"
2909+
},
2910+
"2": {
2911+
"name": "punctuation.parentheses.left.fortran"
2912+
}
2913+
},
2914+
"end": "(?<!\\G)",
2915+
"endCaptures": {
2916+
"1": {
2917+
"name": "punctuation.parentheses.right.fortran"
2918+
}
2919+
},
2920+
"patterns": [
2921+
{
2922+
"include": "#parentheses-dummy-variables"
2923+
}
2924+
]
2925+
},
2926+
"event-statement": {
2927+
"comment": "Introduced in the Fortran 2018 standard.",
2928+
"name": "meta.statement.event.fortran",
2929+
"begin": "(?i)\\b(event post|event wait)\\s*(?=\\()",
2930+
"beginCaptures": {
2931+
"1": {
2932+
"name": "keyword.control.event.fortran"
2933+
},
2934+
"2": {
2935+
"name": "punctuation.parentheses.left.fortran"
2936+
}
2937+
},
2938+
"end": "(?<!\\G)",
2939+
"endCaptures": {
2940+
"1": {
2941+
"name": "punctuation.parentheses.right.fortran"
2942+
}
2943+
},
2944+
"patterns": [
2945+
{
2946+
"include": "#parentheses-dummy-variables"
2947+
}
2948+
]
2949+
},
2950+
"form-team-statement": {
2951+
"comment": "Introduced in the Fortran 2018 standard.",
2952+
"name": "meta.statement.form-team.fortran",
2953+
"begin": "(?i)\\b(form team)\\s*(?=\\()",
2954+
"beginCaptures": {
2955+
"1": {
2956+
"name": "keyword.control.form-team.fortran"
2957+
},
2958+
"2": {
2959+
"name": "punctuation.parentheses.left.fortran"
2960+
}
2961+
},
2962+
"end": "(?<!\\G)",
2963+
"endCaptures": {
2964+
"1": {
2965+
"name": "punctuation.parentheses.right.fortran"
2966+
}
2967+
},
2968+
"patterns": [
2969+
{
2970+
"include": "#parentheses-dummy-variables"
2971+
}
2972+
]
2973+
},
2974+
"fail-image-statement": {
2975+
"comment": "Introduced in the Fortran 2018 standard.",
2976+
"name": "meta.statement.fail-image.fortran",
2977+
"match": "\\b(fail image)\\b",
2978+
"captures": {
2979+
"1": {
2980+
"name": "keyword.control.fail-image.fortran"
2981+
}
2982+
}
2983+
},
28562984
"execution-statements": {
28572985
"patterns": [
28582986
{

test/fortran/syntax/images.f90

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
program main
2+
3+
use iso_fortran_env, only: team_type, event_type
4+
implicit none
5+
6+
type(team_type) :: team
7+
type(event_type) :: event[*]
8+
integer :: image_index, team_index
9+
integer :: status
10+
11+
image_index = this_image()
12+
team_index = merge(1, 2, mod(image_index, 2) == 0)
13+
14+
!> Test form team
15+
form team (team_index, team)
16+
17+
! Test fail image
18+
if (team_index == 1) fail image
19+
20+
!> Test sync all, sync memory
21+
sync all
22+
sync all (stat=status)
23+
sync memory
24+
sync memory (stat=status)
25+
26+
!> Test sync team, sync images
27+
sync team (team_index)
28+
sync team (team_index, stat=status)
29+
sync images (image_index)
30+
sync images (image_index, stat=status)
31+
32+
!> Test event post and event wait
33+
event post (event[1])
34+
event post (event[2])
35+
event wait (event, until_count=2)
36+
37+
end program main

0 commit comments

Comments
 (0)