casl-mode.el revision 36089fe7ad5167b48f702514056071fd8739faea
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;;;###autoload
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(autoload 'turn-on-casl-indent "casl-indent" "Turn on CASL indentation." t)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; Version number
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major "Version of CASL-Mode")
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major "Major mode for editing (heterogeneous) CASL programs."
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; casl major mode setup
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(defvar casl-mode-map (let ((keymap (make-keymap)))
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major (define-key keymap "\C-c\C-n" 'casl-compile-goto-next-error)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major "Keymap for CASL major mode")
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; Are we running FSF Emacs or XEmacs?
1f48f8236de7de97be1c6b9d06bef50b379c8801jenkins "non-nil if we are running XEmacs, nil otherwise.")
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; ============= K E Y W O R D H I G H L I G H T I N G ============
5ec701c9f8ccc403ee6fd3e41239df7dcd9faddeBruno Lavit(defvar casl-black-komma-face 'casl-black-komma-face
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major "Face name to use for black komma.")
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(defvar casl-annotation-face 'casl-annotation-face
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major "CASL mode face for Annotations")
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(setq casl-annotation-face 'font-lock-constant-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(defvar casl-library-name-face 'casl-library-name-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(setq casl-library-name-face 'font-lock-type-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(setq casl-name-face 'font-lock-variable-name-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(defvar casl-other-name-face 'casl-other-name-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(setq casl-other-name-face 'font-lock-function-name-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(defvar casl-string-char-face 'casl-string-char-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major(setq casl-string-char-face 'font-lock-string-face)
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; Syntax highlighting of CASL
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; Keywords of loading Library
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|\\s-+\\)\\(logic\\|from\\|get\\|library\\|version\\)[ :\t\n]+"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; '("\\(\\<\\|\\s-+\\)\\(%authors\\|%date\\|%display\\|%prec\\|%left_assoc\\|%number\\|%floating\\|%LATEX\\|%implies\\)[ :\t\n]+"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; (2 casl-annotation-face keep t))
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; Library and Logic name
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|\\s-+\\)\\(library\\|logic\\)\\s-+\\(\\(\\w\\|/\\)+\\)[ \t\n]*"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; name of from, get and given
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|[ \t]+\\)\\(get\\|given\\)[ \t\n]+\\(\\(\\sw+\\s-*\\(,\\|$\\)[ \t\n]*\\)+\\)"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|\\s-+\\)from\\([ \t]+\\)\\(.+\\)\\(get\\|\\s-*\\)"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; the name of specification and view
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|\\[\\)\\(spec\\|view\\)\\s-+\\(\\w+\\)[ \t]*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?\\s-*.*\\([]=:]\\|::=\\)"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major (3 casl-name-face keep t) (5 casl-name-face keep t))
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; then, and + name
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|\\s-+\\)\\(and\\|then\\)[ \t\n]*\\([A-Z]\\w*\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major (3 casl-name-face keep t) (5 casl-name-face keep t))
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; names before and after to
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("[ \t\n]*\\(\\w+\\)[ \t\n]+to[ \t\n]+\\(\\(\\w+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[, \t]*\\)?"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major (1 casl-name-face keep t) (3 casl-name-face keep t) (5 casl-name-face keep t))
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; instance name of specification
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\<spec.+=\\s-*\\(%\\sw+\\s-*\\)?[ \t\n]*\\([A-Z]\\sw*\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major (2 casl-name-face keep t) (4 casl-name-face keep t))
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; Basic signature: sort X, Y, Z
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|\\s-+\\)sorts?[ \t]+\\(\\(\\sw+\\s-*\\(\\[\\(\\sw\\|,\\)+\\]\\s-*\\)?\\(,\\(\\s-\\)*\\|$\\|<\\|;\\|=\\)\\(\\sw\\|=\\|<\\|;\\|,\\)*[ \t\n]*\\)+\\)"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; Basic signature: op ,pred and var name
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(^\\|\\bops?\\|\\bpreds?\\|\\bvars?\\)\\s-+\\([^.]\\(,\\s-*\\)?\\(\\sw\\(,\\s-*\\)?\\|\\(\\s_\\|\\s_+::?\\s_+\\)\\(,\\s-*\\)?\\|\\s(\\|\\s)\\)*\\)\\s-*\\(\(.*\)\\)?\\s-*\\(:\\??\\|<=>\\)[^:\n]*;?[ \t]*$"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; type name
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\s-+\\(\\sw+\\)[ \t\n]*::?=\\s-*\\(\\sw*\\).*"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major (1 casl-other-name-face keep t) (2 casl-other-name-face keep t) )
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; constructor
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\sw+\\)?\\s-*|\\s-*\\(\\sw+\\)\\s-*[|(]?\\([ \t\n]*\\|$\\)"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major (1 casl-other-name-face keep t) (2 casl-other-name-face keep t))
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\(\\(\\(\\sw\\|,\\)*\\)\\s-*:\\??[^)]*\)"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\([^;]*;\\s-*\\(\\sw+\\)\\s-*:\\??.*\)"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; names before and after '|->'
a35224ef1ee8c02d389ffeeb676b4de432294fb6Phill Cunnington '("[ \t\n]*\\([^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[ \t\n]+|->[ \t\n]+\\([^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[, \t]*"
a35224ef1ee8c02d389ffeeb676b4de432294fb6Phill Cunnington (1 casl-other-name-face keep t) (3 casl-other-name-face keep t)
a35224ef1ee8c02d389ffeeb676b4de432294fb6Phill Cunnington (4 casl-other-name-face keep t) (6 casl-other-name-face keep t))
a35224ef1ee8c02d389ffeeb676b4de432294fb6Phill Cunnington ;; reserved keyword
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major '("\\(\\<\\|\\s-+\\)\\(/\\\\\\|\\\\/\\|=>\\|<=>\\|and\\|arch\\|assoc\\|behaviourally\\|closed\\|comm\\|else\\|end\\|exists\\|fit\\|forall\\|free\\|generated\\|given\\|hide\\|idem\\|if\\|local\\|not\\|refined\\|refinement\\|reveal\\|spec\\|then\\|to\\|unit\\|via\\|view\\|when\\|within\\|with\\|\\(\\(op\\|pred\\|var\\|type\\|sort\\)s?\\)\\)[,;]?[ \t\n]"
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major "Reserved keywords highlighting")
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major;; String and Char
a329900f13c59aa829b6b857a5e96119d249880cPhill Cunnington (list '("\\(\\(\"\\|^>[ \t]*\\\\\\)\\([^\"\\\\\n]\\|\\\\.\\)*\\(\"\\|\\\\[ \t]*$\\)\\|'\\([^'\\\\\n]\\|\\\\.[^'\n]*\\)'\\)" (0 casl-string-char-face t t))
a329900f13c59aa829b6b857a5e96119d249880cPhill Cunnington "Syntax highlighting of String and Char")
9d652bb883e4c215dbdcab006aaf1941c3f412baRich Riley;; Alternativ for Annotation
9d652bb883e4c215dbdcab006aaf1941c3f412baRich Riley ;; %word(...)\n
9d652bb883e4c215dbdcab006aaf1941c3f412baRich Riley '("%\\sw+\([^%\n]+\)$" (0 casl-annotation-face t t))
9d652bb883e4c215dbdcab006aaf1941c3f412baRich Riley ;; %words \n
80ca0b9f5ad61b2335af25d4dcf25a04ebfcbc91Peter Major ;; %( ... )%
(defvar casl-mode-syntax-table nil
(defun casl-vars ()
(defun casl-comment-indent ()
(defvar hets-program nil)
(defvar old-buffer nil)
(defun casl-run-hets ()
(save-buffer nil)
(if hets-program
(set-buffer-modified-p nil)
(let* ((process-environment
(window-width))))
hets-command)))
(defun casl-run-hetsg ()
(save-buffer nil)
(if hets-program
(set-buffer-modified-p nil)
(let* ((process-environment
(window-width))))
hets-command)))
msg)
(let ((buffer-read-only nil)
(if (bolp)
(defun casl-parse-error ()
(defun casl-compile-goto-next-error ()
;; (message "DEBUG<Goto Error>: file: %s, line: %s, column: %s" error-file-name error-line error-column)
(defun casl-mode ()
;; Support for compile.el
(lambda()