1
0
forked from aniani/vim

runtime(fortan): update fortran syntax rules and doc notes

Update to the Fortran 2023 standard. Reorganize some code to reflect the
dropping of dialect support in the previous commit. Minor improvements.

closes: #13712

Signed-off-by: Ajit-Thakkar <142174202+Ajit-Thakkar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Ajit-Thakkar 2023-12-18 08:53:21 +01:00 committed by Christian Brabandt
parent b501108986
commit 71cbe8e17a
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 156 additions and 174 deletions

View File

@ -1,4 +1,4 @@
*syntax.txt* For Vim version 9.0. Last change: 2023 Dec 09 *syntax.txt* For Vim version 9.0. Last change: 2023 Dec 17
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -1589,13 +1589,14 @@ edit F# or Fortran at all, use this in your startup vimrc: >
FORTRAN *fortran.vim* *ft-fortran-syntax* FORTRAN *fortran.vim* *ft-fortran-syntax*
Default highlighting and dialect ~ Default highlighting and dialect ~
Highlighting appropriate for Fortran 2008 is used by default. This choice Vim highlights according to Fortran 2023 (the most recent standard) by
should be appropriate for most users most of the time because Fortran 2008 is default. This choice should be appropriate for most users most of the time
almost a superset of previous versions (Fortran 2003, 95, 90, and 77). A because Fortran 2023 is almost a superset of previous versions (Fortran 2018,
small number of features new to Fortran 2018 and Fortran 2023 are supported 2008, 2003, 95, 90, and 77). A small number of features new to Fortran 2018
and the complete transition to Fortran 2023 will be completed in the future. and Fortran 2023 may have been omitted at present; the transition to Fortran
A few legacy constructs deleted or declared obsolescent in recent Fortran 2023 will be completed in the near future. A few legacy constructs deleted or
standards are highlighted as todo items. declared obsolescent in recent Fortran standards are highlighted as todo
items.
The syntax script no longer supports Fortran dialects. The variable The syntax script no longer supports Fortran dialects. The variable
fortran_dialect is now silently ignored. Since computers are much faster now, fortran_dialect is now silently ignored. Since computers are much faster now,
@ -1605,7 +1606,7 @@ Fortran source code form ~
Fortran code can be in either fixed or free source form. Note that the Fortran code can be in either fixed or free source form. Note that the
syntax highlighting will not be correct if the form is incorrectly set. syntax highlighting will not be correct if the form is incorrectly set.
When you create a new fortran file, the syntax script assumes fixed source When you create a new Fortran file, the syntax script assumes fixed source
form. If you always use free source form, then > form. If you always use free source form, then >
:let fortran_free_source=1 :let fortran_free_source=1
in your .vimrc prior to the :syntax on command. If you always use fixed in your .vimrc prior to the :syntax on command. If you always use fixed
@ -1619,10 +1620,10 @@ file. For more information on ftplugin files, see |ftplugin|. Note that this
will work only if the "filetype plugin indent on" command precedes the "syntax will work only if the "filetype plugin indent on" command precedes the "syntax
on" command in your .vimrc file. on" command in your .vimrc file.
When you edit an existing fortran file, the syntax script will assume free When you edit an existing Fortran file, the syntax script will assume free
source form if the fortran_free_source variable has been set, and assumes source form if the fortran_free_source variable has been set, and assumes
fixed source form if the fortran_fixed_source variable has been set. If fixed source form if the fortran_fixed_source variable has been set. Suppose
neither of these variables have been set, the syntax script attempts to neither of these variables have been set. In that case, the syntax script attempts to
determine which source form has been used by examining the file extension determine which source form has been used by examining the file extension
using conventions common to the ifort, gfortran, Cray, NAG, and PathScale using conventions common to the ifort, gfortran, Cray, NAG, and PathScale
compilers (.f, .for, .f77 for fixed-source, .f90, .f95, .f03, .f08 for compilers (.f, .for, .f77 for fixed-source, .f90, .f95, .f03, .f08 for
@ -1657,17 +1658,17 @@ command such as >
:let fortran_vendor_intrinsics=1 :let fortran_vendor_intrinsics=1
placed prior to the :syntax on command. placed prior to the :syntax on command.
Tabs in fortran files ~ Tabs in Fortran files ~
Tabs are not recognized by the Fortran standards. Tabs are not a good idea in Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
fixed format fortran source code which requires fixed column boundaries. fixed format Fortran source code which requires fixed column boundaries.
Therefore, tabs are marked as errors. Nevertheless, some programmers like Therefore, tabs are marked as errors. Nevertheless, some programmers like
using tabs. If your fortran files contain tabs, then you should set the using tabs. If your Fortran files contain tabs, then you should set the
variable fortran_have_tabs in your .vimrc with a command such as > variable fortran_have_tabs in your .vimrc with a command such as >
:let fortran_have_tabs=1 :let fortran_have_tabs=1
placed prior to the :syntax on command. Unfortunately, the use of tabs will placed prior to the :syntax on command. Unfortunately, the use of tabs will
mean that the syntax file will not be able to detect incorrect margins. mean that the syntax file will not be able to detect incorrect margins.
Syntax folding of fortran files ~ Syntax folding of Fortran files ~
If you wish to use foldmethod=syntax, then you must first set the variable If you wish to use foldmethod=syntax, then you must first set the variable
fortran_fold with a command such as > fortran_fold with a command such as >
:let fortran_fold=1 :let fortran_fold=1
@ -1700,7 +1701,7 @@ Parenthesis checking does not catch too few closing parentheses. Hollerith
strings are not recognized. Some keywords may be highlighted incorrectly strings are not recognized. Some keywords may be highlighted incorrectly
because Fortran90 has no reserved words. because Fortran90 has no reserved words.
For further information related to fortran, see |ft-fortran-indent| and For further information related to Fortran, see |ft-fortran-indent| and
|ft-fortran-plugin|. |ft-fortran-plugin|.
FREEBASIC *freebasic.vim* *ft-freebasic-syntax* FREEBASIC *freebasic.vim* *ft-freebasic-syntax*

View File

@ -1,6 +1,6 @@
" Vim syntax file " Vim syntax file
" Language: Fortran 2008 (and Fortran 2003, 95, 90, and 77) " Language: Fortran 2023 (and Fortran 2018, 2008, 2003, 95, 90, and 77)
" Version: (v106) 2023 December 4 " Version: (v107) 2023 December 17
" Maintainers: Ajit J. Thakkar <ajit@unb.ca>; <https://ajit.ext.unb.ca/> " Maintainers: Ajit J. Thakkar <ajit@unb.ca>; <https://ajit.ext.unb.ca/>
" Joshua Hollett <j.hollett@uwinnipeg.ca> " Joshua Hollett <j.hollett@uwinnipeg.ca>
" Usage: For instructions, do :help fortran-syntax from Vim " Usage: For instructions, do :help fortran-syntax from Vim
@ -71,24 +71,73 @@ endif
syn match fortranConstructName "\(\<end\s*do\s\+\)\@11<=\a\w*" syn match fortranConstructName "\(\<end\s*do\s\+\)\@11<=\a\w*"
syn match fortranConstructName "\(\<end\s*if\s\+\)\@11<=\a\w*" syn match fortranConstructName "\(\<end\s*if\s\+\)\@11<=\a\w*"
syn match fortranConstructName "\(\<end\s*select\s\+\)\@15<=\a\w*" syn match fortranConstructName "\(\<end\s*select\s\+\)\@15<=\a\w*"
syn match fortranConstructName "\(\<end\s*where\s\+\)\@14<=\a\w*"
syn match fortranConstructName "\(\<end\s*block\s\+\)\@14<=\a\w*"
syn match fortranConstructName "\(\<\%(exit\|cycle\)\s\+\)\@11<=\a\w*" syn match fortranConstructName "\(\<\%(exit\|cycle\)\s\+\)\@11<=\a\w*"
syn match fortranConstructName "\(\<end\s*forall\s\+\)\@15<=\a\w*\>"
syn match fortranUserUnit "\(\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\|block\)\s\+\)\@12<=\a\w\+" syn match fortranUnitName "\(\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\s\+\)\@12<=\a\w\+"
syn match fortranUnitHeader "\<end\s*$"
syn match fortranType "\<character\((\s*kind\s*=\w\+)\)\?\>" syn keyword fortranIntrinsic abs acos aimag aint anint asin atan atan2 char cmplx conjg cos cosh exp ichar index int log log10 max min nint sign sin sinh sqrt tan tanh
syn match fortranType "\<complex\((\s*kind\s*=\w\+)\)\?\>" syn keyword fortranIntrinsicR achar iachar transfer dble dprod dim lge lgt lle llt mod
syn keyword fortranType intrinsic syn keyword fortranIntrinsic command_argument_count get_command get_command_argument get_environment_variable is_iostat_end is_iostat_eor move_alloc new_line same_type_as extends_type_of
syn match fortranType "\<implicit\>\s\+\(none\(\s\+\<external\|type\>\)\?\)\?" syn keyword fortranIntrinsic selected_real_kind selected_int_kind selected_logical_kind selected_char_kind
syn keyword fortranStructure dimension syn keyword fortranIntrinsic acosh asinh atanh bessel_j0 bessel_j1 bessel_jn bessel_y0 bessel_y1 bessel_yn erf erfc erfc_scaled gamma log_gamma hypot norm2
syn keyword fortranStorageClass parameter save syn keyword fortranIntrinsic adjustl adjustr all allocated any associated bit_size btest ceiling count cshift date_and_time digits
syn match fortranCall "call\s\+\a\w*" syn keyword fortranIntrinsic dot_product eoshift epsilon exponent floor fraction huge iand ibclr ibits ibset ieor ior ishft ishftc lbound len_trim matmul maxexponent maxloc maxval merge minexponent minloc
syn match fortranUnitHeader "\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\|block\)" syn keyword fortranIntrinsic minval modulo mvbits nearest pack precision present product radix random_number random_seed range repeat reshape rrspacing scale scan set_exponent shape size spacing
syn keyword fortranKeyword return syn keyword fortranIntrinsic spread sum system_clock tiny transpose trim ubound unpack verify
syn match fortranKeyword "\(error\s\+\)\=stop" syn keyword fortranIntrinsic atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits
syn keyword fortranConditional else then syn keyword fortranIntrinsic bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr num_images parity popcnt poppar shifta shiftl shiftr this_image
syn match fortranConditional "\<if\>" syn keyword fortranIntrinsic null cpu_time failed_images stopped_images image_status co_broadcast co_max co_min co_sum co_reduce
syn match fortranConditionalDel "\<if\s*(.*)\s*\d\+\s*,\s*\d\+\s*,\s*\d\+\s*$" syn keyword fortranIntrinsic atomic_add atomic_and atomic_or atomic_xor atomic_fetch_add atomic_fetch_and atomic_fetch_or atomic_fetch_xor atomic_cas
syn keyword fortranIntrinsic ieee_arithmetic ieee_support_underflow_control ieee_get_underflow_mode ieee_set_underflow_mode
syn keyword fortranIntrinsic ieee_max ieee_max_mag ieee_min ieee_min_mag split tokenize ieee_support_subnormal ieee_get_modes ieee_set_modes
syn keyword fortranIntrinsic ieee_set_status ieee_get_rounding_mode ieee_set_rounding_mode
syn keyword fortranIntrinsic iso_c_binding c_loc c_funloc c_sizeof c_associated c_f_pointer c_f_procpointer
syn keyword fortranIntrinsic out_of_range reduce random_init coshape
syn keyword fortranIntrinsic acosd asind atand atan2d cosd sind tand acospi asinpi atanpi atan2pi cospi sinpi tanpi
syn keyword fortranIntrinsic compiler_options compiler_version get_team team_number
"syn match fortranIntrinsic '\<\(count\|dot_product\|epsilon\|exponent\|fraction\|matmul\|maxval\|minval\|modulo\|nearest\|pack\|precision\|product\|radix\|random_number\|random_seed\|range\|repeat\|reshape\|rrspacing\|scale\|scan\|set_exponent\|shape\|size\|sum\|tiny\|transpose\)\>\ze\s*('
syn match fortranIntrinsic "\<real\s*("me=s+4
syn match fortranIntrinsic "\<logical\s*("me=s+7
syn match fortranIntrinsic "\<not\s*("me=s+3
syn match fortranIntrinsic "\<len\s*("me=s+3
syn match fortranIntrinsic "\<kind\s*("me=s+4
" obsolescent type-specific intrinsics
syn keyword fortranIntrinsicOb alog alog10 amax0 amax1 amin0 amin1 amod cabs ccos cexp clog csin csqrt dabs dacos dasin datan datan2 dcos dcosh ddim dexp dint dlog dlog10 dmax1 dmin1 dmod dnint dsign dsin dsinh dsqrt dtan dtanh float iabs idim idint idnint ifix isign max0 max1 min0 min1 sngl
" Extra intrinsics provided by some vendors
syn keyword fortranExtraIntrinsic algama cdabs cdcos cdexp cdlog cdsin cdsqrt cqabs cqcos cqexp cqlog cqsin cqsqrt dcmplx dconjg derf derfc dfloat dgamma dimag dlgama iqint qabs qacos qasin qatan qatan2 qcmplx qconjg qcos qcosh qdim qerf qerfc qexp qgamma qimag qlgama qlog qlog10 qmax1 qmin1 qmod qnint qsign qsin qsinh qsqrt qtan qtanh
syn keyword fortranType generic final enumerator import
syn keyword fortranType c_ptr c_funptr elemental pure impure recursive non_recursive
syn match fortranTypeOb "^\s*\(character\s*\)\@15<=\*"
syn match fortranType "^\s*\(implicit \)\?\s*\(real\|integer\|logical\|complex\|character\|type\)\>"
syn match fortranType "^\s*implicit\s\+none"
syn match fortranType "\(class\|type\)\(of\)\?"
syn match fortranType "\(end\s*\)\?\<interface\>"
syn match fortranType "\<enum\s*,\s*bind\s*(\s*c\s*)"
syn match fortranType "\<end\s*\(enum\|type\)\>"
syn match fortranType "\(end\s*\)\?enumeration\s\+type"
syn match fortranType "\(end\s*\)\?\(\<module\s\+\)\?procedure\>"
syn match fortranTypeR display "double\s*precision"
syn match fortranTypeR display "double\s\+complex"
syn keyword fortranAttribute value bind deferred contiguous intrinsic non_intrinsic
syn keyword fortranAttribute asynchronous nopass non_overridable pass volatile extends
syn keyword fortranAttribute abstract external private public protected intent optional
syn keyword fortranAttribute pointer target allocatable dimension codimension sequence parameter save
syn keyword fortranUnitHeader result operator assignment
syn match fortranUnitHeader "\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\>"
syn match fortranBlock "\(end\s*\)\?\(block\|critical\|associate\)\>"
syn match fortranCalled "\(call\s\+\)\@7<=\a\w*"
syn match fortranRepeat "\<do\>" syn match fortranRepeat "\<do\>"
syn keyword fortranRepeat concurrent
syn keyword fortranRepeatR while
syn match fortranRepeat "\<end\s*do"
syn keyword fortranRepeatOb forall
syn match fortranRepeatOb "\<end\s*forall\>"
syn keyword fortranTodo contained bug note debug todo fixme syn keyword fortranTodo contained bug note debug todo fixme
@ -99,11 +148,13 @@ syn match fortranParenError ")"
syn match fortranOperator "\.\s*n\=eqv\s*\." syn match fortranOperator "\.\s*n\=eqv\s*\."
syn match fortranOperator "\.\s*\(and\|or\|not\)\s*\." syn match fortranOperator "\.\s*\(and\|or\|not\)\s*\."
syn match fortranOperator "\(+\|-\|/\|\*\)" syn match fortranOperator "\(+\|-\|/\|\*\)"
syn match fortranTypeOb "\<character\s*\*" syn match fortranOperator "\(\(>\|<\)=\=\|==\|/=\|=\)"
syn match fortranOperator "\(%\|?\|=>\)"
syn match fortranOperator "\([\|]\)"
syn match fortranOperatorR "\.\s*[gl][et]\s*\."
syn match fortranOperatorR "\.\s*\(eq\|ne\)\s*\."
syn match fortranBoolean "\.\s*\(true\|false\)\s*\." syn keyword fortranReadWrite print flush
syn keyword fortranReadWrite print
syn match fortranReadWrite '\<\(backspace\|close\|endfile\|inquire\|open\|read\|rewind\|write\)\ze\s*(' syn match fortranReadWrite '\<\(backspace\|close\|endfile\|inquire\|open\|read\|rewind\|write\)\ze\s*('
"If tabs are allowed then the left margin checks do not work "If tabs are allowed then the left margin checks do not work
@ -113,24 +164,6 @@ else
syn match fortranTab "\t" syn match fortranTab "\t"
endif endif
syn match fortranIO '\%(\((\|,\|, *&\n\)\s*\)\@<=\(access\|blank\|direct\|exist\|file\|fmt\|form\|formatted\|iostat\|name\|named\|nextrec\|number\|opened\|rec\|recl\|sequential\|status\|unformatted\|unit\)\ze\s*='
" Intrinsics provided by some vendors
syn keyword fortranExtraIntrinsic algama cdabs cdcos cdexp cdlog cdsin cdsqrt cqabs cqcos cqexp cqlog cqsin cqsqrt dcmplx dconjg derf derfc dfloat dgamma dimag dlgama iqint qabs qacos qasin qatan qatan2 qcmplx qconjg qcos qcosh qdim qerf qerfc qexp qgamma qimag qlgama qlog qlog10 qmax1 qmin1 qmod qnint qsign qsin qsinh qsqrt qtan qtanh
syn keyword fortranIntrinsic abs acos aimag aint anint asin atan atan2 char cmplx conjg cos cosh exp ichar index int log log10 max min nint sign sin sinh sqrt tan tanh
syn match fortranIntrinsic "\<len\s*[(,]"me=s+3
syn match fortranIntrinsic "\<real\s*("me=s+4
syn match fortranIntrinsic "\<logical\s*("me=s+7
" F2018 and F2023
syn keyword fortranIntrinsic out_of_range reduce random_init lcobound ucobound this_image coshape selected_logical_kind
syn keyword fortranIntrinsic ieee_max ieee_max_mag ieee_min ieee_min_mag split tokenize
syn keyword fortranIntrinsic acosd asind atand atan2d cosd sind tand acospi asinpi atanpi atan2pi cospi sinpi tanpi
syn match fortranType "\<type\>\(\s\+is\>\)\?"
syn match fortranType "^\s*\(type\s\+\(is\)\? \)\?\s*\(real\|integer\|logical\|complex\|character\)\>"
syn match fortranType "^\s*\(implicit \)\?\s*\(real\|integer\|logical\|complex\|character\)\>"
"Numbers of various sorts "Numbers of various sorts
" Integers " Integers
syn match fortranNumber display "\<\d\+\(_\a\w*\)\=\>" syn match fortranNumber display "\<\d\+\(_\a\w*\)\=\>"
@ -157,129 +190,75 @@ syn match fortranFormatSpec display "\d*\(d\|q\|g\)\d\+\.\d\+\(e\d+\)\="
syn match fortranFormatSpec display "\d\+x\>" syn match fortranFormatSpec display "\d\+x\>"
" The next match cannot be used because it would pick up identifiers as well " The next match cannot be used because it would pick up identifiers as well
" syn match fortranFormatSpec display "\<\(a\|i\)\d\+" " syn match fortranFormatSpec display "\<\(a\|i\)\d\+"
" Numbers as labels " Numbers as labels
syn match fortranLabelNumber display "^\d\{1,5}\s"me=e-1 syn match fortranLabelNumber display "^\d\{1,5}\s"me=e-1
syn match fortranLabelNumber display "^ \d\{1,4}\s"ms=s+1,me=e-1 syn match fortranLabelNumber display "^ \d\{1,4}\s"ms=s+1,me=e-1
syn match fortranLabelNumber display "^ \d\{1,3}\s"ms=s+2,me=e-1 syn match fortranLabelNumber display "^ \d\{1,3}\s"ms=s+2,me=e-1
syn match fortranLabelNumber display "^ \d\d\=\s"ms=s+3,me=e-1 syn match fortranLabelNumber display "^ \d\d\=\s"ms=s+3,me=e-1
syn match fortranLabelNumber display "^ \d\s"ms=s+4,me=e-1 syn match fortranLabelNumber display "^ \d\s"ms=s+4,me=e-1
" Numbers as targets " Numbers as targets
syn match fortranTarget display "\(\<if\s*(.\+)\s*\)\@<=\(\d\+\s*,\s*\)\{2}\d\+\>" syn match fortranTarget display "\(\<if\s*(.\+)\s*\)\@<=\(\d\+\s*,\s*\)\{2}\d\+\>"
syn match fortranTarget display "\(\<do\s\+\)\@11<=\d\+\>" syn match fortranTarget display "\(\<do\s\+\)\@11<=\d\+\>"
syn match fortranTarget display "\(\<go\s*to\s*(\=\)\@11<=\(\d\+\s*,\s*\)*\d\+\>" syn match fortranTarget display "\(\<go\s*to\s*(\=\)\@11<=\(\d\+\s*,\s*\)*\d\+\>"
syn keyword fortranTypeR external syn match fortranBoolean "\.\s*\(true\|false\)\s*\."
syn keyword fortranIOR format
syn match fortranKeyword "call"
syn keyword fortranKeyword use only contains
syn match fortranKeyword "fail\s\+image\>"
syn match fortranKeyword "\(error\s\+\)\=stop"
syn match fortranKeyword "\<continue\>" syn match fortranKeyword "\<continue\>"
syn match fortranKeyword "^\s*\d\+\s\+continue\>" syn match fortranKeyword "^\s*\d\+\s\+continue\>"
syn match fortranKeyword "\<go\s*to\>" syn match fortranKeyword "\<go\s*to\>"
syn match fortranKeywordDel "\<go\s*to\ze\s\+.*,\s*(.*$" syn match fortranKeywordDel "\<go\s*to\ze\s\+.*,\s*(.*$"
syn match fortranKeywordOb "\<go\s*to\ze\s*(\d\+.*$" syn match fortranKeywordOb "\<go\s*to\ze\s*(\d\+.*$"
syn region fortranString start=+'+ end=+'+ contains=fortranContinueMark,fortranLeftMargin,fortranSerialNumber
syn keyword fortranKeywordDel assign pause syn keyword fortranKeywordDel assign pause
syn keyword fortranKeyword allocate deallocate nullify return cycle exit
syn region fortranString start=+'+ end=+'+ contains=fortranLeftMargin,fortranContinueMark,fortranSerialNumber
syn region fortranString start=+"+ end=+"+ contains=fortranLeftMargin,fortranContinueMark,fortranSerialNumber
syn match fortranIO '\%(\((\|,\|, *&\n\)\s*\)\@<=\(access\|blank\|direct\|exist\|file\|fmt\|form\|formatted\|iostat\|name\|named\|nextrec\|number\|opened\|rec\|recl\|sequential\|status\|unformatted\|unit\)\ze\s*='
syn keyword fortranIOR format namelist
syn keyword fortranIO pad position action delim readwrite
syn keyword fortranIO eor advance nml
syn keyword fortranIO newunit decimal round iomsg
syn match fortranIO contains=fortranOperator "\<e\(nd\|rr\)\s*=\s*\d\+"
syn keyword fortranConditional else then where elsewhere
syn match fortranConditional "\<if\>"
syn match fortranConditional "\<else\s*if"
syn match fortranConditional "\(end\s*\)\?\(if\|where\|select\)"
syn match fortranConditional "\<select\s\+\(case\|rank\|type\)"
syn match fortranConditional "\(class\|type\)\s\+is\>"
syn match fortranConditional "\(case\|rank\)\(\s\+default\)\?"
syn match fortranConditionalDel "\<if\s*(.*)\s*\d\+\s*,\s*\d\+\s*,\s*\d\+\s*$"
syn keyword fortranInclude include
syn match fortranImageControl "sync\s\+\(all\|images\|memory\|team\)\>"
syn match fortranImageControl "\(change\|form\|end\)\s\+team\>"
syn match fortranImageControl "event\s\+\(post\|wait\)"
syn match fortranImageControl "\(un\)\?lock\ze\s*("
syn match fortranImageControl "notify\s\+wait\ze\s*("
syn keyword fortranUnitHeaderOb entry
syn match fortranUnitHeaderOb display "block\s*data"
syn keyword fortranStructure private public intent optional
syn keyword fortranStructure pointer target allocatable
syn keyword fortranStorageClass in out syn keyword fortranStorageClass in out
syn match fortranStorageClass "\<in\s*out\>" syn match fortranStorageClass "\<in\s*out\>"
syn match fortranStorageClass "\<kind\s*="me=s+4 syn match fortranStorageClass "\<kind\s*="me=s+4
syn match fortranStorageClass "\<len\s*="me=s+3 syn match fortranStorageClass "\<len\s*="me=s+3
syn keyword fortranUnitHeader use only contains
syn keyword fortranUnitHeader result operator assignment
syn match fortranUnitHeader "\<interface\>"
syn keyword fortranKeyword allocate deallocate nullify cycle exit
syn match fortranConditional "\<select\>"
syn match fortranConditional "\<case\s\+default\>"
syn keyword fortranConditional where elsewhere
syn match fortranOperator "\(\(>\|<\)=\=\|==\|/=\|=\)"
syn match fortranOperator "\(%\|?\|=>\)"
syn region fortranString start=+"+ end=+"+ contains=fortranLeftMargin,fortranContinueMark,fortranSerialNumber
syn keyword fortranIO pad position action delim readwrite
syn keyword fortranIO eor advance nml
syn match fortranIntrinsic '\<\(adjustl\|adjustr\|all\|allocated\|any\|associated\|bit_size\|btest\|ceiling\|count\|cshift\|date_and_time\|digits\|dot_product\|eoshift\|epsilon\|exponent\|floor\|fraction\|huge\|iand\|ibclr\|ibits\|ibset\|ieor\|ior\|ishft\|ishftc\|lbound\|len_trim\|matmul\|maxexponent\|maxloc\|maxval\|merge\|minexponent\|minloc\|minval\|modulo\|mvbits\|nearest\|pack\|precision\|present\|product\|radix\|random_number\|random_seed\|range\|repeat\|reshape\|rrspacing\|scale\|scan\|selected_int_kind\|selected_real_kind\|set_exponent\|shape\|size\|spacing\|spread\|sum\|system_clock\|tiny\|transpose\|trim\|ubound\|unpack\|verify\)\>\ze\s*('
syn match fortranIntrinsic "\<not\>\(\s*\.\)\@!"me=s+3
syn match fortranIntrinsic "\<kind\>\s*[(,]"me=s+4
syn match fortranUnitHeader "\<end\s*interface"
syn match fortranRepeat "\<end\s*do"
syn match fortranConditional "\<end\s*where"
syn match fortranConditional "\<select\s*case"
syn match fortranConditional "\<end\s*select"
syn match fortranType "\<end\s*type"
syn match fortranType "\(end\s\+\)\?\(\<module\s\+\)\?procedure\>"
syn keyword fortranIOR namelist
syn keyword fortranConditionalR while
syn keyword fortranIntrinsicR achar iachar transfer dble dprod dim lge lgt lle llt mod
syn keyword fortranIntrinsicOb alog alog10 amax0 amax1 amin0 amin1 amod cabs ccos cexp clog csin csqrt dabs dacos dasin datan datan2 dcos dcosh ddim dexp dint dlog dlog10 dmax1 dmin1 dmod dnint dsign dsin dsinh dsqrt dtan dtanh float iabs idim idint idnint ifix isign max0 max1 min0 min1 sngl
syn keyword fortranInclude include
syn keyword fortranStorageClassR sequence
syn match fortranConditional "\<end\s*if"
syn match fortranIO contains=fortranOperator "\<e\(nd\|rr\)\s*=\s*\d\+"
syn match fortranConditional "\<else\s*if"
syn keyword fortranUnitHeaderOb entry
syn match fortranTypeR display "double\s\+precision"
syn match fortranTypeR display "double\s\+complex"
syn match fortranUnitHeaderOb display "block\s\+data"
syn match fortranStorageClass "^\s*data\>\(\s\+\a\w*\s*/\)\@=" syn match fortranStorageClass "^\s*data\>\(\s\+\a\w*\s*/\)\@="
syn match fortranStorageClassOb "^\s*common\>"
syn match fortranStorageClassOb "^\s*common\>\(\s*/\)\@=" syn match fortranStorageClassOb "^\s*common\>\(\s*/\)\@="
syn keyword fortranStorageClassOb equivalence syn keyword fortranStorageClassOb equivalence
syn match fortranOperatorR "\.\s*[gl][et]\s*\."
syn match fortranOperatorR "\.\s*\(eq\|ne\)\s*\."
syn keyword fortranRepeatOb forall
syn match fortranRepeatOb "\<end\s*forall"
syn keyword fortranIntrinsic null cpu_time
syn match fortranType "\<elemental\>"
syn match fortranType "\<pure\>"
syn match fortranType "\<impure\>"
syn match fortranType "\<recursive\>"
syn match fortranConstructNameOb "\(\<end\s*forall\s\+\)\@15<=\a\w*\>"
" F2003
syn keyword fortranIntrinsic command_argument_count get_command get_command_argument get_environment_variable is_iostat_end is_iostat_eor move_alloc new_line selected_char_kind same_type_as extends_type_of
" ISO_C_binding
syn keyword fortranConstant c_null_char c_alert c_backspace c_form_feed c_new_line c_carriage_return c_horizontal_tab c_vertical_tab syn keyword fortranConstant c_null_char c_alert c_backspace c_form_feed c_new_line c_carriage_return c_horizontal_tab c_vertical_tab
syn keyword fortranConstant c_int c_short c_long c_long_long c_signed_char c_size_t c_int8_t c_int16_t c_int32_t c_int64_t c_int_least8_t c_int_least16_t c_int_least32_t c_int_least64_t c_int_fast8_t c_int_fast16_t c_int_fast32_t c_int_fast64_t c_intmax_t C_intptr_t c_float c_double c_long_double c_float_complex c_double_complex c_long_double_complex c_bool c_char c_null_ptr c_null_funptr syn keyword fortranConstant c_int c_short c_long c_long_long c_signed_char c_size_t c_int8_t c_int16_t c_int32_t c_int64_t c_int_least8_t c_int_least16_t c_int_least32_t c_int_least64_t c_int_fast8_t c_int_fast16_t c_int_fast32_t c_int_fast64_t c_intmax_t C_intptr_t c_float c_double c_long_double c_float_complex c_double_complex c_long_double_complex c_bool c_char c_null_ptr c_null_funptr
syn keyword fortranIntrinsic iso_c_binding c_loc c_funloc c_associated c_f_pointer c_f_procpointer syn keyword fortranConstant iso_fortran_env character_storage_size error_unit file_storage_size input_unit iostat_end iostat_eor numeric_storage_size output_unit stat_failed_image stat_unlocked_failed_image
syn keyword fortranType c_ptr c_funptr syn keyword fortranConstant int8 int16 int32 int64 real16 real32 real64 real128 character_kinds integer_kinds logical_kinds real_kinds iostat_inquire_internal_unit
" ISO_Fortran_env syn keyword fortranConstant ieee_negative_subnormal ieee_positive_subnormal
syn keyword fortranConstant iso_fortran_env character_storage_size error_unit file_storage_size input_unit iostat_end iostat_eor numeric_storage_size output_unit
" IEEE_arithmetic
syn keyword fortranIntrinsic ieee_arithmetic ieee_support_underflow_control ieee_get_underflow_mode ieee_set_underflow_mode
syn keyword fortranReadWrite flush wait
syn keyword fortranIO decimal round iomsg
syn keyword fortranType asynchronous nopass non_overridable pass protected volatile extends import
syn keyword fortranType non_intrinsic value bind deferred generic final enumerator
syn match fortranType "\<abstract\>"
syn match fortranType "\<class\>"
syn match fortranType "\<associate\>"
syn match fortranType "\<end\s*associate"
syn match fortranType "\<enum\s*,\s*bind\s*(\s*c\s*)"
syn match fortranType "\<end\s*enum"
syn match fortranConditional "\<select\s*type"
syn match fortranConditional "\<class\s*is\>"
syn match fortranConditional "\<class\s*default\>"
syn match fortranUnitHeader "\<abstract\s*interface\>"
syn match fortranOperator "\([\|]\)"
" F2008
syn keyword fortranIntrinsic acosh asinh atanh bessel_j0 bessel_j1 bessel_jn bessel_y0 bessel_y1 bessel_yn erf erfc erfc_scaled gamma log_gamma hypot norm2
syn keyword fortranIntrinsic atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits
syn keyword fortranIntrinsic bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr num_images parity popcnt poppar shifta shiftl shiftr this_image
syn keyword fortranIO newunit
syn keyword fortranType contiguous
syn keyword fortranRepeat concurrent
" CUDA fortran " CUDA fortran
if exists("fortran_CUDA") if exists("fortran_CUDA")
@ -322,14 +301,13 @@ syn cluster fortranCommentGroup contains=fortranTodo
if (b:fortran_fixed_source == 1) if (b:fortran_fixed_source == 1)
if !exists("fortran_have_tabs") if !exists("fortran_have_tabs")
" Fixed format requires a textwidth of 72 for code,
" but some vendor extensions allow longer lines
if exists("fortran_extended_line_length") if exists("fortran_extended_line_length")
" Vendor extensions allow lines with a text width of 132
syn match fortranSerialNumber excludenl "^.\{133,}$"lc=132 syn match fortranSerialNumber excludenl "^.\{133,}$"lc=132
elseif exists("fortran_cardimage_line_length")
syn match fortranSerialNumber excludenl "^.\{81,}$"lc=80
else else
syn match fortranSerialNumber excludenl "^.\{73,}$"lc=72 " Standard requires fixed format to have a text width of 72,
" but all current compilers use 80 instead
syn match fortranSerialNumber excludenl "^.\{81,}$"lc=80
endif endif
"Flag left margin errors "Flag left margin errors
syn match fortranLabelError "^.\{-,4}[^0-9 ]" contains=fortranTab syn match fortranLabelError "^.\{-,4}[^0-9 ]" contains=fortranTab
@ -344,6 +322,7 @@ endif
syn match fortranComment excludenl "!.*$" contains=@fortranCommentGroup,@spell syn match fortranComment excludenl "!.*$" contains=@fortranCommentGroup,@spell
syn match fortranOpenMP excludenl "^\s*!\$\(OMP\)\=&\=\s.*$" syn match fortranOpenMP excludenl "^\s*!\$\(OMP\)\=&\=\s.*$"
syn match fortranEndStatement display ";"
"cpp is often used with Fortran "cpp is often used with Fortran
syn match cPreProc "^\s*#\s*\(define\|ifdef\)\>.*" syn match cPreProc "^\s*#\s*\(define\|ifdef\)\>.*"
@ -390,15 +369,15 @@ if exists("fortran_fold")
if exists("fortran_fold_conditionals") if exists("fortran_fold_conditionals")
if (b:fortran_fixed_source == 1) if (b:fortran_fixed_source == 1)
syn region fortran77Loop transparent fold keepend start="\<do\s\+\z(\d\+\)" end="^\s*\z1\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortran77Loop transparent fold keepend start="\<do\s\+\z(\d\+\)" end="^\s*\z1\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
syn region fortran90Loop transparent fold keepend extend start="\(\<end\s\+\)\@<!\<do\(\s\+\a\|\s*$\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortran90Loop transparent fold keepend extend start="\(\<end\s\+\)\@<!\<do\(\s\+\a\|\s*$\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
syn region fortranIfBlock transparent fold keepend extend start="\(\<e\(nd\|lse\)\s\+\)\@<!\<if\s*(.\+)\s*then\>" skip="^\([!c*]\|\s*#\).*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortranIfBlock transparent fold keepend extend start="\(\<e\(nd\|lse\)\s\+\)\@<!\<if\s*(.\+)\s*then\>" skip="^\([!c*]\|\s*#\).*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
syn region fortranCase transparent fold keepend extend start="\<select\s*\(case\|type\)\>" skip="^\([!c*]\|\s*#\).*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortranCase transparent fold keepend extend start="\<select\s*\(case\|type\)\>" skip="^\([!c*]\|\s*#\).*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
else else
syn region fortran77Loop transparent fold keepend start="\<do\s\+\z(\d\+\)" end="^\s*\z1\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortran77Loop transparent fold keepend start="\<do\s\+\z(\d\+\)" end="^\s*\z1\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
syn region fortran90Loop transparent fold keepend extend start="\(\<end\s\+\)\@<!\<do\(\s\+\a\|\s*$\)" skip="^\s*[!#].*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortran90Loop transparent fold keepend extend start="\(\<end\s\+\)\@<!\<do\(\s\+\a\|\s*$\)" skip="^\s*[!#].*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
syn region fortranIfBlock transparent fold keepend extend start="\(\<e\(nd\|lse\)\s\+\)\@<!\<if\s*(\(.\|&\s*\n\)\+)\(\s\|&\s*\n\)*then\>" skip="^\s*[!#].*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortranIfBlock transparent fold keepend extend start="\(\<e\(nd\|lse\)\s\+\)\@<!\<if\s*(\(.\|&\s*\n\)\+)\(\s\|&\s*\n\)*then\>" skip="^\s*[!#].*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
syn region fortranCase transparent fold keepend extend start="\<select\s*\(case\|type\)\>" skip="^\s*[!#].*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranStructure,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData syn region fortranCase transparent fold keepend extend start="\<select\s*\(case\|type\)\>" skip="^\s*[!#].*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
endif endif
endif endif
@ -424,6 +403,7 @@ hi def link fortranConditional Conditional
hi def link fortranRepeat Repeat hi def link fortranRepeat Repeat
hi def link fortranTodo Todo hi def link fortranTodo Todo
hi def link fortranContinueMark Special hi def link fortranContinueMark Special
hi def link fortranEndStatement Special
hi def link fortranString String hi def link fortranString String
hi def link fortranNumber Number hi def link fortranNumber Number
hi def link fortranBinary Number hi def link fortranBinary Number
@ -432,14 +412,15 @@ hi def link fortranHex Number
hi def link fortranOperator Operator hi def link fortranOperator Operator
hi def link fortranBoolean Boolean hi def link fortranBoolean Boolean
hi def link fortranLabelError Error hi def link fortranLabelError Error
hi def link fortranObsolete Todo hi def link fortranObsolescent Todo
hi def link fortranType Type hi def link fortranType Type
hi def link fortranStructure Type hi def link fortranAttribute Type
hi def link fortranBlock fortranConditional
hi def link fortranImageControl Keyword
hi def link fortranStorageClass StorageClass hi def link fortranStorageClass StorageClass
hi def link fortranIntrinsic Function hi def link fortranIntrinsic Function
hi def link fortranCall Function hi def link fortranCalled Function
hi def link fortranUserUnit Function hi def link fortranUnitName Function
hi def link fortranUnitHeader fortranPreCondit hi def link fortranUnitHeader fortranPreCondit
hi def link fortranReadWrite Keyword hi def link fortranReadWrite Keyword
hi def link fortranIO Keyword hi def link fortranIO Keyword
@ -456,7 +437,7 @@ hi def link fortranTypeR fortranType
hi def link fortranStorageClassR fortranStorageClass hi def link fortranStorageClassR fortranStorageClass
hi def link fortranOperatorR fortranOperator hi def link fortranOperatorR fortranOperator
hi def link fortranIOR fortranIO hi def link fortranIOR fortranIO
hi def link fortranConditionalR fortranConditional hi def link fortranRepeatR fortranRepeat
" features deleted or declared obsolescent in Fortran 2023 " features deleted or declared obsolescent in Fortran 2023
if (b:fortran_fixed_source == 1) if (b:fortran_fixed_source == 1)
@ -469,14 +450,14 @@ if (b:fortran_fixed_source == 1)
hi def link fortranRepeatOb fortranRepeat hi def link fortranRepeatOb fortranRepeat
hi def link fortranIntrinsicOb fortranIntrinsic hi def link fortranIntrinsicOb fortranIntrinsic
else else
hi def link fortranUnitHeaderOb fortranObsolete hi def link fortranUnitHeaderOb fortranObsolescent
hi def link fortranKeywordOb fortranObsolete hi def link fortranKeywordOb fortranObsolescent
hi def link fortranKeywordDel fortranObsolete hi def link fortranKeywordDel fortranObsolescent
hi def link fortranConditionalDel fortranObsolete hi def link fortranConditionalDel fortranObsolescent
hi def link fortranTypeOb fortranObsolete hi def link fortranTypeOb fortranObsolescent
hi def link fortranStorageClassOb fortranObsolete hi def link fortranStorageClassOb fortranObsolescent
hi def link fortranRepeatOb fortranObsolete hi def link fortranRepeatOb fortranObsolescent
hi def link fortranIntrinsicOb fortranObsolete hi def link fortranIntrinsicOb fortranObsolescent
endif endif
hi def link fortranFormatSpec Identifier hi def link fortranFormatSpec Identifier