; Statechart Virtual Machine v0.2 ; ; mode file for statechart descriptions ; written by Thomas Huining Feng ; 2003-03-15 (defvar svm-mode-hook nil) (defvar svm-mode-map nil) (if svm-mode-map nil (setq svm-mode-map (make-keymap)) ) (setq auto-mode-alist (append '(("\\.[Dd][Ee][Ss]\\'" . svm-mode)) auto-mode-alist)) (defconst svm-font-lock-keywords-1 (list '("\\<\\(?:AFTERSNAPSHOT\\|BEFORESNAPSHOT\\|Clock\\|D\\(?:ESCRIPTION\\|UMP\\|ebugger\\)\\|E\\(?:NTER\\|VENT\\|XIT\\|venthandler\\)\\|FINALIZER\\|I\\(?:MPORTATION\\|N\\(?:ITIALIZER\\|TERACTOR\\)\\|nnerTransitionFirst\\)\\|MACRO\\|None\\|OPTIONS\\|RESTORE\\|S\\(?:NAPSHOT\\|TATECHART\\)\\|TRANSITION\\|a\\(?:nd\\|ssert\\)\\|break\\|c\\(?:lass\\|ontinue\\)\\|de\\(?:bugger\\|[fl]\\)\\|e\\(?:l\\(?:if\\|se\\)\\|venthandler\\|x\\(?:cept\\|ec\\)\\)\\|f\\(?:inally\\|or\\|rom\\)\\|global\\|i\\(?:mport\\|[fns]\\)\\|lambda\\|map\\|not\\|or\\|p\\(?:ass\\|rint\\)\\|r\\(?:a\\(?:ise\\|nge\\)\\|eturn\\)\\|try\\|while\\)\\>" . font-lock-builtin-face) '("\\('.*'\\)" . font-lock-string-face) ) ) (defconst svm-font-lock-keywords-2 (append svm-font-lock-keywords-1 (list '("\\<\\(?:CS\\|DS\\|EVAL\\|FS\\|HS\\*?\\|I\\(?:NSTATE\\|TF\\)\\|OTF\\|RT[OT]\\|__import__\\|a\\(?:bs\\|pply\\)\\|c\\(?:allable\\|hr\\|mp\\|o\\(?:erce\\|mp\\(?:ile\\|lex\\)\\)\\)\\|d\\(?:elattr\\|i\\(?:r\\|vmod\\)\\)\\|e\\(?:val\\|xecfile\\)\\|f\\(?:ilter\\|loat\\)\\|g\\(?:etattr\\|lobals\\|roup\\)\\|h\\(?:as\\(?:attr\\|h\\)\\|ex\\)\\|i\\(?:d\\|n\\(?:put\\|t\\(?:ern\\)?\\)\\|s\\(?:instance\\|subclass\\)\\)\\|joinfields\\|l\\(?:en\\|ist\\|o\\(?:cal\\|ng\\)\\)\\|m\\(?:a\\(?:tch\\|x\\)\\|in\\)\\|o\\(?:ct\\|pen\\|rd\\)\\|pow\\|r\\(?:aw_input\\|e\\(?:duce\\|load\\|pr\\)\\|ound\\)\\|s\\(?:e\\(?:arch\\|t\\(?:attr\\|default\\)\\)\\|lice\\|plitfields\\|tr\\)\\|t\\(?:uple\\|ype\\)\\|unic\\(?:hr\\|ode\\)\\|vars\\|xrange\\|zip\\)\\>" . font-lock-keyword-face) ) ) ) (defconst svm-font-lock-keywords-3 (append svm-font-lock-keywords-2 () ) ) (defvar svm-font-lock-keywords svm-font-lock-keywords-3) (defvar svm-mode-syntax-table nil) (defun svm-create-syntax-table () (if svm-mode-syntax-table () (setq svm-mode-syntax-table (make-syntax-table)) (set-syntax-table svm-mode-syntax-table) ; This is added so entity names with underscores can be more easily parsed (modify-syntax-entry ?\( "()" svm-mode-syntax-table) (modify-syntax-entry ?\) ")(" svm-mode-syntax-table) (modify-syntax-entry ?\[ "(]" svm-mode-syntax-table) (modify-syntax-entry ?\] ")[" svm-mode-syntax-table) (modify-syntax-entry ?\{ "(}" svm-mode-syntax-table) (modify-syntax-entry ?\} "){" svm-mode-syntax-table) ;; Add operator symbols misassigned in the std table (modify-syntax-entry ?\$ "." svm-mode-syntax-table) (modify-syntax-entry ?\% "." svm-mode-syntax-table) (modify-syntax-entry ?\& "." svm-mode-syntax-table) (modify-syntax-entry ?\* "." svm-mode-syntax-table) (modify-syntax-entry ?\+ "." svm-mode-syntax-table) (modify-syntax-entry ?\- "." svm-mode-syntax-table) (modify-syntax-entry ?\/ "." svm-mode-syntax-table) (modify-syntax-entry ?\< "." svm-mode-syntax-table) (modify-syntax-entry ?\= "." svm-mode-syntax-table) (modify-syntax-entry ?\> "." svm-mode-syntax-table) (modify-syntax-entry ?\| "." svm-mode-syntax-table) (modify-syntax-entry ?\_ "w" svm-mode-syntax-table) ;; Both single quote and double quote are string delimiters (modify-syntax-entry ?\' "\"" svm-mode-syntax-table) (modify-syntax-entry ?\" "\"" svm-mode-syntax-table) ;; backquote is open and close paren (modify-syntax-entry ?\` "$" svm-mode-syntax-table) ;; comment delimiters (modify-syntax-entry ?\# "<" svm-mode-syntax-table) (modify-syntax-entry ?\n ">" svm-mode-syntax-table) ) ) (defun svm-indent-line nil "Fix the indentation of the current line according to Python rules." (interactive) (let (x y) (forward-line -1) (beginning-of-line) (setq x (point)) (back-to-indentation) (setq y (buffer-substring x (point))) (if (looking-at "[^#].*:\([ ]*#.*\)?$") (setq y (concat y " "))) (forward-line 1) (beginning-of-line) (delete-horizontal-space) (insert y))) (defun svm-mode () (interactive) (kill-all-local-variables) (svm-create-syntax-table) ;; Set up font-lock (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(svm-font-lock-keywords)) ;; Register our indentation function (make-local-variable 'indent-line-function) (setq indent-line-function 'svm-indent-line) (setq major-mode 'svm-mode) (setq mode-name "svm") (make-local-variable `indent-line-function) (setq indent-line-function `svm-indent-line) (add-hook 'svm-mode-hook '(lambda () (local-set-key "\C-m" 'newline-and-indent))) (run-hooks 'svm-mode-hook)) (provide 'svm-mode)