1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<h1>Fortran</h1>
<p>To use this language, use the class "language-fortran".</p>
<h2>Comments</h2>
<pre><code>! This is a comment</code></pre>
<h2>Strings</h2>
<pre><code>"foo 'bar' baz"
'foo ''bar'' baz'
''
ITALICS_'This is in italics'
"test &
! Some "tricky comment" here
&test"</code></pre>
<h2>Numbers</h2>
<pre><code>473
+56
-101
21_2
21_SHORT
1976354279568241_8
B'01110'
B"010"
O'047'
O"642"
Z'F41A'
Z"00BC"
-12.78
+1.6E3
2.1
-16.E4_8
0.45E-4
10.93E7_QUAD
.123
3E4</code></pre>
<h2>Full example</h2>
<pre><code>MODULE MOD1
TYPE INITIALIZED_TYPE
INTEGER :: I = 1 ! Default initialization
END TYPE INITIALIZED_TYPE
SAVE :: SAVED1, SAVED2
INTEGER :: SAVED1, UNSAVED1
TYPE(INITIALIZED_TYPE) :: SAVED2, UNSAVED2
ALLOCATABLE :: SAVED1(:), SAVED2(:), UNSAVED1(:), UNSAVED2(:)
END MODULE MOD1
PROGRAM MAIN
CALL SUB1 ! The values returned by the ALLOCATED intrinsic calls
! in the PRINT statement are:
! .FALSE., .FALSE., .FALSE., and .FALSE.
! Module MOD1 is used, and its variables are allocated.
! After return from the subroutine, whether the variables
! which were not specified with the SAVE attribute
! retain their allocation status is processor dependent.
CALL SUB1 ! The values returned by the first two ALLOCATED intrinsic
! calls in the PRINT statement are:
! .TRUE., .TRUE.
! The values returned by the second two ALLOCATED
! intrinsic calls in the PRINT statement are
! processor dependent and each could be either
! .TRUE. or .FALSE.
CONTAINS
SUBROUTINE SUB1
USE MOD1 ! Brings in saved and not saved variables.
PRINT *, ALLOCATED(SAVED1), ALLOCATED(SAVED2), &
ALLOCATED(UNSAVED1), ALLOCATED(UNSAVED2)
IF (.NOT. ALLOCATED(SAVED1)) ALLOCATE(SAVED1(10))
IF (.NOT. ALLOCATED(SAVED2)) ALLOCATE(SAVED2(10))
IF (.NOT. ALLOCATED(UNSAVED1)) ALLOCATE(UNSAVED1(10))
IF (.NOT. ALLOCATED(UNSAVED2)) ALLOCATE(UNSAVED2(10))
END SUBROUTINE SUB1
END PROGRAM MAIN</code></pre>
<h2>Known failures</h2>
<p>There are certain edge cases where Prism will fail.
There are always such cases in every regex-based syntax highlighter.
However, Prism dares to be open and honest about them.
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
</p>
<h3>Commented string</h3>
<pre><code>! This "string" should not be highlighted</code></pre>