casl-mode.el revision 175c9e5fde43fc804a8d25198133288669b9d54c
;;;###autoload
;; Version number
"Version of CASL-Mode")
"Major mode for editing Haskell programs."
:prefix "casl-")
;; casl major mode setup
(defvar casl-mode-hook nil)
"Keymap for CASL major mode")
;; Are we running FSF Emacs or XEmacs?
(defvar casl-running-xemacs
"non-nil if we are running XEmacs, nil otherwise.")
;; ============= K E Y W O R D H I G H L I G H T I N G ============
(defvar casl-annotation-face 'casl-annotation-face
"CASL mode face for Annotations")
(defvar casl-keyword-face 'casl-keyword-face)
(defvar casl-library-name-face 'casl-library-name-face)
(defvar casl-name-face 'casl-name-face)
(defvar casl-builtin-face 'casl-builtin-face)
(defvar casl-comment-face 'casl-comment-face)
(defvar casl-other-name-face 'casl-other-name-face)
;; Syntax highlighting of CASL
(list
;; Keywords of loading Library
'("\\(\\<\\|\\s-+\\)\\(logic\\|from\\|get\\|library\\|version\\)[ :\t\n]+"
'("\\(\\<\\|\\s-+\\)\\(%authors\\|%date\\|%display\\|%prec\\|%left_assoc\\|%number\\|%floating\\|%LATEX\\|%implies\\)[ :\t\n]+"
;; Library and Logic name
'("\\(\\<\\|\\s-+\\)\\(library\\|logic\\)\\s-+\\([a-zA-Z0-9/]+\\)[ \t\n]*"
;; name of from get and given
'("\\(\\<\\|[ \t]+\\)\\(get\\|given\\)[ \t\n]+\\(\\(\\sw+\\s-*\\(,\\|$\\)[ \t\n]*\\)+\\)"
'("\\(\\<\\|\\s-+\\)from\\([ \t]+\\)\\(.+\\)\\(get\\|\\s-*\\)"
;; the name of specification and view
'("\\(\\<\\|\\[\\)\\(spec\\|view\\)\\s-+\\(\\w+\\)[ \t]*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?\\s-*.*\\([]=:]\\|::=\\)"
;; then, and + name
'("\\(\\<\\|\\s-+\\)\\(and\\|then\\)[ \t\n]*\\([A-Z]\\w*\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?"
;; names before and after to
'("[ \t\n]*\\(\\w+\\)[ \t\n]+to[ \t\n]+\\(\\(\\w+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[, \t]*\\)?"
;; instance name of specification
'("\\<spec.+=\\s-*\\(%\\sw+\\s-*\\)?[ \t\n]*\\([A-Z]\\sw*\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?"
;; Basic signature: sort X, Y, Z
'("\\(\\<\\|\\s-+\\)sorts?[ \t]+\\(\\(\\sw+\\s-*\\(\\[\\sw+\\]\\s-*\\)?\\(,\\|$\\|<\\|;\\|=\\)[ \t\n]*\\)+\\)"
;; Basic signature: op ,pred and var name
'("\\(^\\|ops?\\|preds?\\|vars?\\)\\s-+\\([a-zA-Z0-9]\\sw*\\|[^.%a-zA-Z0-9][^ \n]*\\)\\s-*\\(\(.*\)\\s-*\\)?\\(:\\??\\|<=>\\).*"
;; Basic signatur (pred, op, var) + name
;;;;'("\\(\\<\\|\\s-+\\)\\(op\\|pred\\|var\\)s?[ \t\n]+\\(\\(\\([a-zA-Z0-9][^: \t\n]*\\|\\(_\\|\\s_\\)[^:\n]*\\)\\s-*:[ \t\n]*[^;\n]+;?.*[ \t\n]*\\)+\\)"
;;;; (3 casl-other-name-face keep t))
;; type name
'("\\s-+\\(\\sw+\\)[ \t\n]*::=.*"
;; names before and after '|->'
'("[ \t\n]*\\([^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[ \t\n]+|->[ \t\n]+\\([^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[, \t]*"
;; reserved keyword
'("\\(\\<\\|\\s-+\\)\\(/\\\\\\|\\\\/\\|=>\\|<=>\\|and\\|arch\\|assoc\\|closed\\|comm\\|else\\|end\\|exists\\|fit\\|forall\\|free\\|generated\\|given\\|hide\\|if\\|local\\|not\\|reveal\\|spec\\|then\\|to\\|unit\\|view\\|when\\|within\\|with\\|\\(\\(op\\|pred\\|var\\|type\\|sort\\)s?\\)\\)[,;]?[ \t\n]"
)
"Reserved keywords highlighting")
;; Comment
))
"Special Comment")
;; Alternativ for Annotation
(list
;; %word(...)\n
;; %word \n
;; %( ... )%
;; %word( ... )%
))
"Annotation")
;; Define default highlighting level
;; (defvar casl-font-lock-syntax-highligthing casl-font-lock-keywords
"Default syntax highlighting level in CASL mode")
;; ====================== S Y N T A X T A B L E ==================
;; Syntax table for CASL major mode
(defvar casl-mode-syntax-table nil
"Syntax table for CASL mode.")
()
(let ((table (make-syntax-table)))
;; Indicate that underscore may be part of a word
;; Commnets
;; commenting-out plus including other kinds of comment
;; Some of these are actually OK by default.
"!#$&*+.,/:<=>?@^|~")
)
;; Various mode variables.
(defun casl-vars ()
;; Find the indentation level for a comment.
(defun casl-comment-indent ()
(skip-chars-backward " \t")
;; if the line is blank, put the comment at the beginning,
;; else at comment-column
;; ======================= R U N H E T S =======================
(setq casl-error-list nil)
(defvar hets-program nil)
(defun casl-run-hets ()
"Run hets process to compile the current CASL file."
(save-buffer nil)
(if hets-program
(let* ((casl-hets-file-name (buffer-file-name))
(setq buffer-read-only nil)
(let ((status
"finished\n"
(t
(setq casl-error-list nil)
(setq casl-error-list nil)
)))
;; also functions with old hets-program?
(defun casl-parse-error ()
"Error Parser"
;;;(pop-to-buffer compiler-buffer)
(skip-chars-forward "a-zA-Z* ")
)
(forward-line 1)))))
(defun casl-compile-goto-next-error ()
"search the next error position from error-list, and move to it."
;; wenn error-list leer ist...
(if (null casl-error-list)
(message "no error.")
;; (message "DEBUG<Goto Error>: file: %s, line: %s, column: %s" error-file-name error-line error-column)
;; wenn die Datei, die fehlerbehaftet ist, schon geoeffnet...
)))
;; ================= C A S L M A J O R M O D E ===============
;; Definition of CASL major mode
(defun casl-mode ()
"Major mode for editing CASL models"
;; Load keymap
;; Load syntax table
;; (casl-create-syntax-table)
;; Highlight CASL keywords
;; Support for compile.el
;; We just substitute our own functions to go to the error.
(lambda()
;; FIXME: This has global impact! -stef
)
;; CASL-mode ends here