-(let ((comment-chars "cd\\*") ; `d' for `debugging' comments
- (fortran-type-types
- (eval-when-compile
- (let ((re (regexp-opt
- (let ((simple-types
- '("character" "byte" "integer" "logical"
- "none" "real" "complex"
- "double precision" "double complex"))
- (structured-types '("structure" "union" "map"))
- (other-types '("record" "dimension"
- "parameter" "common" "save"
- "external" "intrinsic" "data"
- "equivalence")))
- (append
- (mapcar (lambda (x) (concat "implicit " x))
- simple-types)
- simple-types
- (mapcar (lambda (x) (concat "end " x))
- structured-types)
- structured-types
- other-types)))))
- ;; In the optimized regexp above, replace spaces by a
- ;; regexp for optional whitespace; regexp-opt would have
- ;; escaped that.
- (mapconcat #'identity (split-string re) "[ \t]*"))))
- (fortran-keywords
- (eval-when-compile
- (regexp-opt '("continue" "format" "end" "enddo" "if" "then"
- "else" "endif" "elseif" "while" "inquire" "stop"
- "return" "include" "open" "close" "read" "write"
- "format" "print" "select" "case" "cycle" "exit"
- "rewind" "backspace"))))
- (fortran-logicals
- (eval-when-compile
- (regexp-opt '("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne"
- "true" "false")))))
- (setq fortran-font-lock-syntactic-keywords
- ;; Fixed format comments. (!-style handled normally.)
- (list
- (list (concat "^[" comment-chars "]") 0 '(11))
- (list (concat "^[^" comment-chars "\t\n]" ".\\{71\\}"
- "\\([^\n]+\\)")
- 1 '(11))))
- (setq fortran-font-lock-keywords-1
- (list
- ;; Program, subroutine and function declarations, plus calls.
- (list (concat "\\<\\(block[ \t]*data\\|call\\|entry\\|function\\|"
- "program\\|subroutine\\)\\>[ \t]*\\(\\sw+\\)?")
- '(1 font-lock-keyword-face)
- '(2 font-lock-function-name-face nil t))))
- (setq fortran-font-lock-keywords-2
- (append fortran-font-lock-keywords-1
- (list
- ;; Fontify all type specifiers (must be first; see below).
- (cons (concat "\\<\\(" fortran-type-types "\\)\\>")
- 'font-lock-type-face)
- ;; Fontify all builtin keywords (except logical, do
- ;; and goto; see below).
- (concat "\\<\\(" fortran-keywords "\\)\\>")
- ;; Fontify all builtin operators.
- (concat "\\.\\(" fortran-logicals "\\)\\.")
- ;; Fontify do/goto keywords and targets, and goto tags.
- (list "\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)?"
- '(1 font-lock-keyword-face)
- '(2 font-lock-constant-face nil t))
- (cons "^ *\\([0-9]+\\)" 'font-lock-constant-face))))
- (setq fortran-font-lock-keywords-3
- (append
- ;; The list `fortran-font-lock-keywords-1'.
- fortran-font-lock-keywords-1
- ;; Fontify all type specifiers plus their declared items.
- (list
- (list (concat "\\<\\(" fortran-type-types "\\)\\>[ \t(/]*\\(*\\)?")
- ;; Fontify the type specifier.
- '(1 font-lock-type-face)
- ;; Fontify each declaration item (or just the /.../ block name).
- `(font-lock-match-c-style-declaration-item-and-skip-to-next
- ;; Start after any *(...) expression.
- (condition-case nil
- (and (and (match-beginning ,(+ 2 (regexp-opt-depth
- fortran-type-types)))
- (forward-sexp))
- (forward-sexp))
- (error nil))
- ;; No need to clean up.
- nil
- ;; Fontify as a variable name, functions are
- ;; fontified elsewhere.
- (1 font-lock-variable-name-face nil t))))
- ;; Things extra to `fortran-font-lock-keywords-3'
- ;; (must be done first).
- (list
- ;; Fontify goto-like `err=label'/`end=label' in read/write
- ;; statements.
- '(", *\\(e\\(nd\\|rr\\)\\)\\> *\\(= *\\([0-9]+\\)\\)?"
- (1 font-lock-keyword-face) (4 font-lock-constant-face nil t))
- ;; Highlight standard continuation character and in a
- ;; TAB-formatted line.
- '("^ \\([^ 0]\\)" 1 font-lock-string-face)
- '("^\t\\([1-9]\\)" 1 font-lock-string-face))
- (list
- ;; cpp stuff (ugh)
-;;; '("^# *[a-z]+" . font-lock-keyword-face))
- `(,fortran-directive-re (0 font-lock-keyword-face t)))
- ;; The list `fortran-font-lock-keywords-2' less that for types
- ;; (see above).
- (cdr (nthcdr (length fortran-font-lock-keywords-1)
- fortran-font-lock-keywords-2)))))
-