init
This commit is contained in:
		
							parent
							
								
									f4320afa13
								
							
						
					
					
						commit
						55e62a7975
					
				| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					#+OPTIONS: toc:nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* ztl-mode
 | 
				
			||||||
 | 
					:PROPERTIES:
 | 
				
			||||||
 | 
					:CUSTOM_ID: ztl-mode
 | 
				
			||||||
 | 
					:END:
 | 
				
			||||||
 | 
					ZTL mode for Emacs
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,74 @@
 | 
				
			||||||
 | 
					;;; ztl-mode.el --- Zongor's Transpiler Language (ZTL) mode for Emacs                     -*- lexical-binding: t; -*-
 | 
				
			||||||
 | 
					;; Author: Zongor
 | 
				
			||||||
 | 
					;; Version: 0.0.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defconst ztl-mode-hook nil
 | 
				
			||||||
 | 
					  "Hook for Zongor's Transpiler Language mode.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defconst ztl-file-extensions '(".ztl")
 | 
				
			||||||
 | 
					  "List of file extensions for Zongor's Transpiler Language.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defconst ztl-keywords
 | 
				
			||||||
 | 
					  '("fn" "to" "in" "is" "as" "use" "set" "if" "else" "for" "loop" "while"
 | 
				
			||||||
 | 
					    "push" "pop" "return" "const" "type" "this" "do" "end" "then" "result"
 | 
				
			||||||
 | 
					    "function" "eq" "ne" "mod" "not" "and" "or" "xor" "band" "bor" "bxor"
 | 
				
			||||||
 | 
					    "srl" "sll")
 | 
				
			||||||
 | 
					  "List of Zongor's Transpiler Language keywords.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defconst ztl-keywords-2
 | 
				
			||||||
 | 
					  '("char" "str" "f16" "f32" "f64" "f128")
 | 
				
			||||||
 | 
					  "List of Zongor's Transpiler Language secondary keywords.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defconst ztl-literals
 | 
				
			||||||
 | 
					  '("true" "false")
 | 
				
			||||||
 | 
					  "List of Zongor's Transpiler Language literals.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					;;;###autoload
 | 
				
			||||||
 | 
					(define-derived-mode ztl-mode prog-mode "ZTL"
 | 
				
			||||||
 | 
					  "Major mode for editing Zongor's Transpiler Language (ZTL)."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ;; File extension
 | 
				
			||||||
 | 
					  (setq auto-mode-alist
 | 
				
			||||||
 | 
					        (cons (cons ztl-file-extensions 'ztl-mode) auto-mode-alist))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ;; Comments
 | 
				
			||||||
 | 
					  (setq comment-start "!")
 | 
				
			||||||
 | 
					  (setq comment-end "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ;; Font Lock
 | 
				
			||||||
 | 
					  (set (make-local-variable 'font-lock-defaults)
 | 
				
			||||||
 | 
					       '((ztl-font-lock-keywords)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ;; Whitespace
 | 
				
			||||||
 | 
					  (set (make-local-variable 'whitespace-line-column)
 | 
				
			||||||
 | 
					       80)
 | 
				
			||||||
 | 
					  (whitespace-mode 1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defconst ztl-font-lock-keywords
 | 
				
			||||||
 | 
					  `(
 | 
				
			||||||
 | 
					    ;; Comments
 | 
				
			||||||
 | 
					    ("^!.*" . font-lock-comment-face)
 | 
				
			||||||
 | 
					    ("!!.*!!" . font-lock-comment-face)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ;; Strings
 | 
				
			||||||
 | 
					    ("\\(\"\\([^\\\\\"]\\\\?.*?\\)\"\\|'\\([^\\\\']\\\\?.*?\\)'\\)" 1 font-lock-string-face)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ;; Operators
 | 
				
			||||||
 | 
					    (";" . font-lock-delimiter-face)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ;; Keywords
 | 
				
			||||||
 | 
					    ,@(mapcar (lambda (kw) `(,kw . font-lock-keyword-face)) ztl-keywords)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ;; Secondary keywords
 | 
				
			||||||
 | 
					    ,@(mapcar (lambda (kw) `(,kw . font-lock-keyword-face)) ztl-keywords-2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ;; Literals
 | 
				
			||||||
 | 
					    ,@(mapcar (lambda (lit) `(,lit . font-lock-builtin-face)) ztl-literals)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ;; Function definitions
 | 
				
			||||||
 | 
					    ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\s*(\\)" 1 font-lock-function-name-face)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					;; Example usage in .emacs or init.el:
 | 
				
			||||||
 | 
					;; (add-to-list 'auto-mode-alist '("\\.ztl$" . ztl-mode))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(provide 'ztl-mode)
 | 
				
			||||||
		Loading…
	
		Reference in New Issue