Skip to content

Commit

Permalink
feat: add fortran (fixed form)
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter committed Jan 29, 2024
1 parent e444180 commit 2a604ad
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/tm-grammars/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

=========================================================================================================
Files: fortran-free-form.json
Files: fortran-fixed-form.json, fortran-free-form.json
License: https://raw.githubusercontent.com/fortran-lang/vscode-fortran-support/main/LICENSE
SPDX: MIT
---------------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions packages/tm-grammars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { grammars } from 'tm-grammars'
| `erb` | | [textmate/ruby.tmbundle](https://github.com/textmate/ruby.tmbundle/blob/ecf0f1df23984bcff9b51552e35d9696cb0d9539/Syntaxes/HTML%20(Ruby%20-%20ERB).tmLanguage) | | `html` `ruby` | 1.90 kB |
| `erlang` | `erl` | [erlang-ls/grammar](https://github.com/erlang-ls/grammar/blob/20fc9036e3c2b2ada5f14925bffc7041951f38af/Erlang.plist) | [Apache-2.0](https://raw.githubusercontent.com/erlang-ls/grammar/main/LICENSE) | | 28.16 kB |
| `fish` | | [bmalehorn/vscode-fish](https://github.com/bmalehorn/vscode-fish/blob/2fe4ccc72fdcd9b9f54fbb2c05fe9b350c32d718/syntaxes/fish.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/bmalehorn/vscode-fish/master/LICENSE) | | 5.06 kB |
| `fortran-fixed-form` | | [fortran-lang/vscode-fortran-support](https://github.com/fortran-lang/vscode-fortran-support/blob/e642012094fc0a7379f204bb4e61243005afb1da/syntaxes/fortran_fixed-form.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/fortran-lang/vscode-fortran-support/main/LICENSE) | `fortran-free-form` | 905.00 B |
| `fortran-free-form` | | [fortran-lang/vscode-fortran-support](https://github.com/fortran-lang/vscode-fortran-support/blob/f7fb41579770a0d8c75b9f295d167b31147b4f33/syntaxes/fortran_free-form.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/fortran-lang/vscode-fortran-support/main/LICENSE) | | 92.92 kB |
| `fsharp` | `f#` `fs` | [microsoft/vscode](https://github.com/microsoft/vscode/blob/35d97bc7e439fce0f50f42074041ab2d8571b20a/extensions/fsharp/syntaxes/fsharp.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `markdown` | 24.18 kB |
| `gdresource` | | [godotengine/godot-vscode-plugin](https://github.com/godotengine/godot-vscode-plugin/blob/e7e2d0439dea0fb3a568378554c81e0a17348a84/syntaxes/GDResource.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/godotengine/godot-vscode-plugin/master/LICENSE) | `gdshader` `gdscript` | 4.90 kB |
Expand Down
74 changes: 74 additions & 0 deletions packages/tm-grammars/grammars/fortran-fixed-form.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"displayName": "Fortran (Fixed Form)",
"fileTypes": [
"f",
"F",
"f77",
"F77",
"for",
"FOR"
],
"injections": {
"source.fortran.fixed - ( string | comment )": {
"patterns": [
{
"include": "#line-header"
},
{
"include": "#line-end-comment"
}
]
}
},
"name": "fortran-fixed-form",
"patterns": [
{
"include": "#comments"
},
{
"include": "#line-header"
},
{
"include": "source.fortran.free"
}
],
"repository": {
"comments": {
"patterns": [
{
"begin": "^[cC\\*]",
"end": "\\n",
"name": "comment.line.fortran"
},
{
"begin": "^ *!",
"end": "\\n",
"name": "comment.line.fortran"
}
]
},
"line-end-comment": {
"begin": "(?<=^.{72})(?!\\n)",
"end": "(?=\\n)",
"name": "comment.line-end.fortran"
},
"line-header": {
"captures": {
"1": {
"name": "constant.numeric.fortran"
},
"2": {
"name": "keyword.line-continuation-operator.fortran"
},
"3": {
"name": "source.fortran.free"
},
"4": {
"name": "invalid.error.fortran"
}
},
"match": "^(?!\\s*[!#])(?:([ \\d]{5} )|( {5}.)|(\\t)|(.{1,5}))"
}
},
"scopeName": "source.fortran.fixed"
}
14 changes: 14 additions & 0 deletions packages/tm-grammars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,20 @@ export const grammars = [
sha: '2fe4ccc72fdcd9b9f54fbb2c05fe9b350c32d718',
source: 'https://github.com/bmalehorn/vscode-fish/blob/2fe4ccc72fdcd9b9f54fbb2c05fe9b350c32d718/syntaxes/fish.tmLanguage.json',
},
{
byteSize: 905,
displayName: 'Fortran (Fixed Form)',
embedded: [
'fortran-free-form',
],
lastUpdate: '2021-11-09T22:09:17Z',
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/fortran-lang/vscode-fortran-support/main/LICENSE',
name: 'fortran-fixed-form',
scopeName: 'source.fortran.fixed',
sha: 'e642012094fc0a7379f204bb4e61243005afb1da',
source: 'https://github.com/fortran-lang/vscode-fortran-support/blob/e642012094fc0a7379f204bb4e61243005afb1da/syntaxes/fortran_fixed-form.tmLanguage.json',
},
{
byteSize: 95147,
displayName: 'Fortran (Free Form)',
Expand Down
34 changes: 34 additions & 0 deletions samples/fortran-fixed-form.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
* euclid.f (FORTRAN 77)
* Find greatest common divisor using the Euclidean algorithm

PROGRAM EUCLID
PRINT *, 'A?'
READ *, NA
IF (NA.LE.0) THEN
PRINT *, 'A must be a positive integer.'
STOP
END IF
PRINT *, 'B?'
READ *, NB
IF (NB.LE.0) THEN
PRINT *, 'B must be a positive integer.'
STOP
END IF
PRINT *, 'The GCD of', NA, ' and', NB, ' is', NGCD(NA, NB), '.'
STOP
END

FUNCTION NGCD(NA, NB)
IA = NA
IB = NB
1 IF (IB.NE.0) THEN
ITEMP = IA
IA = IB
IB = MOD(ITEMP, IB)
GOTO 1
END IF
NGCD = IA
RETURN
END

* From https://en.wikibooks.org/wiki/Fortran/Fortran_examples#Greatest_common_divisor
5 changes: 5 additions & 0 deletions sources-grammars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ export const sourcesCommunity: GrammarSource[] = [
displayName: 'Fortran (Free Form)',
source: 'https://github.com/fortran-lang/vscode-fortran-support/blob/main/syntaxes/fortran_free-form.tmLanguage.json',
},
{
name: 'fortran-fixed-form',
displayName: 'Fortran (Fixed Form)',
source: 'https://github.com/fortran-lang/vscode-fortran-support/blob/main/syntaxes/fortran_fixed-form.tmLanguage.json',
},
{
name: 'gdresource',
displayName: 'GDResource',
Expand Down

0 comments on commit 2a604ad

Please sign in to comment.