Browse Source

Working

main
Annwan 2 years ago
parent
commit
a839a3f8be
  1. 78
      worst-mode.el

78
worst-mode.el

@ -1,9 +1,8 @@
;;; worst-mode.el --- major mode for worst -*- lexical-binding: t -*-
;; Author: Antoine "Annwan" Combet
;; Maintainer: Antoine "Annwan" Combet
;; Author: Antoine "Annwan" Combet <annwan@annwan.me>
;; Maintainer: Antoine "Annwan" Combet <annwan@annwan.me
;; Version: 0.1.0
;; Homepage: TBD
;; This file is not part of GNU Emacs
@ -24,59 +23,60 @@
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
;;FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
;; IN THE SOFTWARE.
;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
;; IN THE SOFTWARE.
;;; Commentary:
;; commentary
;; This is a major mode for the worst programming language
;; <https://gitlab.com/worst-lang/worst>
;;; Code:
(defvar worst--builtins
'(; Builtins
"define" "default-attributes" "definition-add" "all-definitions"
"definition-resolve" "dispatch" "dispatch-first" "stack-matches?" "quote"
"clone" "drop" "dig" "burry" "eval" "call" "uplevel" "upquote" "const"
"swap" "if" "while" "equal?" "not" "false?" "error?" "pause" "stack-empty"
"stack-dump" "value->string" "stack-get" "doc" "dcoumentation-attribute"
"value-doc" "open-file/read" "open-embedded-file/read" "interpreter-empty"
(defvar worst-keywords '("define" "import" "export" "%exports")
(defvar worst-builtins
'("default-attributes" "definition-add" "all-definitions" "definition-resolve"
"dispatch" "dispatch-first" "stack-matches?" "quote" "clone" "drop" "dig"
"bury" "eval" "call" "uplevel" "upquote" "const" "swap" "if" "while"
"equal?" "not" "false?" "error?" "pause" "stack-empty" "stack-dump"
"value->string" "stack-get" "doc" "dcoumentation-attribute" "value-doc"
"open-file/read" "open-embedded-file/read" "interpreter-empty"
"interpreter-reset" "interpreter-stack-length" "interpreter-stack-push"
"interpreter-stack-pop" "interpreter-stack-get"
"interpreter-definition-add" "interpreter-definition-remove"
"interpreter-call" "interpreter-body-push" "interpreter-body-prepend"
"current-output-port" "current-error-port" "current-input-port"
"port-write-string" "port-flush" "can-read?" "port->string"
"buffered-port-read-line" "open-string-input-port" "list?" "list-empty"
"list-length" "list-reverse" "list-push" "list-pop" "list-append" "f64?"
"import" "export" "%exports" "i64?" "i64-add" "f64-add" "i64-sub" "f64-sub"
"interpreter-stack-pop" "interpreter-stack-get" "interpreter-definition-add"
"interpreter-definition-remove" "interpreter-call" "interpreter-body-push"
"interpreter-body-prepend" "current-output-port" "current-error-port"
"current-input-port" "port-write-string" "port-flush" "can-read?"
"port->string" "buffered-port-read-line" "open-string-input-port" "list?"
"list-empty?" "list-length" "list-reverse" "list-push" "list-pop"
"list-append" "f64?" "i64?" "i64-add" "f64-add" "i64-sub" "f64-sub"
"i64-mul" "f64-mul" "i64-div" "f64-div" "i64-negate" "f64-negate" "i64-abs"
"f64-abs" "i64-complt" "f64-complt" "i64-comple" "f64-comple" "i64-compgt"
"f64-compgt" "i64-compge" "f64-compge" "command-line-arguments"
"get-environment-variable" "make-place" "place-get" "place-set"
"reader-empty" "reader-set-eof" "reader-write-string" "reader-next"
"reader-empty" "reader-set-eof" "reader-write-string" "reader-next"
"read-port->list" "string?" "string-append" "whitespace?" "string->symbol"
; Standard lib definitions
"add" "sub" "mul" "div" "negate" "abs" "comple" "complt" "compge" "compgt"
"append" "->string" "print-value" "print" "read-line" "read-file"
"evaluate" "equals?" "==" "not" "max" "min" "updo" "iteri" "do-times"
"definition-exists" "definition-rename" "definition-copy-up"
"define-gensym" "stack-swap" "case"))
"append" "->string" "print-value" "print" "read-line" "read-file" "evaluate"
"equals?" "==" "not" "max" "min" "updo" "iteri" "do-times"
"definition-exists" "definition-rename" "definition-copy-up" "define-gensym"
"stack-swap" "case"))
(setq worst-font-lock-keywords
`((,worst--builtins . 'font-lock-builtin-face)))
(defvar worst-tab-width 4)
(defun worst-mode-setup ()
(set-syntax-table lisp-mode-syntax-table)
(setq tab-width worst-tab-width)
(modify-syntax-entry ?/ "w") (modify-syntax-entry ?? "w")
(modify-syntax-entry ?{ "(}") (modify-syntax-entry ?} "){"))
;;;###autoload
(define-generic-mode 'worst-mode
'(";")
worst--builtins
'(("#f\\|#t\\|[0-9+](\\.[0-9]+)\\|\".+?\"" . 'font-lock-constant-face)
("(\\|)\\|\\[\\|]\\|{\\|}" . 'font-lock-keyword-face)
("[^[:space:]]+" . 'font-lock-variable-name-face))
(define-generic-mode worst-mode
'()
worst-keywords
`(( ,(regexp-opt worst-builtins 'symbols) . font-lock-builtin-face)
( "#f\\|#t\\|\\<[0-9]+\\(\\.[0-9]+\\)?\\>" . font-lock-constant-face))
'("\\.w$")
nil
"A mode for worst files")
'(worst-mode-setup))
(provide 'worst-mode)

Loading…
Cancel
Save