/usr/share/enscript/hl/fortran.st is in enscript 1.6.5.90-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /**
* Name: fortran
* Description: Fortran77 programming language.
* Author: Keith Refson <Keith.Refson@earth.ox.ac.uk>
* Markku Rossi <mtr@iki.fi>
* edited by Joachim Kaiser <jhk@cmpnetmail.com>:
* - relational/logical operators and io specifiers (named added) with
* changed from keyword_face to builtin_face
* - type statement keywords changed from keyword_face to type_face
* - 'print' moved from keywords to io statements
* - distinguish between 'real' type statement and 'real' type conversion
* function
* - 'endfile', 'enddo' and 'while' removed from keyword list (not
* defined in FORTRAN 77), 'assign' added, 'else if' and 'end if' with
* optional blank before 'if'
* - comments only as complete lines starting with [cC\*] (FORTRAN 77)
* - case-insensitive regexp with the `i' option at the end of the regexp
*/
state fortran_string extends Highlight
{
/[\']/ {
language_print ($0);
debug ("Finishing fortran_string state.");
return;
}
}
state fortran_io extends Highlight
{
/\(/ {
language_print ($0);
parentheses_level++;
debug (concat("Parenthesis_level = ",string(parentheses_level)));
}
/\)/ {
language_print ($0);
parentheses_level--;
debug (concat("Parenthesis_level = ",string(parentheses_level)));
if (parentheses_level == 0) {
debug ("Finishing fortran_io state.");
return;
}
}
/* IO Specifiers.
(build-re '(FMT UNIT REC END ERR FILE STATUS ACCESS FORM RECL BLANK
IOSTAT EXIST OPENED NUMBER NAME NAMED SEQUENTIAL DIRECT FORMATTED
UNFORMATTED NEXTREC))
*/
/\b(ACCESS|BLANK|DIRECT|E(ND|RR|XIST)|F(ILE|MT|ORM(|ATTED))|IOSTAT\
|N(AMED?|EXTREC|UMBER)|OPENED|REC(|L)|S(EQUENTIAL|TATUS)\
|UN(FORMATTED|IT))\b/i {
debug (concat("This is an io specifier: ",$0));
builtin_face (true);
language_print ($0);
builtin_face (false);
}
/* String within io statement */
/[\']/ {
debug ("String in io statement found.");
string_face (true);
language_print ($0);
call (fortran_string);
string_face (false);
}
}
state fortran extends HighlightEntry
{
BEGIN {
parentheses_level = 0;
debug ("Starting fortran state.");
}
END {
debug ("Finishing fortran state.");
}
/* Comments. */
/^[cC\*]/ {
debug ("Comment line found.");
comment_face (true);
language_print ($0);
call (eat_one_line);
comment_face (false);
}
/* String constants. */
/[\']/ {
debug ("String constant found.");
string_face (true);
language_print ($0);
call (fortran_string);
string_face (false);
}
/* Relational/logical operators. We have to roll by hand because of the
dots - "\b" doesn't delimit here. */
/\.(AND|EQV?|G(E|T)|L(E|T)|NE(QV)?|NOT|OR)\./i {
debug (concat("This is an rel/log operator: ",$0));
builtin_face (true);
language_print ($0);
builtin_face (false);
}
/* IO Statement (build-re '(OPEN CLOSE READ PRINT
WRITE INQUIRE BACKSPACE ENDFILE REWIND )) */
/\b(BACKSPACE|CLOSE|ENDFILE|INQUIRE|OPEN|PRINT|RE(AD|WIND)|WRITE)(\(?)/i {
debug (concat("This is an io statement: ",$1));
keyword_face (true);
language_print ($1);
keyword_face (false);
if (strcmp ($3, "") != 0) {
language_print ($3);
parentheses_level=1;
call (fortran_io);
}
}
/* Type statements. */
/\b((CHARACTER|COMPLEX|INTEGER|LOGICAL|REAL)(\*([0-9]+|\())?\
|(DOUBLE *PRECISION))( *\(?[a-zA-Z0-9]+)/i {
debug (concat("This is a type statement: ",$2,$5));
type_face (true);
language_print ($2);
language_print ($5);
type_face (false);
language_print ($3);
next_word = $6;
if (regmatch (next_word, / *FUNCTION/i)) {
debug ("... for a function");
keyword_face (true);
language_print (next_word);
keyword_face (false);
} else {
language_print (next_word);
}
}
/* Keywords other than type and io statements.
(build-re '(ASSIGN BLOCK_sDATA CALL COMMON CONTINUE DATA DIMENSION DO
ELSE ELSE_sIF END END_sIF ENTRY EQUIVALENCE EXTERNAL FORMAT FUNCTION
GO_sTO IF IMPLICIT INCLUDE INTRINSIC PARAMETER PAUSE PROGRAM RETURN
SAVE STOP SUBROUTINE THEN ))
*/
/\b(ASSIGN|BLOCK \*DATA|C(ALL|O(MMON|NTINUE))|D(ATA|IMENSION|O)\
|E(LSE(| \*IF)|N(D(| \*IF)|TRY)|QUIVALENCE|XTERNAL)|F(ORMAT|UNCTION)\
|GO \*TO|I(F|MPLICIT|N(CLUDE|TRINSIC))|P(A(RAMETER|USE)|ROGRAM)|RETURN\
|S(AVE|TOP|UBROUTINE)|THEN)\b/i {
debug (concat("Other keyword found: ",$0));
keyword_face (true);
language_print ($0);
keyword_face (false);
}
}
/*
Local variables:
mode: c
End:
*/
|