25
James McDermott §
source link: http://jmmcd.net/2017/10/13/mosel-mode.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
mosel-mode
Mosel is a language for defining LP and IP models, used by Xpress-MP among other solvers. I couldn’t find an Emacs mode for editing Mosel, so here’s a small contribution which does some syntax highlighting. It also lives at EmacsWiki.
(define-generic-mode 'mosel-mode
;; comment characters
'("!")
'("model" "end-model" "uses" "declarations" "end-declarations" "writeln" "case" "end-case" "else" "in" "array" "of" "getsol" "getsensrng" "getobjval" "is_integer") ;; keywords
'(
("(!.*?\\(\n.*?\\)*?!)" . 'font-lock-comment-face) ;; the RE is right but it seems to fail for blocks longer than a few lines
(";" . 'font-lock-builtin-face)
(":=" . 'font-lock-builtin-face)
("::" . 'font-lock-builtin-face)
("\\.\\." . 'font-lock-builtin-face)
("<=" . 'font-lock-builtin-face)
(">=" . 'font-lock-builtin-face)
("=" . 'font-lock-builtin-face)
(":" . 'font-lock-builtin-face)
("linctr" . 'font-lock-function-name-face)
("mpvar" . 'font-lock-function-name-face)
("real" . 'font-lock-function-name-face)
("integer" . 'font-lock-function-name-face)
("string" . 'font-lock-function-name-face)
("sum" . 'font-lock-function-name-face)
("forall" . 'font-lock-function-name-face)
("end-procedure" . 'font-lock-function-name-face)
("procedure" . 'font-lock-function-name-face)
("end-function" . 'font-lock-function-name-face)
("function" . 'font-lock-function-name-face)
("maximize" . 'font-lock-function-name-face)
("minimize" . 'font-lock-function-name-face)
("XPRS_OPT" . 'font-lock-constant-face)
("XPRS_UNF" . 'font-lock-constant-face)
("XPRS_INF" . 'font-lock-constant-face)
("XPRS_UNB" . 'font-lock-constant-face)
("XPRS_OTH" . 'font-lock-constant-face)
)
'("\\.mos\\'") ;; filename suffix
nil ;; extra function hooks
"Major mode for Mosel highlighting.")
Installation
Paste it into your .emacs
file and execute it with C-x C-e
. When
you edit a .mos
file, it will automatically go into mosel-mode
.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK