Skip to content

Commit 801c7f3

Browse files
committed
Add syntax test for fixed form fortran
1 parent 920ea64 commit 801c7f3

File tree

3 files changed

+129
-2
lines changed

3 files changed

+129
-2
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@
211211
"watch": "tsc -watch -p ./",
212212
"postinstall": "node ./node_modules/vscode/bin/install",
213213
"test": "CODE_TESTS_WORKSPACE='./' node ./node_modules/vscode/bin/test",
214-
"test:grammar": "vscode-tmgrammar-snap -s source.fortran.free -g ./syntaxes/fortran_free-form.tmLanguage.json -t \"./test/**/*{.f90,F90}\"",
215-
"test:grammar-update": "npm run test:grammar -- -u",
214+
"test:grammar-free": "vscode-tmgrammar-snap -s source.fortran.free -g ./syntaxes/fortran_free-form.tmLanguage.json -t \"./test/**/*{.f90,F90}\"",
215+
"test:grammar-fixed": "vscode-tmgrammar-snap -s source.fortran.fixed -g ./syntaxes/fortran_fixed-form.tmLanguage.json -t \"./test/**/*{.f,F}\"",
216+
"test:grammar": "npm run test:grammar-free && npm run test:grammar-fixed",
217+
"test:grammar-update": "npm run test:grammar -- -u",
216218
"lint": "node ./node_modules/tslint/bin/tslint ./src/**/*.ts "
217219
},
218220
"devDependencies": {

test/resources/fixed_form.F

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
* euclid.f (FORTRAN 77)
2+
* Find greatest common divisor using the Euclidean algorithm
3+
4+
PROGRAM EUCLID
5+
PRINT *, 'A?'
6+
READ *, NA
7+
IF (NA.LE.0) THEN
8+
PRINT *, 'A must be a positive integer.'
9+
STOP
10+
END IF
11+
PRINT *, 'B?'
12+
READ *, NB
13+
IF (NB.LE.0) THEN
14+
PRINT *, 'B must be a positive integer.'
15+
STOP
16+
END IF
17+
PRINT *, 'The GCD of', NA, ' and', NB, ' is', NGCD(NA, NB), '.'
18+
STOP
19+
END
20+
21+
FUNCTION NGCD(NA, NB)
22+
IA = NA
23+
IB = NB
24+
1 IF (IB.NE.0) THEN
25+
ITEMP = IA
26+
IA = IB
27+
IB = MOD(ITEMP, IB)
28+
GOTO 1
29+
END IF
30+
NGCD = IA
31+
RETURN
32+
END

test/resources/fixed_form.F.snap

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
>* euclid.f (FORTRAN 77)
2+
#^ source.fortran.fixed comment.line.fortran
3+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed comment.line.fortran
4+
>* Find greatest common divisor using the Euclidean algorithm
5+
#^ source.fortran.fixed comment.line.fortran
6+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed comment.line.fortran
7+
>
8+
> PROGRAM EUCLID
9+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
10+
# ^^^^^^^^^^^^^^^ source.fortran.fixed
11+
> PRINT *, 'A?'
12+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
13+
# ^^^^^^^^^^^^^^^^^ source.fortran.fixed
14+
> READ *, NA
15+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
16+
# ^^^^^^^^^^^^^^ source.fortran.fixed
17+
> IF (NA.LE.0) THEN
18+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
19+
# ^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
20+
> PRINT *, 'A must be a positive integer.'
21+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
22+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
23+
> STOP
24+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
25+
# ^^^^^^^^^^^ source.fortran.fixed
26+
> END IF
27+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
28+
# ^^^^^^^^^^ source.fortran.fixed
29+
> PRINT *, 'B?'
30+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
31+
# ^^^^^^^^^^^^^^^^^ source.fortran.fixed
32+
> READ *, NB
33+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
34+
# ^^^^^^^^^^^^^^ source.fortran.fixed
35+
> IF (NB.LE.0) THEN
36+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
37+
# ^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
38+
> PRINT *, 'B must be a positive integer.'
39+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
40+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
41+
> STOP
42+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
43+
# ^^^^^^^^^^^ source.fortran.fixed
44+
> END IF
45+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
46+
# ^^^^^^^^^^ source.fortran.fixed
47+
> PRINT *, 'The GCD of', NA, ' and', NB, ' is', NGCD(NA, NB), '.'
48+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
49+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
50+
> STOP
51+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
52+
# ^^^^^^^^ source.fortran.fixed
53+
> END
54+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
55+
# ^^^^ source.fortran.fixed
56+
>
57+
> FUNCTION NGCD(NA, NB)
58+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
59+
# ^^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
60+
> IA = NA
61+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
62+
# ^^^^^^^^^^^ source.fortran.fixed
63+
> IB = NB
64+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
65+
# ^^^^^^^^^^^ source.fortran.fixed
66+
> 1 IF (IB.NE.0) THEN
67+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
68+
# ^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
69+
> ITEMP = IA
70+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
71+
# ^^^^^^^^^^^^^^^^^ source.fortran.fixed
72+
> IA = IB
73+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
74+
# ^^^^^^^^^^^^^^ source.fortran.fixed
75+
> IB = MOD(ITEMP, IB)
76+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
77+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.fortran.fixed
78+
> GOTO 1
79+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
80+
# ^^^^^^^^^^^^^ source.fortran.fixed
81+
> END IF
82+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
83+
# ^^^^^^^^^^ source.fortran.fixed
84+
> NGCD = IA
85+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
86+
# ^^^^^^^^^^^^^ source.fortran.fixed
87+
> RETURN
88+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
89+
# ^^^^^^^^^^ source.fortran.fixed
90+
> END
91+
#^^^^^^ source.fortran.fixed constant.numeric.fortran
92+
# ^^^^ source.fortran.fixed
93+
>

0 commit comments

Comments
 (0)