Commit 3b0d1a50 authored by Glenn Morris's avatar Glenn Morris

f90: handle F2008 module function

* lisp/progmodes/f90.el (f90-font-lock-keywords-1)
Handle F2008 "module function" and subroutine.  (Bug#38415)
* test/lisp/progmodes/f90-tests.el (f90-test-bug38415): New test.
parent 55803cc1
......@@ -539,8 +539,10 @@ type-name parts, respectively."
read\\|write\\)\\)[ \t]*(" (1 font-lock-keyword-face t))
;; Other functions and declarations. Named interfaces = F2003.
;; F2008: end submodule submodule_name.
'("\\_<\\(\\(?:end[ \t]*\\)?\\(program\\|\\(?:sub\\)?module\\|\
;; F2008: module function|subroutine NAME.
'("\\_<\\(\\(?:end[ \t]*\\)?\\(program\\|\
\\(?:module[ \t]*\\)?\\(?:function\\|subroutine\\)\\|\
\\_>[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
(1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
;; F2008: submodule (parent_name) submodule_name.
......@@ -1381,14 +1383,19 @@ write\\)[ \t]*([^)\n]*)")
((looking-at "\\(program\\)[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>")
(list (match-string 1) (match-string 2)))
((and (not (looking-at "module[ \t]*procedure\\_>"))
((and (not (looking-at "module[ \t]*\\(procedure\\|function\\|subroutine\\)\\_>"))
(looking-at "\\(module\\)[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>"))
(list (match-string 1) (match-string 2)))
((looking-at "\\(submodule\\)[ \t]*([^)\n]+)[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>")
(list (match-string 1) (match-string 2)))
((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)"))
(looking-at "[^!'\"&\n]*\\(function\\|subroutine\\)[ \t]+\
((and (not (looking-at "end[ \t]*\\(function\\|procedure\\|subroutine\\)"))
(looking-at "[^!'\"&\n]*\\(?:module[ \t]*\\)?\
\\(function\\|subroutine\\)[ \t]+\
;; TODO: In F2008 "module procedure foo" may or may not start a block,
;; It is impossible to tell the difference without parsing state.
;;; (looking-at "[^!'\"&\n]*module[ \t]*\\(procedure\\)[ \t]+\
(list (match-string 1) (match-string 2)))))
;; Following will match an un-named main program block; however
;; one needs to check if there is an actual PROGRAM statement after
......@@ -277,4 +277,24 @@ end program prog")
(forward-line -2)
(should (= 2 (current-indentation))))) ; type is
(ert-deftest f90-test-bug38415 ()
"Test for ."
(setq-local f90-smart-end 'no-blink)
(insert "module function foo(x)
real :: x
(should (equal " function foo"
(buffer-substring (point) (line-end-position))))
(goto-char (point-max))
(insert "\nmodule subroutine bar(x)
real :: x
(should (equal " subroutine bar"
(buffer-substring (point) (line-end-position))))))
;;; f90-tests.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment