First pass at a PicoML mode
Getty Ritter
9 years ago
1 | ;; pico-ml-mode.el --- a simple major mode for editing PicoML files | |
2 | ||
3 | ;; Version: 20150815.0000 | |
4 | ;; Author: Getty ritter | |
5 | ;; Url: https://github.com/aisamanra/pico-ml-mode | |
6 | ||
7 | (setq pico-ml-font-lock | |
8 | '(( "data\\|record\\|let\\|in\\|if\\|implicit\\|exports\\|import" . font-lock-keyword-face ) | |
9 | ( "^\\(implicit *\\)?\\([a-z][A-Za-z0-9]*\\|[_+*/\!@~#$%^&=|<>]+\\)" 2 font-lock-function-name-face ) | |
10 | ( "\\.[a-z][A-Za-z-9]*" . font-lock-variable-name-face ) | |
11 | ( "Bool\\|Nat\\|Int\\|Float\\|String" . font-lock-builtin-face ) | |
12 | ( "[A-Z][A-Za-z0-9]+" . font-lock-type-face ))) | |
13 | ||
14 | (defvar pico-ml-syntax-table nil "Syntax table for `pico-ml-mode'.") | |
15 | (setq pico-ml-syntax-table | |
16 | (let ((table (make-syntax-table))) | |
17 | (modify-syntax-entry ?- ". 12b" table) | |
18 | (modify-syntax-entry ?\n "> b" table) | |
19 | (modify-syntax-entry ?( "($") | |
20 | (modify-syntax-entry ?) ")^") | |
21 | ||
22 | table)) | |
23 | ||
24 | (define-derived-mode pico-ml-mode prog-mode | |
25 | "PicoML mode is a major mode for editing PicoML files" | |
26 | :syntax-table pico-ml-syntax-table | |
27 | ||
28 | (setq font-lock-defaults '(pico-ml-font-lock)) | |
29 | (setq mode-name "PicoML mode") | |
30 | (setq comment-start "--") | |
31 | (setq comment-end "")) | |
32 | ||
33 | ;;;###autoload | |
34 | (add-to-list 'auto-mode-alist '("\\.pml\\'" . pico-ml-mode)) | |
35 | ||
36 | (provide 'pico-ml-mode) | |
37 | ||
38 | ;;; pico-ml-mode.el ends here |