diff --git a/lpp-mode.el b/lpp-mode.el new file mode 100644 index 0000000000000000000000000000000000000000..8707d3ec22bbc06cff98b4e4e77ec798b03bd69f --- /dev/null +++ b/lpp-mode.el @@ -0,0 +1,46 @@ +(defvar lpp-mode-hook nil) + +(defvar lpp-mode-map + (let ((map (make-keymap))) + (define-key map (kbd "C-\\") (lambda () (interactive) (insert "\\"))) + (define-key map (kbd "\\") "λ") + map) + "Keymap for LPP major mode") + +(defun lpp-indent-line ()) ; todo + +(defconst lpp--token-syntax-types + '(( + ("#.*" . font-lock-comment-face) + ("$\\w*" . font-lock-variable-name-face) + ("λ\\w*" . font-lock-builtin-face) + )nil nil nil)) + +(defconst lpp--syntax-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\/ "<" table) + (modify-syntax-entry ?\n ">" table) + table) + "Syntax table for lpp-mode.") + +;;;###autoload +(defgroup lpp nil + "Major mode for editing λ++ code." + :prefix 'lpp + :group 'languages) + +;;;###autoload +(define-derived-mode lpp-mode prog-mode "lpp" + "Major mode for editing λ++ source code." + :syntax-table lpp--syntax-table + :group 'lpp + (setq-local font-lock-defaults lpp--token-syntax-types) + (use-local-map lpp-mode-map) + (set (make-local-variable 'indent-line-function) 'lpp-indent-line) + (run-hooks 'lpp-mode-hook)) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.lpp\\'" . lpp-mode)) +;;;###autoload +(add-to-list 'interpreter-mode-alist '("lpp" . lpp-mode)) +(provide 'lpp-mode)