-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from zilch-lang/develop
Stabilize features for the v2.2.0
- Loading branch information
Showing
61 changed files
with
902 additions
and
206 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
;;; nstar-mode.el --- Major mode for N* | ||
;; SPDX-License-Identifier: BSD3 License | ||
|
||
;;; Commentary: | ||
|
||
;; A major mode providing some syntax highlighting for the typed assembly language N*. | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;;; Dependency | ||
|
||
;;; Code: | ||
|
||
(defgroup nstar nil | ||
"Major mode for editing N* code." | ||
:link '(custom-group-link :tag "Font lock faces group" font-lock-faces) | ||
:group 'languages) | ||
|
||
(defconst nstar-font-lock-keywords | ||
'( | ||
("^\\([ \t]*\\)\\(\\(\\sw\\|\\s_\\)+\\):" | ||
2 font-lock-function-name-face) | ||
;; function definition | ||
("\\b\\(forall\\|unsafe\\|section\\|include\\)\\b" | ||
1 font-lock-keyword-face) | ||
;; keywords | ||
("%r[0-5]" . | ||
font-lock-variable-name-face) | ||
;; registers | ||
("\\b\\(mv\\|st\\|ld\\|salloc\\|sld\\|sst\\|call\\|ret\\|jmp\\|jz\\|dec\\|inc\\|sfree\\|mul\\|nop\\|sref\\)\\b" | ||
1 font-lock-builtin-face) | ||
;; instructions | ||
("\\b\\(T\\(a\\|c\\|s\\|[0-9]+\\)\\|s\\(8\\|16\\|32\\|64\\)\\|u\\(8\\|16\\|32\\|64\\)\\)\\b" | ||
1 font-lock-type-face) | ||
;; builtin types | ||
) | ||
"Additional expressions to highlight in N* mode.") | ||
|
||
(defvar nstar-mode-syntax-table | ||
(let ((st (make-syntax-table))) | ||
(modify-syntax-entry ?\n "> b" st) | ||
(modify-syntax-entry ?/ ". 124b" st) | ||
(modify-syntax-entry ?* ". 23" st) | ||
(modify-syntax-entry ?# "< b" st) | ||
(modify-syntax-entry ?_ "w" st) | ||
(modify-syntax-entry ?\" "|" st) | ||
(modify-syntax-entry ?' "|" st) | ||
st) | ||
"Syntax table used while in N* mode.") | ||
|
||
;;;###autoload | ||
(add-to-list 'auto-mode-alist '("\\.nst\\'" . nstar-mode)) | ||
;;;###autoload | ||
(modify-coding-system-alist 'file "\\.nst\\'" 'utf-8) | ||
;;;###autoload | ||
(define-derived-mode nstar-mode prog-mode "N*" | ||
"Major mode for editing simple N* source files. | ||
Only provides syntax highlighting." | ||
|
||
(setq-local font-lock-defaults '(nstar-font-lock-keywords)) | ||
(set-syntax-table (make-syntax-table nstar-mode-syntax-table)) | ||
|
||
(setq-local comment-start "#") | ||
(setq-local comment-add 1) | ||
(setq-local comment-end "") | ||
|
||
(setq-local comment-start-skip "\\(?:\\s<+\\|/[/*]+\\)[ \t]*") | ||
(setq-local comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)") | ||
|
||
(setq-local comment-multi-line 1) | ||
) | ||
|
||
|
||
(provide 'nstar-mode) | ||
|
||
;;; nstar-mode.el ends here |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# -*- nstar -*- | ||
|
||
### x86-amd64 code driver | ||
|
||
section code { | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- nstar -*- | ||
|
||
section extern.code { | ||
puts: forall(s: Ts, e: Tc).{ %r4: !, %r5: *s64 | forall().{ %r0: u64 | s -> e }::s -> 0 } | ||
} | ||
|
||
include { | ||
"amd64-driver.nst" | ||
} | ||
|
||
section data { | ||
test_str: *s8 = # [ 'H' 'e' 'l' 'l' 'o' ',' ' ' 'w' 'o' 'r' 'l' 'd' '!' '\0' ] | ||
"Hello, world!" | ||
} | ||
|
||
section code { | ||
_main: forall(s: Ts, e: Tc).{ %r5: forall().{ %r0: u64 | s -> e } | s -> %r5 } | ||
= mv %r5, %r3 | ||
; mv puts_ret<s, e>, %r5 | ||
; salloc forall().{ %r0: !, %r3: forall().{ %r0: u64 | s -> e } | s -> %r3 } | ||
; sst %r5, 0 | ||
; mv test_str, %r5 | ||
; call puts<s, %r3> | ||
puts_ret: forall(s: Ts, e: Tc).{ %r3: forall().{ %r0: u64 | s -> e } | s -> %r3 } | ||
= mv 0, %r0 | ||
; ret | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# -*- nstar -*- | ||
|
||
include { | ||
"amd64-driver.nst" | ||
} | ||
|
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
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
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
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
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
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
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
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
Oops, something went wrong.