Skip to content

Instantly share code, notes, and snippets.

@krtx
Created June 8, 2017 03:28
Show Gist options
  • Save krtx/d907bd665bf23e94560f264fff7f42e4 to your computer and use it in GitHub Desktop.
Save krtx/d907bd665bf23e94560f264fff7f42e4 to your computer and use it in GitHub Desktop.
(defvar systemf-mode-syntax-table nil "Syntax table for systemf mode.")
(setq systemf-mode-syntax-table
(let ((syn-table (make-syntax-table)))
(modify-syntax-entry ?\/ ". 14" syn-table)
(modify-syntax-entry ?* ". 23" syn-table)
syn-table))
(defface systemf-lock-governing-face
'((t (:foreground "black" :weight bold)))
"Face for governing keywords.")
(defvar systemf-lock-governing-face 'systemf-lock-governing-face)
(defface systemf-lock-operator-face
'((t (:foreground "brown")))
"Face for operators.")
(defvar systemf-lock-operator-face 'systemf-lock-operator-face)
(setq systemf-governing '("let" "in" "as" "Some" "All"))
(setq systemf-operators '("=" "->" ":" "(" ")" "{" "}" ";"))
(setq systemf-keywords '("lambda" "if" "then" "else" "fix"))
(setq systemf-types '("Nat" "Bool" "Unit"))
(setq systemf-constants '("false" "true"))
(setq systemf-governing-regexp (regexp-opt systemf-governing 'words))
(setq systemf-operators-regexp (regexp-opt systemf-operators))
(setq systemf-keywords-regexp (regexp-opt systemf-keywords 'words))
(setq systemf-types-regexp (regexp-opt systemf-types 'words))
(setq systemf-constants-regexp (regexp-opt systemf-constants 'words))
(setq systemf-font-lock-keywords
`((,systemf-governing-regexp . systemf-lock-governing-face)
(,systemf-operators-regexp . systemf-lock-operator-face)
(,systemf-keywords-regexp . font-lock-keyword-face)
(,systemf-types-regexp . font-lock-type-face)
(,systemf-constants-regexp . font-lock-constant-face)))
(define-derived-mode systemf-mode fundamental-mode "systemf"
"major mode for editing systemf language (implemented in TaPL) code."
(setq font-lock-defaults '((systemf-font-lock-keywords)))
(setq-local comment-start "/*")
(setq-local comment-end "*/"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment