aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-04-02 17:28:26 +0000
committerStefan Monnier2002-04-02 17:28:26 +0000
commit84021009d587d03689129324859a7ea0300fc231 (patch)
tree3d6a27cf70e5d74f40d3edfd0756811ffc35279c
parent5d12f14d6cf06731bf51c74e1a121b71b0297592 (diff)
downloademacs-84021009d587d03689129324859a7ea0300fc231.tar.gz
emacs-84021009d587d03689129324859a7ea0300fc231.zip
(f90-keywords-re, f90-keywords-level-3-re)
(f90-procedures-re, f90-operators-re, f90-hpf-keywords-re): Use regexp-opt. (f90-keywords-re, f90-keywords-level-3-re): Add `pure' and `elemental'. (f90-procedures-re): Add `null' and `cpu_time' from F95. (f90-font-lock-keywords-1): Minor reorganization so we don't need `override' any more. (f90-font-lock-keywords-3): Use `keep' rather than `override'. (f90-indent-subprogram): Use indent-region. (f90-break-line): Use indent-according-to-mode.
-rw-r--r--lisp/progmodes/f90.el203
1 files changed, 83 insertions, 120 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index 4bfd595eccd..c2f0c4686ef 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -236,143 +236,106 @@ whether to blink the matching beginning."
236 :group 'f90) 236 :group 'f90)
237 237
238(defconst f90-keywords-re 238(defconst f90-keywords-re
239 ;;("allocate" "allocatable" "assign" "assignment" "backspace" "block" 239 (regexp-opt '("allocatable" "allocate" "assign" "assignment" "backspace"
240 ;;"call" "case" "character" "close" "common" "complex" "contains" 240 "block" "call" "case" "character" "close" "common" "complex"
241 ;;"continue" "cycle" "data" "deallocate" "dimension" "do" "double" "else" 241 "contains" "continue" "cycle" "data" "deallocate"
242 ;;"elseif" "elsewhere" "end" "enddo" "endfile" "endif" "entry" "equivalence" 242 "dimension" "do" "double" "else" "elseif" "elsewhere" "end"
243 ;;"exit" "external" "forall" "format" "function" "goto" "if" "implicit" 243 "enddo" "endfile" "endif" "entry" "equivalence" "exit"
244 ;;"include" "inquire" "integer" "intent" "interface" "intrinsic" "logical" 244 "external" "forall" "format" "function" "goto" "if"
245 ;;"module" "namelist" "none" "nullify" "only" "open" "operator" "optional" "parameter" 245 "implicit" "include" "inquire" "integer" "intent"
246 ;;"pause" "pointer" "precision" "print" "private" "procedure" "program" 246 "interface" "intrinsic" "logical" "module" "namelist" "none"
247 ;;"public" "read" "real" "recursive" "result" "return" "rewind" "save" "select" 247 "nullify" "only" "open" "operator" "optional" "parameter"
248 ;;"sequence" "stop" "subroutine" "target" "then" "type" "use" "where" 248 "pause" "pointer" "precision" "print" "private" "procedure"
249 ;;"while" "write") 249 "program" "public" "read" "real" "recursive" "result" "return"
250 (concat 250 "rewind" "save" "select" "sequence" "stop" "subroutine"
251 "\\<\\(a\\(llocat\\(able\\|e\\)\\|ssign\\(\\|ment\\)\\)\\|b\\(ackspace\\|" 251 "target" "then" "type" "use" "where" "while" "write"
252 "lock\\)\\|c\\(a\\(ll\\|se\\)\\|haracter\\|lose\\|o\\(m\\(mon\\|plex\\)\\|" 252 ;; F95 keywords.
253 "nt\\(ains\\|inue\\)\\)\\|ycle\\)\\|d\\(ata\\|eallocate\\|imension\\|" 253 "elemental" "pure") 'words)
254 "o\\(\\|uble\\)\\)\\|e\\(lse\\(\\|if\\|where\\)\\|n\\(d\\(\\|do\\|file\\|"
255 "if\\)\\|try\\)\\|quivalence\\|x\\(it\\|ternal\\)\\)\\|f\\(or\\(all\\|"
256 "mat\\)\\|unction\\)\\|goto\\|i\\(f\\|mplicit\\|n\\(clude\\|quire\\|t\\("
257 "e\\(ger\\|nt\\|rface\\)\\|rinsic\\)\\)\\)\\|logical\\|module\\|n\\("
258 "amelist\\|one\\|ullify\\)\\|o\\(nly\\|p\\(en\\|erator\\|tional\\)\\)\\|p\\(a\\("
259 "rameter\\|use\\)\\|ointer\\|r\\(ecision\\|i\\(nt\\|vate\\)\\|o\\("
260 "cedure\\|gram\\)\\)\\|ublic\\)\\|re\\(a[dl]\\|cursive\\|sult\\|turn\\|wind\\)\\|"
261 "s\\(ave\\|e\\(lect\\|quence\\)\\|top\\|ubroutine\\)\\|t\\(arget\\|hen\\|"
262 "ype\\)\\|use\\|w\\(h\\(ere\\|ile\\)\\|rite\\)\\)\\>")
263 "Regexp for F90 keywords.") 254 "Regexp for F90 keywords.")
264 255
265(defconst f90-keywords-level-3-re 256(defconst f90-keywords-level-3-re
266 ;; ("allocate" "allocatable" "assign" "assignment" "backspace" "close" 257 (regexp-opt
267 ;; "deallocate" "dimension" "endfile" "entry" "equivalence" "external" 258 '("allocatable" "allocate" "assign" "assignment" "backspace"
268 ;; "inquire" "intent" "intrinsic" "nullify" "only" "open" "operator" 259 "close" "deallocate" "dimension" "endfile" "entry" "equivalence"
269 ;; "optional" "parameter" "pause" "pointer" "print" "private" "public" 260 "external" "inquire" "intent" "intrinsic" "nullify" "only" "open"
270 ;; "read" "recursive" "result" "rewind" "save" "select" "sequence" 261 "operator" "optional" "parameter" "pause" "pointer" "print" "private"
271 ;; "target" "write") 262 "public" "read" "recursive" "result" "rewind" "save" "select"
272 (concat 263 "sequence" "target" "write"
273 "\\<\\(a\\(llocat\\(able\\|e\\)\\|ssign\\(\\|ment\\)\\)\\|backspace\\|" 264 ;; F95 keywords.
274 "close\\|d\\(eallocate\\|imension\\)\\|e\\(n\\(dfile\\|try\\)\\|" 265 "elemental" "pure") 'words)
275 "quivalence\\|xternal\\)\\|" 266 "Keyword-regexp for font-lock level >= 3.")
276 "in\\(quire\\|t\\(ent\\|rinsic\\)\\)\\|nullify\\|"
277 "o\\(nly\\|p\\(en\\|erator\\|tional\\)\\)\\|"
278 "p\\(a\\(rameter\\|use\\)\\|ointer\\|ri\\(nt\\|vate\\)\\|ublic\\)\\|re\\("
279 "ad\\|cursive\\|sult\\|wind\\)\\|s\\(ave\\|e\\(lect\\|quence\\)\\)\\|target\\|"
280 "write\\)\\>")
281"Keyword-regexp for font-lock level >= 3.")
282 267
283 268
284(defconst f90-procedures-re 269(defconst f90-procedures-re
285 ;; ("abs" "achar" "acos" "adjustl" "adjustr" "aimag" "aint" "all" "allocated" 270 (concat "\\<"
286 ;; "anint" "any" "asin" "associated" "atan" "atan2" "bit_size" "btest" 271 (regexp-opt
287 ;; "ceiling" "char" "cmplx" "conjg" "cos" "cosh" "count" "cshift" 272 '("abs" "achar" "acos" "adjustl" "adjustr" "aimag" "aint"
288 ;; "date_and_time" "dble" "digits" "dim" "dot_product" "dprod" "eoshift" 273 "all" "allocated" "anint" "any" "asin" "associated"
289 ;; "epsilon" "exp" "exponent" "floor" "fraction" "huge" "iachar" "iand" 274 "atan" "atan2" "bit_size" "btest" "ceiling" "char" "cmplx"
290 ;; "ibclr" "ibits" "ibset" "ichar" "ieor" "index" "int" "ior" "ishft" 275 "conjg" "cos" "cosh" "count" "cshift" "date_and_time" "dble"
291 ;; "ishftc" "kind" "lbound" "len" "len_trim" "lge" "lgt" "lle" "llt" "log" 276 "digits" "dim" "dot_product" "dprod" "eoshift" "epsilon"
292 ;; "logical" "log10" "matmul" "max" "maxexponent" "maxloc" "maxval" "merge" 277 "exp" "exponent" "floor" "fraction" "huge" "iachar" "iand"
293 ;; "min" "minexponent" "minloc" "minval" "mod" "modulo" "mvbits" "nearest" 278 "ibclr" "ibits" "ibset" "ichar" "ieor" "index" "int" "ior"
294 ;; "nint" "not" "pack" "precision" "present" "product" "radix" 279 "ishft" "ishftc" "kind" "lbound" "len" "len_trim" "lge" "lgt"
295 ;; "random_number" "random_seed" "range" "real" "repeat" "reshape" 280 "lle" "llt" "log" "log10" "logical" "matmul" "max"
296 ;; "rrspacing" "scale" "scan" "selected_int_kind" "selected_real_kind" 281 "maxexponent" "maxloc" "maxval" "merge" "min" "minexponent"
297 ;; "set_exponent" "shape" "sign" "sin" "sinh" "size" "spacing" "spread" 282 "minloc" "minval" "mod" "modulo" "mvbits" "nearest" "nint"
298 ;; "sqrt" "sum" "system_clock" "tan" "tanh" "tiny" "transfer" "transpose" 283 "not" "pack" "precision" "present" "product" "radix"
299 ;; "trim" "ubound" "unpack" "verify") 284 ;; Real is taken out here to avoid highlighting declarations.
300 ;; A left parenthesis to avoid highlighting non-procedures. 285 "random_number" "random_seed" "range" ;; "real"
301 ;; Real is taken out here to avoid highlighting declarations. 286 "repeat" "reshape" "rrspacing" "scale" "scan"
302 (concat 287 "selected_int_kind" "selected_real_kind" "set_exponent"
303 "\\<\\(a\\(bs\\|c\\(har\\|os\\)\\|djust[lr]\\|i\\(mag\\|nt\\)\\|ll\\(\\|" 288 "shape" "sign" "sin" "sinh" "size" "spacing" "spread" "sqrt"
304 "ocated\\)\\|n\\(int\\|y\\)\\|s\\(in\\|sociated\\)\\|tan2?\\)\\|b\\(" 289 "sum" "system_clock" "tan" "tanh" "tiny" "transfer"
305 "it_size\\|test\\)\\|c\\(eiling\\|har\\|mplx\\|o\\(njg\\|sh?\\|unt\\)\\|" 290 "transpose" "trim" "ubound" "unpack" "verify"
306 "shift\\)\\|d\\(ate_and_time\\|ble\\|i\\(gits\\|m\\)\\|ot_product\\|prod" 291 ;; F95 intrinsic functions.
307 "\\)\\|e\\(oshift\\|psilon\\|xp\\(\\|onent\\)\\)\\|f\\(loor\\|" 292 "null" "cpu_time") t)
308 "raction\\)\\|huge\\|i\\(a\\(char\\|nd\\)\\|b\\(clr\\|its\\|set\\)\\|" 293 ;; A left parenthesis to avoid highlighting non-procedures.
309 "char\\|eor\\|n\\(dex\\|t\\)\\|or\\|shftc?\\)\\|kind\\|l\\(bound\\|" 294 "[ \t]*(")
310 "en\\(\\|_trim\\)\\|g[et]\\|l[et]\\|og\\(\\|10\\|ical\\)\\)\\|m\\(a\\("
311 "tmul\\|x\\(\\|exponent\\|loc\\|val\\)\\)\\|erge\\|in\\(\\|exponent\\|"
312 "loc\\|val\\)\\|od\\(\\|ulo\\)\\|vbits\\)\\|n\\(earest\\|int\\|ot\\)\\|"
313 "p\\(ack\\|r\\(e\\(cision\\|sent\\)\\|oduct\\)\\)\\|r\\(a\\(dix\\|n\\("
314 "dom_\\(number\\|seed\\)\\|ge\\)\\)\\|e\\(peat\\|shape\\)\\|rspacing\\)\\|"
315 "s\\(ca\\(le\\|n\\)\\|e\\(lected_\\(int_kind\\|real_kind\\)\\|"
316 "t_exponent\\)\\|hape\\|i\\(gn\\|nh?\\|ze\\)\\|p\\(acing\\|read\\)\\|"
317 "qrt\\|um\\|ystem_clock\\)\\|t\\(anh?\\|iny\\|r\\(ans\\(fer\\|pose\\)\\|"
318 "im\\)\\)\\|u\\(bound\\|npack\\)\\|verify\\)[ \t]*(")
319 "Regexp whose first part matches F90 intrinsic procedures.") 295 "Regexp whose first part matches F90 intrinsic procedures.")
320 296
321(defconst f90-operators-re 297(defconst f90-operators-re
322;; "and" "or" "not" "eqv" "neqv" "eq" "ne" "lt" "le" "gt" "ge" "true" "false" 298 (concat "\\."
323 (concat 299 (regexp-opt '("and" "eq" "eqv" "false" "ge" "gt" "le" "lt" "ne"
324 "\\.\\(and\\|eqv?\\|false\\|g[et]\\|l[et]\\|n\\(e\\(\\|qv\\)\\|" 300 "neqv" "not" "or" "true") t)
325 "ot\\)\\|or\\|true\\)\\.") 301 "\\.")
326 "Regexp matching intrinsic operators.") 302 "Regexp matching intrinsic operators.")
327 303
328(defconst f90-hpf-keywords-re 304(defconst f90-hpf-keywords-re
329 ;; Intrinsic procedures 305 (regexp-opt
330 ;; ("all_prefix" "all_scatter" "all_suffix" "any_prefix" "any_scatter" 306 ;; Intrinsic procedures
331 ;; "any_suffix" "copy_prefix" "copy_scatter" "copy_suffix" "count_prefix" 307 '("all_prefix" "all_scatter" "all_suffix" "any_prefix"
332 ;; "count_scatter" "count_suffix" "grade_down" "grade_up" "hpf_alignment" 308 "any_scatter" "any_suffix" "copy_prefix" "copy_scatter"
333 ;; "hpf_template" "hpf_distribution" "iall" "iall_prefix" "iall_scatter" 309 "copy_suffix" "count_prefix" "count_scatter" "count_suffix"
334 ;; "iall_suffix" "iany" "iany_prefix" "iany_scatter" "iany_suffix" "iparity" 310 "grade_down" "grade_up"
335 ;; "iparity_prefix" "iparity_scatter" "iparity_suffix" "leadz" 311 "hpf_alignment" "hpf_distribution" "hpf_template" "iall" "iall_prefix"
336 ;; "maxval_prefix" "maxval_scatter" "maxval_suffix" "minval_prefix" 312 "iall_scatter" "iall_suffix" "iany" "iany_prefix" "iany_scatter"
337 ;; "minval_scatter" "minval_suffix" "parity" "parity_prefix" 313 "iany_suffix" "ilen" "iparity" "iparity_prefix"
338 ;; "parity_scatter" "parity_suffix" "popcnt" "poppar" "product_prefix" 314 "iparity_scatter" "iparity_suffix" "leadz" "maxval_prefix"
339 ;; "product_scatter" "product_suffix" "sum_prefix" "sum_scatter" 315 "maxval_scatter" "maxval_suffix" "minval_prefix" "minval_scatter"
340 ;; "sum_suffix" "ilen" "number_of_processors" "processors_shape") 316 "minval_suffix" "number_of_processors" "parity"
341 ;; Directives 317 "parity_prefix" "parity_scatter" "parity_suffix" "popcnt" "poppar"
342 ;; ("align" "distribute" "dynamic" "inherit" "template" "processors" 318 "processors_shape" "product_prefix" "product_scatter"
343 ;; "realign" "redistribute" "independent") 319 "product_suffix" "sum_prefix" "sum_scatter" "sum_suffix"
344 ;; Keywords 320 ;; Directives
345 ;; ("pure" "extrinsic" "new" "with" "onto" "block" "cyclic") 321 "align" "distribute" "dynamic" "independent" "inherit" "processors"
346 (concat 322 "realign" "redistribute" "template"
347 "\\<\\(a\\(l\\(ign\\|l_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|ny_\\(" 323 ;; Keywords
348 "prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|block\\|c\\(o\\(py_\\(prefix\\|" 324 "block" "cyclic" "extrinsic" "new" "onto" "pure" "with") 'words)
349 "s\\(catter\\|uffix\\)\\)\\|unt_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|"
350 "yclic\\)\\|d\\(istribute\\|ynamic\\)\\|extrinsic\\|grade_\\(down\\|"
351 "up\\)\\|hpf_\\(alignment\\|distribution\\|template\\)\\|i\\(a\\(ll\\(\\|"
352 "_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|ny\\(\\|_\\(prefix\\|s\\("
353 "catter\\|uffix\\)\\)\\)\\)\\|len\\|n\\(dependent\\|herit\\)\\|parity\\(\\|"
354 "_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\)\\|leadz\\|m\\(axval_\\("
355 "prefix\\|s\\(catter\\|uffix\\)\\)\\|inval_\\(prefix\\|s\\(catter\\|"
356 "uffix\\)\\)\\)\\|n\\(ew\\|umber_of_processors\\)\\|onto\\|p\\(arity\\(\\|"
357 "_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|op\\(cnt\\|par\\)\\|ro\\("
358 "cessors\\(\\|_shape\\)\\|duct_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|"
359 "ure\\)\\|re\\(align\\|distribute\\)\\|sum_\\(prefix\\|s\\(catter\\|"
360 "uffix\\)\\)\\|template\\|with\\)\\>")
361 "Regexp for all HPF keywords, procedures and directives.") 325 "Regexp for all HPF keywords, procedures and directives.")
362 326
363;; Highlighting patterns 327;; Highlighting patterns
364 328
365(defvar f90-font-lock-keywords-1 329(defvar f90-font-lock-keywords-1
366 (list 330 (list
367 '("\\<\\(end[ \t]*\\(program\\|module\\|function\\|subroutine\\|type\\)\\)\\>[ \t]*\\(\\sw+\\)?"
368 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
369 '("\\<\\(program\\|call\\|module\\|subroutine\\|function\\|use\\)\\>[ \t]*\\(\\sw+\\)?"
370 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
371 ;; Special highlighting of "module procedure foo-list" 331 ;; Special highlighting of "module procedure foo-list"
372 '("\\<\\(module[ \t]*procedure\\)\\>" (1 font-lock-keyword-face t)) 332 '("\\<\\(module[ \t]*procedure\\)\\>" (1 font-lock-keyword-face))
373 ;; Highlight definition of new type 333 ;; Highlight definition of new type
374 '("\\<\\(type\\)[ \t]*\\(.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)" 334 '("\\<\\(type\\)[ \t]*\\(.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)"
375 (1 font-lock-keyword-face) (3 font-lock-function-name-face)) 335 (1 font-lock-keyword-face) (3 font-lock-function-name-face))
336 ;; Other functions and declarations.
337 '("\\<\\(\\(?:end[ \t]*\\)?\\(program\\|module\\|function\\|subroutine\\|type\\)\\|use\\|call\\)\\>[ \t]*\\(\\sw+\\)?"
338 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
376 "\\<\\(\\(end[ \t]*\\)?\\(interface\\|block[ \t]*data\\)\\|contains\\)\\>") 339 "\\<\\(\\(end[ \t]*\\)?\\(interface\\|block[ \t]*data\\)\\|contains\\)\\>")
377 "This does fairly subdued highlighting of comments and function calls.") 340 "This does fairly subdued highlighting of comments and function calls.")
378 341
@@ -406,8 +369,8 @@ whether to blink the matching beginning."
406 (list 369 (list
407 f90-keywords-level-3-re 370 f90-keywords-level-3-re
408 f90-operators-re 371 f90-operators-re
409 (list f90-procedures-re '(1 font-lock-keyword-face t)) 372 (list f90-procedures-re '(1 font-lock-keyword-face keep))
410 "\\<real\\>" ; Avoid overwriting real defs. 373 "\\<real\\>" ; Avoid overwriting real defs.
411 )) 374 ))
412 "Highlights all F90 keywords and intrinsic procedures.") 375 "Highlights all F90 keywords and intrinsic procedures.")
413 376
@@ -1454,11 +1417,11 @@ If run in the middle of a line, the line is not broken."
1454 (progn 1417 (progn
1455 (message "Indenting %s %s..." 1418 (message "Indenting %s %s..."
1456 (car program) (car (cdr program))) 1419 (car program) (car (cdr program)))
1457 (f90-indent-region (point) (mark)) 1420 (indent-region (point) (mark))
1458 (message "Indenting %s %s...done" 1421 (message "Indenting %s %s...done"
1459 (car program) (car (cdr program)))) 1422 (car program) (car (cdr program))))
1460 (message "Indenting the whole file...") 1423 (message "Indenting the whole file...")
1461 (f90-indent-region (point) (mark)) 1424 (indent-region (point) (mark))
1462 (message "Indenting the whole file...done"))))) 1425 (message "Indenting the whole file...done")))))
1463 1426
1464;; autofill and break-line 1427;; autofill and break-line
@@ -1476,7 +1439,7 @@ If run in the middle of a line, the line is not broken."
1476 (if (not no-update) (f90-update-line)) 1439 (if (not no-update) (f90-update-line))
1477 (newline 1) 1440 (newline 1)
1478 (if f90-beginning-ampersand (insert "&"))))) 1441 (if f90-beginning-ampersand (insert "&")))))
1479 (f90-indent-line)) 1442 (indent-according-to-mode))
1480 1443
1481(defun f90-find-breakpoint () 1444(defun f90-find-breakpoint ()
1482 "From fill-column, search backward for break-delimiter." 1445 "From fill-column, search backward for break-delimiter."