Last active
April 18, 2018 19:56
-
-
Save goral09/01e7d200dc753a590d37056c09fd04a6 to your computer and use it in GitHub Desktop.
Rholang syntax highlight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar rholang-constants | |
'("true" | |
"false" | |
"Nil" | |
)) | |
(defvar rholang-keywords | |
'("contract" | |
"matches" | |
"with" | |
"and" | |
"or" | |
"contract" | |
"for" | |
"select" | |
"match" | |
"if" | |
"in" | |
"new" | |
)) | |
(defvar rholang-tab-width 4 "Width of a tab for MYDSL mode") | |
(defvar rholang-font-lock-defaults | |
`(( | |
;; when there's an override, use it | |
;; otherwise it gets the default value | |
(when rholang-tab-width | |
(setq tab-width rholang-tab-width)) | |
(":\\|,\\|;\\|{\\|}\\|=>\\|@\\|$\\|=\\|<-\\|@\\|!\\|!!\\||" . font-lock-keyword-face) | |
( ,(regexp-opt rholang-keywords 'words) . font-lock-builtin-face) | |
( ,(regexp-opt rholang-constants 'words) . font-lock-constant-face) | |
)) | |
) | |
(define-derived-mode rholang-mode fundamental-mode "Rholang" | |
(setq font-lock-defaults rholang-font-lock-defaults) | |
(setq comment-start "//") | |
(setq comment-end "") | |
(modify-syntax-entry ?/ "< b" rholang-mode-syntax-table) | |
(modify-syntax-entry ?\n "> b" rholang-mode-syntax-table) | |
) | |
(provide 'rholang-mode) | |
;; associate *.rho files with rholang-mode | |
(add-to-list 'auto-mode-alist '("\\.rho\\'" . rholang-mode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment