Initial commit

This commit is contained in:
Skylar Hill 2024-04-15 11:26:13 -05:00
commit f7845aa23a
2 changed files with 77 additions and 0 deletions

16
LICENSE Normal file
View File

@ -0,0 +1,16 @@
MIT No Attribution
Copyright 2024 Skylar Hill
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.

61
hex0-mode.el Normal file
View File

@ -0,0 +1,61 @@
;;; hex0-mode.el --- Major mode to add syntax highlighting to hex0.
;;;
;;; MIT No Attribution
;;;
;;; Copyright 2024 Skylar Hill
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining a copy of this
;;; software and associated documentation files (the "Software"), to deal in the Software
;;; without restriction, including without limitation the rights to use, copy, modify,
;;; merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
;;; permit persons to whom the Software is furnished to do so.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
;;; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.
;;;
;;; Commentary:
;;;
;;; TODO Make that big regexp for x86 assembly instructions actually match
;;; inside comments, where they actually appear. Right now, the syntax table
;;; entries for the comments overrides the font-lock keywords.
;;;
;;; Code:
(defvar hex0-mode-hook nil)
(defvar hex0-mode-map
(make-keymap)
"Keymap for hex0 major mode.")
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.hex0\\'" . hex0-mode))
(defconst hex0-font-lock-keywords
(list
'("\\<\\([0-9a-fA-F]\\{2\\}\\)\\>" . font-lock-variable-name-face)
'("\\<\\(a\\(?:a[adms]\\|d[cd]\\|nd\\|rpl\\)\\|b\\(?:ound\\|s\\(?:wap\\|[fr]\\)\\|t[crs]?\\)\\|c\\(?:all\\|bw\\|dq\\|l\\(?:ts\\|[cdi]\\)\\|m\\(?:p\\(?:s\\|xchg\\)\\|[cp]\\)\\|wde?\\)\\|d\\(?:a[as]\\|ec\\|iv\\)\\|e\\(?:nter\\|sc\\)\\|fwait\\|hlt\\|i\\(?:div\\|mul\\|n\\(?:to\\|v\\(?:d\\|lpg\\)\\|[cst]\\)?\\|retd?\\)\\|j\\(?:ae\\|be\\|cxz\\|ecxz\\|ge\\|le\\|mp\\|n\\(?:[abgl]e\\|[abceglopsz]\\)\\|p[eo]\\|[abceglopsz]\\)\\|l\\(?:a\\(?:hf\\|r\\)\\|ds\\|e\\(?:ave\\|[as]\\)\\|fs\\|g\\(?:dt\\|s\\)\\|idt\\|ldt\\|msw\\|o\\(?:ck\\|ds\\|op\\(?:n[ez]\\|[ez]\\)?\\)\\|s[ls]\\|tr\\)\\|m\\(?:ov\\(?:sx?\\|zx\\)?\\|ul\\)\\|n\\(?:eg\\|o[pt]\\)\\|o\\(?:r\\|uts?\\)\\|p\\(?:op\\(?:[af]d\\|[af]\\)?\\|ush\\(?:[af]d\\|[af]\\)?\\)\\|r\\(?:c[lr]\\|e\\(?:p\\(?:n[ez]\\|[ez]\\)\\|tf\\|[pt]\\)\\|o[lr]\\)\\|s\\(?:a\\(?:hf\\|[lr]\\)\\|bb\\|cas\\|et\\(?:ae\\|be\\|ge\\|le\\|n\\(?:[agl]e\\|[abceglopsz]\\)\\|p[eo]\\|[bceglopsz]\\)\\|gdt\\|h\\(?:[lr]d\\|[lr]\\)\\|idt\\|ldt\\|msw\\|t\\(?:os\\|[cdir]\\)\\|ub\\)\\|test\\|ver[rw]\\|w\\(?:ait\\|binv\\)\\|x\\(?:chg\\|latb?\\|or\\)\\)\\>". font-lock-builtin-face)))
(defvar hex0-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?\; "<" st)
;; (modify-syntax-entry ?# "<" st)
(modify-syntax-entry ?\n ">" st)
st)
"Syntax table in hex0-mode.")
(defun hex0-mode ()
"Major mode to add syntax highlighting to hex0 code."
(interactive)
(kill-all-local-variables)
(set-syntax-table hex0-mode-syntax-table)
(use-local-map hex0-mode-map)
(set (make-local-variable 'font-lock-defaults) '(hex0-font-lock-keywords))
(setq major-mode 'hex0-mode)
(setq mode-name "hex0")
(run-hooks 'hex0-mode-hook))
(provide 'hex0-mode)
;;; hex0-mode.el ends here