3 * Description: Fortran77 programming language.
4 * Author: Keith Refson <Keith.Refson@earth.ox.ac.uk>
5 * Markku Rossi <mtr@iki.fi>
6 * edited by Joachim Kaiser <jhk@cmpnetmail.com>:
7 * - relational/logical operators and io specifiers (named added) with
8 * changed from keyword_face to builtin_face
9 * - type statement keywords changed from keyword_face to type_face
10 * - 'print' moved from keywords to io statements
11 * - distinguish between 'real' type statement and 'real' type conversion
13 * - 'endfile', 'enddo' and 'while' removed from keyword list (not
14 * defined in FORTRAN 77), 'assign' added, 'else if' and 'end if' with
15 * optional blank before 'if'
16 * - comments only as complete lines starting with [cC\*] (FORTRAN 77)
17 * - case-insensitive regexp with the `i' option at the end of the regexp
20 state fortran_string extends Highlight
24 debug ("Finishing fortran_string state.");
29 state fortran_io extends Highlight
34 debug (concat("Parenthesis_level = ",string(parentheses_level)));
40 debug (concat("Parenthesis_level = ",string(parentheses_level)));
41 if (parentheses_level == 0) {
42 debug ("Finishing fortran_io state.");
48 (build-re '(FMT UNIT REC END ERR FILE STATUS ACCESS FORM RECL BLANK
49 IOSTAT EXIST OPENED NUMBER NAME NAMED SEQUENTIAL DIRECT FORMATTED
52 /\b(ACCESS|BLANK|DIRECT|E(ND|RR|XIST)|F(ILE|MT|ORM(|ATTED))|IOSTAT\
53 |N(AMED?|EXTREC|UMBER)|OPENED|REC(|L)|S(EQUENTIAL|TATUS)\
54 |UN(FORMATTED|IT))\b/i {
55 debug (concat("This is an io specifier: ",$0));
61 /* String within io statement */
63 debug ("String in io statement found.");
66 call (fortran_string);
71 state fortran extends HighlightEntry
74 parentheses_level = 0;
75 debug ("Starting fortran state.");
79 debug ("Finishing fortran state.");
84 debug ("Comment line found.");
91 /* String constants. */
93 debug ("String constant found.");
96 call (fortran_string);
100 /* Relational/logical operators. We have to roll by hand because of the
101 dots - "\b" doesn't delimit here. */
102 /\.(AND|EQV?|G(E|T)|L(E|T)|NE(QV)?|NOT|OR)\./i {
103 debug (concat("This is an rel/log operator: ",$0));
106 builtin_face (false);
109 /* IO Statement (build-re '(OPEN CLOSE READ PRINT
110 WRITE INQUIRE BACKSPACE ENDFILE REWIND )) */
111 /\b(BACKSPACE|CLOSE|ENDFILE|INQUIRE|OPEN|PRINT|RE(AD|WIND)|WRITE)(\(?)/i {
112 debug (concat("This is an io statement: ",$1));
115 keyword_face (false);
116 if (strcmp ($3, "") != 0) {
123 /* Type statements. */
124 /\b((CHARACTER|COMPLEX|INTEGER|LOGICAL|REAL)(\*([0-9]+|\())?\
125 |(DOUBLE *PRECISION))( *\(?[a-zA-Z0-9]+)/i {
126 debug (concat("This is a type statement: ",$2,$5));
133 if (regmatch (next_word, / *FUNCTION/i)) {
134 debug ("... for a function");
136 language_print (next_word);
137 keyword_face (false);
139 language_print (next_word);
143 /* Keywords other than type and io statements.
144 (build-re '(ASSIGN BLOCK_sDATA CALL COMMON CONTINUE DATA DIMENSION DO
145 ELSE ELSE_sIF END END_sIF ENTRY EQUIVALENCE EXTERNAL FORMAT FUNCTION
146 GO_sTO IF IMPLICIT INCLUDE INTRINSIC PARAMETER PAUSE PROGRAM RETURN
147 SAVE STOP SUBROUTINE THEN ))
149 /\b(ASSIGN|BLOCK \*DATA|C(ALL|O(MMON|NTINUE))|D(ATA|IMENSION|O)\
150 |E(LSE(| \*IF)|N(D(| \*IF)|TRY)|QUIVALENCE|XTERNAL)|F(ORMAT|UNCTION)\
151 |GO \*TO|I(F|MPLICIT|N(CLUDE|TRINSIC))|P(A(RAMETER|USE)|ROGRAM)|RETURN\
152 |S(AVE|TOP|UBROUTINE)|THEN)\b/i {
153 debug (concat("Other keyword found: ",$0));
156 keyword_face (false);