{ "comment": "Specificities of Fortran >= 90", "name": "Fortran - Free Form", "scopeName": "source.fortran.free", "fileTypes": [ "f90", "F90", "f95", "F95", "f03", "F03", "f08", "F08", "f18", "F18", "fpp", "FPP", ".pf", ".PF" ], "firstLineMatch": "(?i)-[*]- mode: fortran free -[*]-", "injections": { "source.fortran.free - ( string | comment | meta.preprocessor )": { "patterns": [ { "include": "#line-continuation-operator" }, { "include": "#preprocessor" } ] }, "string.quoted.double.fortran": { "patterns": [ { "include": "#string-line-continuation-operator" } ] }, "string.quoted.single.fortran": { "patterns": [ { "include": "#string-line-continuation-operator" } ] } }, "patterns": [ { "include": "#preprocessor" }, { "include": "#comments" }, { "include": "#constants" }, { "include": "#operators" }, { "include": "#array-constructor" }, { "include": "#parentheses" }, { "include": "#include-statement" }, { "include": "#import-statement" }, { "include": "#block-data-definition" }, { "include": "#function-definition" }, { "include": "#module-definition" }, { "include": "#program-definition" }, { "include": "#submodule-definition" }, { "include": "#subroutine-definition" }, { "include": "#procedure-definition" }, { "include": "#derived-type-definition" }, { "include": "#enum-block-construct" }, { "include": "#interface-block-constructs" }, { "include": "#procedure-specification-statement" }, { "include": "#type-specification-statements" }, { "include": "#specification-statements" }, { "include": "#control-constructs" }, { "include": "#control-statements" }, { "include": "#execution-statements" }, { "include": "#intrinsic-functions" }, { "include": "#variable" } ], "repository": { "preprocessor": { "name": "meta.preprocessor", "begin": "^\\s*(#:?)", "beginCaptures": { "1": { "name": "keyword.control.preprocessor.indicator.fortran" } }, "end": "\\n", "patterns": [ { "include": "#preprocessor-if-construct" }, { "include": "#preprocessor-statements" } ] }, "preprocessor-comments": { "name": "comment.preprocessor", "begin": "/\\*", "end": "\\*/" }, "preprocessor-constants": { "patterns": [ { "include": "#cpp-numeric-constant" }, { "include": "#preprocessor-string-constant" } ] }, "cpp-numeric-constant": { "match": "(?=)|(\\<)|(\\>)|(~)|(\\^)|(&)|(\\!)|(\\|)", "captures": { "1": { "name": "keyword.operator.logical.preprocessor.and.fortran" }, "2": { "name": "keyword.operator.logical.preprocessor.equals.fortran" }, "3": { "name": "keyword.operator.logical.preprocessor.not_equals.fortran" }, "4": { "name": "keyword.operator.logical.preprocessor.or.fortran" }, "5": { "name": "keyword.operator.logical.preprocessor.less_eq.fortran" }, "6": { "name": "keyword.operator.logical.preprocessor.more_eq.fortran" }, "7": { "name": "keyword.operator.logical.preprocessor.less.fortran" }, "8": { "name": "keyword.operator.logical.preprocessor.more.fortran" }, "9": { "name": "keyword.operator.logical.preprocessor.complementary.fortran" }, "10": { "name": "keyword.operator.logical.preprocessor.xor.fortran" }, "11": { "name": "keyword.operator.logical.preprocessor.bitand.fortran" }, "12": { "name": "keyword.operator.logical.preprocessor.not.fortran" }, "13": { "name": "keyword.operator.logical.preprocessor.bitor.fortran" } } }, "preprocessor-arithmetic-operators": { "comment": "division regex is different than in main fortran", "match": "(\\-)|(\\+)|(\\/)|(\\*)", "captures": { "1": { "name": "keyword.operator.subtraction.fortran" }, "2": { "name": "keyword.operator.addition.fortran" }, "3": { "name": "keyword.operator.division.fortran" }, "4": { "name": "keyword.operator.multiplication.fortran" } } }, "preprocessor-statements": { "patterns": [ { "include": "#preprocessor-define-statement" }, { "include": "#preprocessor-error-statement" }, { "include": "#preprocessor-include-statement" }, { "include": "#preprocessor-preprocessor-pragma-statement" }, { "include": "#preprocessor-undefine-statement" } ] }, "preprocessor-define-statement": { "name": "meta.preprocessor.macro.fortran", "begin": "(?i)\\G\\s*\\b(define)\\b", "beginCaptures": { "1": { "name": "keyword.control.preprocessor.define.fortran" } }, "end": "(?=\\n)", "patterns": [ { "include": "#preprocessor-comments" }, { "include": "#preprocessor-constants" }, { "include": "#preprocessor-line-continuation-operator" } ] }, "preprocessor-error-statement": { "name": "meta.preprocessor.macro.fortran", "begin": "(?i)\\G\\s*(error)\\b", "beginCaptures": { "1": { "name": "keyword.control.preprocessor.error.fortran" } }, "end": "(?=\\n)", "patterns": [ { "include": "#preprocessor-comments" }, { "include": "#preprocessor-string-constant" }, { "include": "#preprocessor-line-continuation-operator" } ] }, "preprocessor-include-statement": { "name": "meta.preprocessor.include.fortran", "begin": "(?i)\\G\\s*(include)\\b", "beginCaptures": { "1": { "name": "keyword.control.preprocessor.include.fortran" } }, "end": "(?=\\n)", "patterns": [ { "include": "#preprocessor-comments" }, { "include": "#preprocessor-string-constant" }, { "name": "string.quoted.other.lt-gt.include.preprocessor.fortran", "begin": "<", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.preprocessor.fortran" } }, "end": ">", "endCaptures": { "0": { "name": "punctuation.definition.string.end.preprocessor.fortran" } } }, { "include": "#line-continuation-operator" } ] }, "preprocessor-pragma-statement": { "name": "meta.preprocessor.pragma.fortran", "begin": "(?i)\\G\\s*\\b(pragma)\\b", "beginCaptures": { "1": { "name": "keyword.control.preprocessor.pragma.fortran" } }, "end": "(?=\\n)", "patterns": [ { "include": "#preprocessor-comments" }, { "include": "#preprocessor-string-constant" } ] }, "preprocessor-undefine-statement": { "name": "meta.preprocessor.undef.fortran", "begin": "(?i)\\G\\s*\\b(undef)\\b", "beginCaptures": { "1": { "name": "keyword.control.preprocessor.undef.fortran" } }, "end": "(?=\\n)", "patterns": [ { "include": "#preprocessor-comments" }, { "include": "#preprocessor-line-continuation-operator" } ] }, "abstract-attribute": { "comment": "Introduced in the Fortran 2003 standard.", "match": "(?i)\\G\\s*\\b(abstract)\\b", "captures": { "1": { "name": "storage.modifier.fortran.fortran" } } }, "access-attribute": { "patterns": [ { "include": "#private-attribute" }, { "include": "#public-attribute" } ] }, "allocatable-attribute": { "comment": "Introduced in the Fortran 1990 standard.", "match": "(?i)\\s*\\b(allocatable)\\b", "captures": { "1": { "name": "storage.modifier.allocatable.fortran" } } }, "asynchronous-attribute": { "comment": "Introduced in the Fortran 2003 standard.", "match": "(?i)\\G\\s*\\b(asynchronous)\\b", "captures": { "1": { "name": "storage.modifier.asynchronous.fortran" } } }, "codimension-attribute": { "comment": "Introduced in the Fortran 2008 standard.", "begin": "(?i)\\G\\s*\\b(codimension)(?=\\s*\\[)", "beginCaptures": { "1": { "name": "storage.modifier.codimension.fortran" } }, "end": "(?\\=|\\>|\\<|\\<\\=|\\-|\\+|\\/|\\/\\/|\\*\\*|\\*) |(\\S.*) )\\s*(\\))", "beginCaptures": { "1": { "name": "keyword.other.operator.fortran" }, "2": { "name": "punctuation.parentheses.left.fortran" }, "3": { "name": "keyword.operator.fortran" }, "4": { "name": "invalid.error.generic-interface-block-op.fortran" }, "5": { "name": "punctuation.parentheses.right.fortran" } }, "end": "(?ix)\\b(end\\s*interface)\\b (?:\\s*\\b(\\1)\\b\\s*(\\()\\s*(?:(\\3)|(\\S.*))\\s*(\\)))?", "endCaptures": { "1": { "name": "keyword.control.endinterface.fortran" }, "2": { "name": "keyword.other.operator.fortran" }, "3": { "name": "punctuation.parentheses.left.fortran" }, "4": { "name": "keyword.operator.fortran" }, "5": { "name": "invalid.error.generic-interface-block-op-end.fortran" }, "6": { "name": "punctuation.parentheses.right.fortran" } }, "patterns": [ { "include": "#interface-procedure-statement" }, { "include": "$base" } ] }, { "comment": "Read/Write generic interface.", "begin": "(?ix)\\G\\s*\\b(?:(read)|(write))\\s* (\\()\\s*(?:(formatted)|(unformatted)|(\\S.*))\\s*(\\))", "beginCaptures": { "1": { "name": "keyword.other.read.fortran" }, "2": { "name": "keyword.other.write.fortran" }, "3": { "name": "punctuation.parentheses.left.fortran" }, "4": { "name": "keyword.other.formatted.fortran" }, "5": { "name": "keyword.other.unformatted.fortran" }, "6": { "name": "invalid.error.generic-interface-block.fortran" }, "7": { "name": "punctuation.parentheses.right.fortran" } }, "end": "(?ix)\\b(end\\s*interface)\\b(?:\\s*\\b(?:(\\2)|(\\3))\\b\\s* (\\()\\s*(?:(\\4)|(\\5)|(\\S.*))\\s*(\\)))?", "endCaptures": { "1": { "name": "keyword.control.endinterface.fortran" }, "2": { "name": "keyword.other.read.fortran" }, "3": { "name": "keyword.other.write.fortran" }, "4": { "name": "punctuation.parentheses.left.fortran" }, "5": { "name": "keyword.other.formatted.fortran" }, "6": { "name": "keyword.other.unformatted.fortran" }, "7": { "name": "invalid.error.generic-interface-block-end.fortran" }, "8": { "name": "punctuation.parentheses.right.fortran" } }, "patterns": [ { "include": "#interface-procedure-statement" }, { "include": "$base" } ] }, { "comment": "Generic interface.", "begin": "(?i)\\G\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.function.fortran" } }, "end": "(?i)\\b(end\\s*interface)\\b(?:\\s*\\b(\\1)\\b)?", "endCaptures": { "1": { "name": "keyword.control.endinterface.fortran" }, "2": { "name": "entity.name.function.fortran" } }, "patterns": [ { "include": "#interface-procedure-statement" }, { "include": "$base" } ] } ] }, "interface-procedure-statement": { "comment": "Introduced in the Fortran 1990 standard.", "name": "meta.statement.procedure.fortran", "begin": "(?i)(?=[^'\";!\\n]*\\bprocedure\\b)", "end": "(?=[;!\\n])", "patterns": [ { "comment": "Attribute list.", "name": "meta.attribute-list.interface.fortran", "begin": "(?i)(?=\\G\\s*(?!\\bprocedure\\b))", "end": "(?i)(?=\\bprocedure\\b)", "patterns": [ { "include": "#module-attribute" }, { "include": "#invalid-word" } ] }, { "comment": "Procedure statement.", "begin": "(?i)\\s*\\b(procedure)\\b", "beginCaptures": { "1": { "name": "keyword.other.procedure.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "match": "\\G\\s*(::)", "captures": { "1": { "name": "keyword.operator.double-colon.fortran" } } }, { "include": "#procedure-name-list" } ] } ] }, "intrinsic-functions": { "patterns": [ { "comment": "Intrinsic functions introduced in the Fortran 2008 standard.", "begin": "(?ix)\\b(acosh|asinh|atanh|bge|bgt|ble|blt|dshiftl|dshiftr| findloc|hypot|iall|iany|image_index|iparity|is_contiguous|lcobound| leadz|mask[lr]|merge_bits|norm2|num_images|parity|popcnt|poppar| shift[alr]|storage_size|this_image|trailz|ucobound)\\s*(?=\\()", "beginCaptures": { "1": { "name": "support.function.intrinsic.fortran" }, "2": { "name": "punctuation.parentheses.left.fortran" } }, "end": "(?)(\\=)(?!\\=|\\>)" }, "derived-type-operators": { "comment": "Introduced in the Fortran 1995 standard.", "match": "\\s*(\\%)", "captures": { "1": { "name": "keyword.other.selector.fortran" } } }, "line-continuation-operator": { "comment": "Operator that allows a line to be continued on the next line.", "patterns": [ { "match": "(?:^|(?<=;))\\s*(&)", "captures": { "1": { "name": "keyword.operator.line-continuation.fortran" } } }, { "contentName": "meta.line-continuation.fortran", "begin": "\\s*(&)", "beginCaptures": { "1": { "name": "keyword.operator.line-continuation.fortran" } }, "end": "(?i)^(?:\\s*(&))?", "endCaptures": { "1": { "name": "keyword.operator.line-continuation.fortran" } }, "patterns": [ { "include": "#comments" }, { "name": "invalid.error.line-cont.fortran", "match": "\\S[^!]*" } ] } ] }, "logical-operators": { "patterns": [ { "comment": "Introduced in the Fortran 1977 standard.", "match": "(?ix)(\\s*\\.(and|eq|eqv|le|lt|ge|gt|ne|neqv|not|or)\\.)", "name": "keyword.logical.fortran" }, { "comment": "Introduced in the Fortran 1990 standard.", "name": "keyword.logical.fortran.modern", "match": "(\\=\\=|\\/\\=|\\>\\=|(?|\\<\\=|\\<)" } ] }, "pointer-operators": { "comment": "Introduced in the Fortran 1990 standard.", "name": "keyword.other.point.fortran", "match": "(\\=\\>)" }, "string-operators": { "comment": "Introduced in the Fortran 19?? standard.", "name": "keyword.other.concatination.fortran", "match": "(\\/\\/)" }, "string-line-continuation-operator": { "comment": "Operator that allows a line to be continued on the next line.", "begin": "(&)(?=\\s*\\n)", "beginCaptures": { "1": { "name": "keyword.operator.line-continuation.fortran" } }, "end": "(?i)^(?:(?=\\s*[^\\s!&])|\\s*(&))", "endCaptures": { "1": { "name": "keyword.operator.line-continuation.fortran" } }, "patterns": [ { "include": "#comments" }, { "name": "invalid.error.string-line-cont.fortran", "match": "\\S.*" } ] }, "user-defined-operators": { "match": "(?i)\\s*(\\.[a-z]+\\.)", "captures": { "1": { "name": "keyword.operator.user-defined.fortran" } } }, "block-data-definition": { "name": "meta.block-data.fortran", "begin": "(?i)\\b(block\\s*data)\\b(?:\\s+([a-z]\\w*)\\b)?", "beginCaptures": { "1": { "name": "keyword.control.block-data.fortran" }, "2": { "name": "entity.name.block-data.fortran" } }, "end": "(?ix)\\b(?:(end\\s*block\\s*data)(?:\\s+(\\2))?|(end))\\b (?:\\s*(\\S((?!\\n).)*))?", "endCaptures": { "1": { "name": "keyword.control.end-block-data.fortran" }, "2": { "name": "entity.name.block-data.fortran" }, "3": { "name": "keyword.control.end-block-data.fortran" }, "4": { "name": "invalid.error.block-data-definition.fortran" } }, "patterns": [ { "include": "$base" } ] }, "function-definition": { "comment": "Function program unit. Introduced in the Fortran 1977 standard.", "name": "meta.function.fortran", "begin": "(?i)(?=([^:'\";!\\n](?!\\bend)(?!\\bsubroutine\\b))*\\bfunction\\b)", "end": "(?=[;!\\n])", "patterns": [ { "comment": "Function attribute list.", "name": "meta.attribute-list.function.fortran", "begin": "(?i)(?=\\G\\s*(?!\\bfunction\\b))", "end": "(?i)(?=\\bfunction\\b)", "patterns": [ { "include": "#elemental-attribute" }, { "include": "#module-attribute" }, { "include": "#pure-attribute" }, { "include": "#recursive-attribute" }, { "include": "#types" }, { "include": "#invalid-word" } ] }, { "comment": "Captures the function keyword", "begin": "(?i)\\b(function)\\b", "beginCaptures": { "1": { "name": "keyword.other.function.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "comment": "Function body.", "begin": "(?i)\\G\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.function.fortran" } }, "end": "(?ix)\\s*\\b(?:(end\\s*function)(?:\\s+([a-z_]\\w*))?|(end))\\b \\s*([^;!\\n]+)?(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.other.endfunction.fortran" }, "2": { "name": "entity.name.function.fortran" }, "3": { "name": "keyword.other.endfunction.fortran" }, "4": { "name": "invalid.error.function.fortran" } }, "patterns": [ { "comment": "Rest of the first line in function construct.", "name": "meta.function.first-line.fortran", "begin": "\\G(?!\\s*[;!\\n])", "end": "(?=[;!\\n])", "patterns": [ { "include": "#dummy-variable-list" }, { "include": "#result-statement" }, { "include": "#language-binding-attribute" } ] }, { "comment": "Specification and execution block.", "name": "meta.block.specification.function.fortran", "begin": "(?i)(?!\\b(?:end\\s*[;!\\n]|end\\s*function\\b))", "end": "(?i)(?=\\b(?:end\\s*[;!\\n]|end\\s*function\\b))", "patterns": [ { "comment": "Contains block.", "name": "meta.block.contains.fortran", "begin": "(?i)\\b(contains)\\b", "beginCaptures": { "1": { "name": "keyword.control.contains.fortran" } }, "end": "(?i)(?=(?:end\\s*[;!\\n]|end\\s*function\\b))", "patterns": [ { "include": "$base" } ] }, { "include": "$base" } ] } ] } ] } ] }, "module-definition": { "comment": "Introduced in the Fortran 1990 standard.", "name": "meta.module.fortran", "begin": "(?ix)(?=\\b(module)\\b)(?![^'\";!\\n]* \\b(?:function|procedure|subroutine)\\b)", "end": "(?=[;!\\n])", "patterns": [ { "match": "(?i)\\G\\s*\\b(module)\\b", "captures": { "1": { "name": "keyword.other.program.fortran" } } }, { "comment": "Module body.", "begin": "(?i)\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.class.module.fortran" } }, "end": "(?ix)\\b(?:(end\\s*module)(?:\\s+([a-z_]\\w*))?|(end))\\b \\s*([^;!\\n]+)?(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.other.endmodule.fortran" }, "2": { "name": "entity.name.class.module.fortran" }, "3": { "name": "keyword.other.endmodule.fortran" }, "4": { "name": "invalid.error.module-definition.fortran" } }, "applyEndPatternLast": 1, "patterns": [ { "comment": "Module specification block.", "name": "meta.block.specification.module.fortran", "begin": "\\G", "end": "(?i)(?=\\b(?:end\\s*[;!\\n]|end\\s*module\\b))", "patterns": [ { "comment": "Module contains block.", "name": "meta.block.contains.fortran", "begin": "(?i)\\b(contains)\\b", "beginCaptures": { "1": { "name": "keyword.control.contains.fortran" } }, "end": "(?i)(?=\\s*(?:end\\s*[;!\\n]|end\\s*module\\b))", "patterns": [ { "include": "$base" } ] }, { "include": "$base" } ] } ] } ] }, "program-definition": { "comment": "Introduced in the Fortran 1977 standard.", "name": "meta.program.fortran", "begin": "(?i)(?=\\b(program)\\b)", "end": "(?=[;!\\n])", "patterns": [ { "match": "(?i)\\G\\s*\\b(program)\\b", "captures": { "1": { "name": "keyword.control.program.fortran" } } }, { "comment": "Program body.", "begin": "(?i)\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.program.fortran" } }, "end": "(?ix)\\b(?:(end\\s*program)(?:\\s+([a-z_]\\w*))?|(end))\\b\\s*([^;!\\n]+)?(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.control.endprogram.fortran" }, "2": { "name": "entity.name.program.fortran" }, "3": { "name": "keyword.control.endprogram.fortran" }, "4": { "name": "invalid.error.program-definition.fortran" } }, "applyEndPatternLast": 1, "patterns": [ { "comment": "Program specification block.", "name": "meta.block.specification.program.fortran", "begin": "\\G", "end": "(?i)(?=\\b(?:end\\s*[;!\\n]|end\\s*program\\b))", "patterns": [ { "comment": "Program contains block.", "name": "meta.block.contains.fortran", "begin": "(?i)\\b(contains)\\b", "beginCaptures": { "1": { "name": "keyword.control.contains.fortran" } }, "end": "(?i)(?=(?:end\\s*[;!\\n]|end\\s*program\\b))", "patterns": [ { "include": "$base" } ] }, { "include": "$base" } ] } ] } ] }, "procedure-definition": { "comment": "Procedure program unit. Introduced in the Fortran 2008 standard.", "name": "meta.procedure.fortran", "begin": "(?i)(?=[^'\";!\\n]*\\bmodule\\s+procedure\\b)", "end": "(?=[;!\\n])", "patterns": [ { "begin": "(?i)\\s*\\b(module\\s+procedure)\\b", "beginCaptures": { "1": { "name": "keyword.other.procedure.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "comment": "Procedure body.", "begin": "(?i)\\G\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.function.procedure.fortran" } }, "end": "(?ix)\\s*\\b(?:(end\\s*procedure)(?:\\s+([a-z_]\\w*))?|(end))\\b \\s*([^;!\\n]+)?(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.other.endprocedure.fortran" }, "2": { "name": "entity.name.function.procedure.fortran" }, "3": { "name": "keyword.other.endprocedure.fortran" }, "4": { "name": "invalid.error.procedure-definition.fortran" } }, "patterns": [ { "comment": "Rest of the first line in procedure construct - should be empty.", "name": "meta.first-line.fortran", "begin": "\\G(?!\\s*[;!\\n])", "end": "(?=[;!\\n])", "patterns": [ { "include": "#invalid-character" } ] }, { "comment": "Specification and execution block.", "name": "meta.block.specification.procedure.fortran", "begin": "(?i)(?!\\s*(?:contains\\b|end\\s*[;!\\n]|end\\s*procedure\\b))", "end": "(?i)(?=\\s*(?:contains\\b|end\\s*[;!\\n]|end\\s*procedure\\b))", "patterns": [ { "include": "$self" } ] }, { "comment": "Contains block.", "name": "meta.block.contains.fortran", "begin": "(?i)\\s*(contains)\\b", "beginCaptures": { "1": { "name": "keyword.control.contains.fortran" } }, "end": "(?i)(?=\\s*(?:end\\s*[;!\\n]|end\\s*procedure\\b))", "patterns": [ { "include": "$self" } ] } ] } ] } ] }, "subroutine-definition": { "comment": "Subroutine program unit. Introduced in the Fortran 1977 standard.", "name": "meta.subroutine.fortran", "begin": "(?i)(?=([^:'\";!\\n](?!\\bend))*\\bsubroutine\\b)", "end": "(?=[;!\\n])", "patterns": [ { "comment": "Attribute list.", "name": "meta.attribute-list.subroutine.fortran", "begin": "(?i)(?=\\G\\s*(?!\\bsubroutine\\b))", "end": "(?i)(?=\\bsubroutine\\b)", "patterns": [ { "include": "#elemental-attribute" }, { "include": "#module-attribute" }, { "include": "#pure-attribute" }, { "include": "#recursive-attribute" }, { "include": "#invalid-word" } ] }, { "begin": "(?i)\\s*\\b(subroutine)\\b", "beginCaptures": { "1": { "name": "keyword.other.subroutine.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "comment": "Subroutine body.", "begin": "(?i)\\G\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.function.subroutine.fortran" } }, "end": "(?ix)\\b(?:(end\\s*subroutine)(?:\\s+([a-z_]\\w*))?|(end))\\b \\s*([^;!\\n]+)?(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.other.endsubroutine.fortran" }, "2": { "name": "entity.name.function.subroutine.fortran" }, "3": { "name": "keyword.other.endsubroutine.fortran" }, "4": { "name": "invalid.error.subroutine.fortran" } }, "patterns": [ { "comment": "Rest of the first line in subroutine construct.", "name": "meta.first-line.fortran", "begin": "\\G(?!\\s*[;!\\n])", "end": "(?=[;!\\n])", "patterns": [ { "include": "#dummy-variable-list" }, { "include": "#language-binding-attribute" } ] }, { "comment": "Specification and execution block.", "name": "meta.block.specification.subroutine.fortran", "begin": "(?i)(?!\\b(?:end\\s*[;!\\n]|end\\s*subroutine\\b))", "end": "(?i)(?=\\b(?:end\\s*[;!\\n]|end\\s*subroutine\\b))", "patterns": [ { "comment": "Contains block.", "name": "meta.block.contains.fortran", "begin": "(?i)\\b(contains)\\b", "beginCaptures": { "1": { "name": "keyword.control.contains.fortran" } }, "end": "(?i)(?=(?:end\\s*[;!\\n]|end\\s*subroutine\\b))", "patterns": [ { "include": "$base" } ] }, { "include": "$base" } ] } ] } ] } ] }, "submodule-definition": { "comment": "Introduced in the Fortran 2008 standard.", "name": "meta.submodule.fortran", "begin": "(?i)(?=\\b(submodule)\\s*\\()", "end": "(?=[;!\\n])", "patterns": [ { "begin": "(?i)\\G\\s*\\b(submodule)\\s*(\\()\\s*(\\w+)", "beginCaptures": { "1": { "name": "keyword.other.submodule.fortran" }, "2": { "name": "punctuation.parentheses.left.fortran" }, "3": { "name": "entity.name.class.submodule.fortran" } }, "end": "(\\))", "endCaptures": { "1": { "name": "punctuation.parentheses.left.fortran" } }, "patterns": [] }, { "comment": "Submodule body.", "begin": "(?i)\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.module.submodule.fortran" } }, "end": "(?ix)\\s*\\b(?:(end\\s*submodule)(?:\\s+([a-z_]\\w*))?|(end))\\b \\s*([^;!\\n]+)?(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.other.endsubmodule.fortran" }, "2": { "name": "entity.name.module.submodule.fortran" }, "3": { "name": "keyword.other.endsubmodule.fortran" }, "4": { "name": "invalid.error.submodule.fortran" } }, "applyEndPatternLast": 1, "patterns": [ { "comment": "Submodule specification block.", "name": "meta.block.specification.submodule.fortran", "begin": "\\G", "end": "(?i)(?=\\b(?:end\\s*[;!\\n]|end\\s*submodule\\b))", "patterns": [ { "comment": "Submodule contains block.", "name": "meta.block.contains.fortran", "begin": "(?i)\\b(contains)\\b", "beginCaptures": { "1": { "name": "keyword.control.contains.fortran" } }, "end": "(?i)(?=\\s*(?:end\\s*[;!\\n]|end\\s*submodule\\b))", "patterns": [ { "include": "$base" } ] }, { "include": "$base" } ] } ] } ] }, "type-specification-statements": { "name": "meta.specification.type.fortran", "comment": "Supported types for function and escape :: if function is used as a variable name (which is bad practice).", "begin": "(?ix)(?=\\b(?:character|class|complex|double\\s*precision|double\\s*complex|integer|logical|real|type|dimension)\\b(?![^'\";!\\n:]*\\bfunction\\b))", "end": "(?=[\\);!\\n])", "patterns": [ { "include": "#types" }, { "comment": "Attribute list.", "contentName": "meta.attribute-list.type-specification-statements.fortran", "begin": "(?=\\s*(,|::))", "end": "(::)|(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.operator.double-colon.fortran" } }, "patterns": [ { "begin": "(,)|^|(?<=&)", "beginCaptures": { "1": { "name": "punctuation.comma.fortran" } }, "end": "(?=::|[,&;!\\n])", "patterns": [ { "include": "#access-attribute" }, { "include": "#allocatable-attribute" }, { "include": "#asynchronous-attribute" }, { "include": "#codimension-attribute" }, { "include": "#contiguous-attribute" }, { "include": "#dimension-attribute" }, { "include": "#external-attribute" }, { "include": "#intent-attribute" }, { "include": "#intrinsic-attribute" }, { "include": "#language-binding-attribute" }, { "include": "#optional-attribute" }, { "include": "#parameter-attribute" }, { "include": "#pointer-attribute" }, { "include": "#protected-attribute" }, { "include": "#save-attribute" }, { "include": "#target-attribute" }, { "include": "#value-attribute" }, { "include": "#volatile-attribute" }, { "include": "#invalid-word" } ] } ] }, { "include": "#name-list" } ] }, "procedure-specification-statement": { "comment": "Introduced in the Fortran 2003 standard.", "name": "meta.specification.procedure.fortran", "begin": "(?i)(?=\\b(?:procedure)\\b)", "end": "(?=[;!\\n])", "patterns": [ { "include": "#procedure-type" }, { "comment": "Attribute list.", "contentName": "meta.attribute-list.procedure.fortran", "begin": "(?=\\s*(,|::|\\())", "end": "(::)|(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.operator.double-colon.fortran" } }, "patterns": [ { "begin": "(,)|^|(?<=&)", "beginCaptures": { "1": { "name": "punctuation.comma.fortran" } }, "end": "(?=::|[,&;!\\n])", "patterns": [ { "include": "#access-attribute" }, { "include": "#intent-attribute" }, { "include": "#optional-attribute" }, { "include": "#pointer-attribute" }, { "include": "#protected-attribute" }, { "include": "#save-attribute" }, { "include": "#invalid-word" } ] } ] }, { "include": "#procedure-name-list" } ] }, "specification-statements": { "patterns": [ { "include": "#attribute-specification-statement" }, { "include": "#common-statement" }, { "include": "#data-statement" }, { "include": "#equivalence-statement" }, { "include": "#implicit-statement" }, { "include": "#namelist-statement" }, { "include": "#use-statement" } ] }, "attribute-specification-statement": { "name": "meta.statement.attribute-specification.fortran", "begin": "(?ix)(?=\\b(?:allocatable|asynchronous|contiguous |external|intrinsic|optional|parameter|pointer|private|protected|public|save|target|value|volatile)\\b |(bind|dimension|intent)\\s*\\( |(codimension)\\s*\\[)", "end": "(?=[;!\\n])", "patterns": [ { "include": "#access-attribute" }, { "include": "#allocatable-attribute" }, { "include": "#asynchronous-attribute" }, { "include": "#codimension-attribute" }, { "include": "#contiguous-attribute" }, { "include": "#dimension-attribute" }, { "include": "#external-attribute" }, { "include": "#intent-attribute" }, { "include": "#intrinsic-attribute" }, { "include": "#language-binding-attribute" }, { "include": "#optional-attribute" }, { "include": "#parameter-attribute" }, { "include": "#pointer-attribute" }, { "include": "#protected-attribute" }, { "include": "#save-attribute" }, { "include": "#target-attribute" }, { "include": "#value-attribute" }, { "include": "#volatile-attribute" }, { "comment": "Attribute list.", "contentName": "meta.attribute-list.normal.fortran", "begin": "(?=\\s*::)", "end": "(::)|(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.operator.double-colon.fortran" } }, "patterns": [ { "include": "#invalid-word" } ] }, { "include": "#name-list" } ] }, "common-statement": { "begin": "(?i)\\b(common)\\b", "beginCaptures": { "1": { "name": "keyword.control.common.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "include": "$base" } ] }, "data-statement": { "begin": "(?i)\\b(data)\\b", "beginCaptures": { "1": { "name": "keyword.control.data.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "include": "$base" } ] }, "equivalence-statement": { "begin": "(?i)\\b(equivalence)\\b", "beginCaptures": { "1": { "name": "keyword.control.common.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "begin": "(?:\\G|(,))", "beginCaptures": { "1": { "name": "puntuation.comma.fortran" } }, "end": "(?=[,;!\\n])", "patterns": [ { "include": "#parentheses-dummy-variables" } ] } ] }, "implicit-statement": { "name": "meta.statement.implicit.fortran", "begin": "(?i)\\b(implicit)\\b", "beginCaptures": { "1": { "name": "keyword.other.implicit.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "match": "(?i)\\s*\\b(none)\\b", "captures": { "1": { "name": "keyword.other.none.fortran" } } }, { "include": "$base" } ] }, "namelist-statement": { "comment": "Introduced in the Fortran 1990 standard.", "begin": "(?i)\\b(namelist)\\b", "beginCaptures": { "1": { "name": "keyword.control.namelist.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "include": "$base" } ] }, "use-statement": { "comment": "Introduced in the Fortran 1990 standard.", "name": "meta.statement.use.fortran", "begin": "(?i)\\b(use)\\b", "beginCaptures": { "1": { "name": "keyword.control.use.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "comment": "Attribute list.", "contentName": "meta.attribute-list.namelist.fortran", "begin": "(?=\\s*(,|::|\\())", "end": "(::)|(?=[;!\\n])", "endCaptures": { "1": { "name": "keyword.operator.double-colon.fortran" } }, "patterns": [ { "begin": "(,)", "beginCaptures": { "1": { "name": "punctuation.comma.fortran" } }, "end": "(?=::|[,;!\\n])", "patterns": [ { "include": "#intrinsic-attribute" }, { "include": "#non-intrinsic-attribute" }, { "include": "#invalid-word" } ] } ] }, { "begin": "(?i)\\s*\\b([a-z]\\w*)\\b", "beginCaptures": { "1": { "name": "entity.name.class.module.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "begin": "(,)", "beginCaptures": { "1": { "name": "punctuation.comma.fortran" } }, "end": "(?=::|[;!\\n])", "patterns": [ { "begin": "(?i)\\s*\\b(only\\s*:)", "beginCaptures": { "1": { "name": "keyword.control.only.fortran" } }, "end": "(?=[;!\\n])", "patterns": [ { "include": "#operator-keyword" }, { "include": "$base" } ] }, { "contentName": "meta.name-list.fortran", "begin": "(?i)(?=\\s*[a-z])", "end": "(?=[;!\\n])", "patterns": [ { "include": "#operator-keyword" }, { "include": "$base" } ] } ] } ] } ] }, "types": { "patterns": [ { "include": "#character-type" }, { "include": "#derived-type" }, { "include": "#logical-type" }, { "include": "#numeric-type" } ] }, "character-type": { "comment": "Introduced in the Fortran 1977 standard.", "patterns": [ { "begin": "(?i)\\b(character)\\s*(?=\\()", "beginCaptures": { "1": { "name": "storage.type.character.fortran" }, "2": { "name": "punctuation.parentheses.left.fortran" } }, "end": "(?