Skip to content

Instantly share code, notes, and snippets.

@folone
Created December 8, 2011 16:42
Show Gist options
  • Save folone/1447544 to your computer and use it in GitHub Desktop.
Save folone/1447544 to your computer and use it in GitHub Desktop.
roy-mode
(require 'generic-x)
(defvar roy-keywords
'("with" "macro" "return" "bind" "do" "case" "match"
"type" "data" "else" "then" "if" "fn" "let" "true" "false")
"Roy keywords.")
;;
;; Syntax highligh
;;
(define-generic-mode 'roy-mode
'("//") ;; comments
roy-keywords
'(;; fixnums
("[0-9]+" . 'font-lock-variable-name-face)
;; floats
("[0-9]+\.[0-9]+" . 'font-lock-variable-name-face)
;; types
("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)" . 'font-lock-type-face)
;; opareators and constants
("\\([!-+*/~⊥πτ:≠λ←→⇒∈∉∘<>=&!?%^]+\\)" 1 'font-lock-function-name-face)
;; functions
("^\\s *let\\s +\\([^( \t\n]+\\)" 1 'font-lock-function-name-face)
("\\<\\(e\\(?:mpty\\|ven\\)\\|f\\(?:ilter\\|lip\\|oldl\\)\\|head\\|id\\|l\\(?:ength\\|og\\)\\|ma\\(?:p\\|ybe\\)\\|not\\|odd\\|pred\\|replicate\\|succ\\|ta\\(?:il\\|ke\\)\\)\\>" 1 'font-lock-function-name-face)
)
'("\\.roy$") ;; files for which to activate this mode
nil ;; other functions to call
"A simple mode for roy files" ;; doc string for this mode
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment