dol-mode.el revision 453058446f4b25ac85504960f6aaf8d9e4bc1a9b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;;;###autoload
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina(autoload 'turn-on-dol-indent "dol-indent" "Turn on DOL indentation." t)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;;;;;;;;;;;;;;;;;;;;;;;;;;
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; Copyright: (c) University of Magdeburg, 2007-2016
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; License: LGPL, see LICENSE.txt or LIZENZ.txt
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; Contact: hets-users@informatik.uni-bremen.de
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;;;;;;;;;;;;;;;;;;;;;;;;;;
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; Version number
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "Version of DOL-Mode")
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "Major mode for editing (heterogeneous) DOL specifications."
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina(defvar dol-mode-map (let ((keymap (make-keymap)))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (define-key keymap "\C-c\C-r" 'dol-run-hets-r)
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel Březina (define-key keymap "\C-c\C-u" 'dol-run-hets-g)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (define-key keymap "\C-c\C-c" 'dol-run-hets-g))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (define-key keymap "\C-c\C-n" 'dol-compile-goto-next-error)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "Keymap for DOL major mode")
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina;; Are we running FSF Emacs or XEmacs?
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina "non-nil if we are running XEmacs, nil otherwise.")
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; ====================== S Y N T A X T A B L E ==================
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; Syntax table for DOL major mode
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "Syntax table for DOL mode.")
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; Indicate that underscore may be part of a word
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; Some of these are actually OK by default.
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "!#$&*+.,/\\\\:<=>?@^|~")
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; commenting-out plus including other kinds of comment
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina;; Various mode variables.
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (setq comment-start-skip "%[{[]") ;; %[%{[]() *")
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (setq comment-indent-function 'dol-comment-indent)
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov (set (make-local-variable 'comment-end-skip) "[\]}]%")
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina;; Find the indentation level for a comment.
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; if the line is blank, put the comment at the beginning,
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; else at comment-column
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (if (bolp) 0 (max (1+ (current-column)) comment-column)))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina;; ============= K E Y W O R D H I G H L I G H T I N G ============
573e86dc3156e481ce53d39ac901da2e99cfa0caJakub Hrozek(defvar dol-black-komma-face 'dol-black-komma-face
573e86dc3156e481ce53d39ac901da2e99cfa0caJakub Hrozek "Face name to use for black komma.")
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(defvar dol-annotation-face 'dol-annotation-face
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina "DOL mode face for Annotations")
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(setq dol-annotation-face 'font-lock-constant-face)
573e86dc3156e481ce53d39ac901da2e99cfa0caJakub Hrozek(setq dol-name-face 'font-lock-variable-name-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(defvar dol-library-name-face 'dol-library-name-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(setq dol-library-name-face 'font-lock-type-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(setq dol-builtin-face 'font-lock-builtin-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(setq dol-comment-face 'font-lock-comment-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(defvar dol-other-name-face 'dol-other-name-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (setq dol-other-name-face 'dol-blue-komma-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (setq dol-other-name-face 'font-lock-function-name-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(defvar dol-string-char-face 'dol-string-char-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina(setq dol-string-char-face 'font-lock-string-face)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina;; Syntax highlighting of DOL
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; "Warning: Do not design an element of font-lock-keywords to match
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; text which spans lines; this does not work reliably. While
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; font-lock-fontify-buffer handles multi-line patterns correctly,
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; updating when you edit the buffer does not, since it considers
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; text one line at a time." (from the GNU Emacs Lisp Reference Manual)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; order of all the following highlighting rules is significant,
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; ony change if really needed
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("%%.*$" (0 (symbol-value 'dol-comment-face) keep t)))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "Special Comment")
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; Alternativ for Annotation
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; always highlight closing )%
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\(\)%\\)[^%]"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (1 (symbol-value 'dol-annotation-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("%\\w+\\b[^\n]*$"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (0 (symbol-value 'dol-annotation-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("[^%]\\(%\([^)]*?\)%\\)[^%]"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (1 (symbol-value 'dol-annotation-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; %word( ... )%
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\(%\\sw+\([^)]*?\)%\\)[^%]"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (1 (symbol-value 'dol-annotation-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "Annotation")
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; reserved keyword
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\(\\<\\|\\s-+\\)\\(/\\\\\\|\\\\/\\|=>\\|<=>\\|and\\|arch\\|assoc\\|behaviourally\\|closed\\|comm\\|else\\|end\\|exists\\|fit\\|flexible\\|forall\\|free\\|generated\\|given\\|idem\\|if\\|local\\|modality\\|not\\|orElse\\|unit\\|when\\|alignment\\|along\\|assuming\\|and\\|closed-world\\|cofree\\|combine\\|cons-ext\\|end\\|entails\\|entailment\\|equivalence\\|excluding\\|extract\\|free\\|hide\\|import\\|in\\|for\\|forget\\|interpretation\\|keep\\|language\\|library\\|logic\\|maximize\\|model\\|minimize\\|network\\|ni\\|of\\|oms\\|onto\\|ontology\\|refined\\|refinement\\|reject\\|relation\\|remove\\|result\\|reveal\\|select\\|separators\\|serialization\\|spec\\|specification\\|substitution\\|syntax\\|then\\|to\\|translation\\|using\\|vars\\|via\\|view\\|where\\|with\\|cons\\|ccons\\|complete\\|consistent\\|def\\|implied\\|inconsistent\\|mcons\\|mono\\|notccons\\|notmcons\\|prefix\\|wdef\\|within\\|\\(\\(op\\|pred\\|var\\|type\\|sort\\)s?\\)\\)[,;]?[ \t\n]"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("[,;.]" (0 (symbol-value 'dol-black-komma-face) t t))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; after forall don't highlight
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina '("\\bforall\\b\\(.*\\)"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (1 (symbol-value 'dol-black-komma-face) keep t))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; Keywords of loading Library
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("\\(\\<\\|\\s-+\\)\\(logic\\|from\\|get\\|library\\|version\\)[ :\t\n]+"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; Library and Logic name
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("\\b\\(library\\|logic\\)\\s-+\\(\\(\\w\\|/\\)+\\)\\(\\s-*->\\s-*\\(\\(\\w\\|/\\)+\\)\\)?[ \t\n]"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (2 (symbol-value 'dol-library-name-face) keep t)
5ff1c3c5a12930692cb6284d14f7fda3a974af8ePavel Březina (5 (symbol-value 'dol-library-name-face) keep t))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; name of from, get and given
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("\\b\\(get\\|given\\)[ \t\n]+\\(\\(\\sw+\\s-*\\(,[ \t\n]*\\|$\\)\\)+\\)\\(=\\|:\\|$\\)"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\bfrom[ \t]+\\(.+\\)\\(get\\|$\\)"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (1 (symbol-value 'dol-library-name-face) keep t))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina ;; the name of specification and view
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\(\\<\\|\\[\\)\\(spec\\|view\\)\\s-+\\(\\w+\\)[ \t]*\\(\\[\\s-*\\([A-Z]\\w*\\).*\\s-*\\]\\)?\\s-*.*\\([]=:]\\|::=\\)"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; then, and + name
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\b\\(and\\|then\\)[ \t\n]*\\([A-Z]\\w*\\)\\s-*\\(\\[\\([A-Z]\\sw*\\).*\\]\\)?"
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov (4 (symbol-value 'dol-name-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; names before and after to
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("[ \t\n]*\\(\\sw+\\)[ \t\n]+to[ \t\n]+\\(\\(\\sw+\\)\\s-*\\(\\[\\([A-Z]\\sw*\\).*\\]\\)?[, \t]*\\)?"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; instance name of specification
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\<spec.+=\\s-*\\(%\\sw+\\s-*\\)?[ \t\n]*\\([A-Z]\\w*\\)\\s-*\\(\\[\\s-*\\([A-Z]\\w*\\).*\\s-*\\]\\)?"
573e86dc3156e481ce53d39ac901da2e99cfa0caJakub Hrozek ;; Basic signature: sort X, Y, Z
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("\\(\\<\\|\\s-+\\)sorts?[ \t\n]+\\(\\(\\sw+\\s-*\\(\\[\\s-*\\(\\sw\\|,\\)+\\s-*\\]\\s-*\\)?\\(,\\(\\s-\\)*\\|$\\|<\\|;\\|=\\)\\(=\\|<\\|;\\|,\\)*[ \t\n]*\\)+\\)"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (2 (symbol-value 'dol-other-name-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; Basic signature: op ,pred and var name
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\(\\(^[^.{%]\\)\\s-*\\|\\bops?\\b\\|\\bpreds?\\b\\|\\bvars?\\b\\)\\([^:{()\n]*\\)\\(\(.*\)\\)?:\\??[^?.:=%].*;?[ \t]*$"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (2 (symbol-value 'dol-other-name-face) keep t)
7379170a0860790f2739e07fffe3d6ec85264566Pavel Březina (3 (symbol-value 'dol-other-name-face) keep t))
7379170a0860790f2739e07fffe3d6ec85264566Pavel Březina ;; highlight a line with , an end
7379170a0860790f2739e07fffe3d6ec85264566Pavel Březina '("^\\(\\(\\(__\\s-*[^_\n]+\\s-*__\\|[^.,:>\n]+\\)\\s-*,\\s-*\\)+\\)$"
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina (0 (symbol-value 'dol-other-name-face) keep t))
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina ;; names before and after '|->'
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina '("[ \t\n]*\\(__[^|_]+__\\|[^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[ \t\n]*|->[ \t\n]*\\(__[^|_]+__\\|[^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[, \t]*"
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina (1 (symbol-value 'dol-other-name-face) keep t)
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina (3 (symbol-value 'dol-other-name-face) keep t)
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (4 (symbol-value 'dol-other-name-face) keep t)
5ff1c3c5a12930692cb6284d14f7fda3a974af8ePavel Březina (6 (symbol-value 'dol-other-name-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina '("\\(\\btype\\|\\bfree type\\)?\\s-+\\(\\sw+\\)\\s-+\\(\\sw*\\|\\[\\(\\s-*\\sw+\\s-*\\)\\]\\)[ \t\n]*::?=[ \t\n]*\\(\\(\_\_[^_]+\_\_\\|[^|][^(|]+\\)\\s-*\\(\(.*\)\\)?\\)"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (2 (symbol-value 'dol-other-name-face) keep t)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (4 (symbol-value 'dol-other-name-face) keep t)
573e86dc3156e481ce53d39ac901da2e99cfa0caJakub Hrozek (6 (symbol-value 'dol-other-name-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina ;; constructor
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("\|\\s-+\\(\_\_[^|_]+\_\_\\|[^|][^(|]+\\)\\s-*\\(\([^|]+\)\\)?[ \t\n]*"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (1 (symbol-value 'dol-other-name-face) keep t))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("\(\\(\\(\\sw\\|,\\)*\\)\\s-*:\\??[^)]*\)"
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (1 (symbol-value 'dol-other-name-face) keep t))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina '("\([^;]*;\\s-*\\(\\sw+\\)\\s-*:\\??.*\)"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (1 (symbol-value 'dol-other-name-face) keep t))
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina "Reserved keywords highlighting")
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina;; String and Char
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (list '("\\(\\(\"\\|^>[ \t]*\\\\\\)\\([^\"\\\\\n]\\|\\\\.\\)*\\(\"\\|\\\\[ \t]*$\\)\\|'\\([^'\\\\\n]\\|\\\\.[^'\n]*\\)'\\)"
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (0 (symbol-value 'dol-string-char-face) keep t))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina "Syntax highlighting of String and Char")
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina;; Define default highlighting level
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina;; (defvar dol-font-lock-syntax-highligthing dol-font-lock-keywords
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina(defvar dol-font-lock-syntax-highligthing (symbol-value 'dol-font-lock-string)
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina "Default syntax highlighting level in DOL mode")
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina;; ======================= R U N H E T S =======================
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina "*the additional options for running hets.")
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Run hets process to compile the current DOL file."
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (setq run-option (concat run-option current " "))))
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina (setq hets-command (concat dol-hets-program run-option "\"" dol-hets-file-name "\""))
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov ;; Pop up the compilation buffer.
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina ;; (display-buffer outbuf nil t)
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel Březina ;; (set-buffer outbuf)
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina ;; Start the compilation.
(window-width))))
hets-command)))
(if dol-hets-options
(if opt
(defun dol-run-hets-g ()
msg)
(let ((buffer-read-only nil)
(if (bolp)
(defun dol-parse-error ()
(if (not (or (looking-at "Fail") (and (looking-at "\\*\\*\\*") (looking-at "[0-9]+\\.[0-9]+-[0-9]+\\.[0-9]*"))))
(re-search-forward ":\\([0-9]+\\)\\.\\([0-9]+\\)\\(-[0-9]+\\.[0-9]*\\)?[:,]" (save-excursion (end-of-line) (point)) t 1)
(defun dol-compile-goto-next-error ()
;; (message "DEBUG<Goto Error>: file: %s, line: %s, column: %s" error-file-name error-line error-column)
(defun dol-mode ()
(dol-vars)
;; Support for compile.el
(lambda()