on master help sign in
feat: add nasm language (#6068)
commita4049e6f55144f502a1d6d1538b690f3e24524ef authorMatthew Toohey <contact@mtoohey.com> dateSat 25 Feb 2023, 13:53 (4 years ago) parentf69bb41
5 files changed+157
book/src/generated/lang-support.md+1 languages.toml+13 runtime/queries/nasm/highlights.scm+126 runtime/queries/nasm/injections.scm+2 runtime/queries/nasm/textobjects.scm+15
book/src/generated/lang-support.md+1
@@ -85,6 +85,7 @@
8585| meson | ✓ | | ✓ | |
8686| mint | | | | `mint` |
8787| msbuild | ✓ | | ✓ | |
88+| nasm | ✓ | ✓ | | |
8889| nickel | ✓ | | ✓ | `nls` |
8990| nix | ✓ | | | `nil` |
9091| nu | ✓ | | | |
languages.toml+13
@@ -2218,3 +2218,16 @@ comment-token = "#"
22182218[[grammar]]
22192219name = "po"
22202220source = { git = "https://github.com/erasin/tree-sitter-po", rev = "417cee9abb2053ed26b19e7de972398f2da9b29e" }
2221+
2222+[[language]]
2223+name = "nasm"
2224+scope = "source.nasm"
2225+file-types = ["asm", "s", "S", "nasm"]
2226+injection-regex = "n?asm"
2227+roots = []
2228+comment-token = ";"
2229+indent = { tab-width = 8, unit = " " }
2230+
2231+[[grammar]]
2232+name = "nasm"
2233+source = { git = "https://github.com/naclsn/tree-sitter-nasm", rev = "a0db15db6fcfb1bf2cc8702500e55e558825c48b" }
runtime/queries/nasm/highlights.scmnew file+126
@@ -0,0 +1,126 @@
1+(comment) @comment
2+
3+(label) @label
4+
5+(preproc_expression) @keyword.directive
6+
7+[
8+ (line_here_token)
9+ (section_here_token)
10+] @variable.builtin
11+
12+(unary_expression
13+ operator: _ @operator)
14+(binary_expression
15+ operator: _ @operator)
16+(conditional_expression
17+ "?" @operator
18+ ":" @operator)
19+
20+[
21+ ":"
22+ ","
23+] @punctuation.delimiter
24+
25+[
26+ "("
27+ ")"
28+ "["
29+ "]"
30+ "{"
31+ "}"
32+] @punctuation.bracket
33+
34+(instruction_prefix) @keyword
35+(actual_instruction
36+ instruction: (word) @function)
37+
38+(call_syntax_expression
39+ base: (word) @function)
40+
41+(size_hint) @type
42+(struc_declaration
43+ name: (word) @type)
44+(struc_instance
45+ name: (word) @type)
46+
47+(effective_address
48+ hint: _ @type)
49+(effective_address
50+ segment: _ @constant.builtin)
51+
52+(register) @constant.builtin
53+
54+(number_literal) @constant.numeric.integer
55+(string_literal) @string
56+(float_literal) @constant.numeric.float
57+(packed_bcd_literal) @constant.numeric.integer
58+
59+((word) @constant
60+ (#match? @constant "^[A-Z_][?A-Z_0-9]+$"))
61+((word) @constant.builtin
62+ (#match? @constant.builtin "^__\\?[A-Z_a-z0-9]+\\?__$"))
63+(word) @variable
64+
65+(preproc_arg) @keyword.directive
66+
67+[
68+ (preproc_def)
69+ (preproc_function_def)
70+ (preproc_undef)
71+ (preproc_alias)
72+ (preproc_multiline_macro)
73+ (preproc_multiline_unmacro)
74+ (preproc_if)
75+ (preproc_rotate)
76+ (preproc_rep_loop)
77+ (preproc_include)
78+ (preproc_pathsearch)
79+ (preproc_depend)
80+ (preproc_use)
81+ (preproc_push)
82+ (preproc_pop)
83+ (preproc_repl)
84+ (preproc_arg)
85+ (preproc_stacksize)
86+ (preproc_local)
87+ (preproc_reporting)
88+ (preproc_pragma)
89+ (preproc_line)
90+ (preproc_clear)
91+] @keyword.directive
92+[
93+ (pseudo_instruction_dx)
94+ (pseudo_instruction_resx)
95+ (pseudo_instruction_incbin_command)
96+ (pseudo_instruction_equ_command)
97+ (pseudo_instruction_times_prefix)
98+ (pseudo_instruction_alignx_macro)
99+] @function.special
100+[
101+ (assembl_directive_target)
102+ (assembl_directive_defaults)
103+ (assembl_directive_sections)
104+ (assembl_directive_absolute)
105+ (assembl_directive_symbols)
106+ (assembl_directive_common)
107+ (assembl_directive_symbolfixes)
108+ (assembl_directive_cpu)
109+ (assembl_directive_floathandling)
110+ (assembl_directive_org)
111+ (assembl_directive_sectalign)
112+
113+ (assembl_directive_primitive_target)
114+ (assembl_directive_primitive_defaults)
115+ (assembl_directive_primitive_sections)
116+ (assembl_directive_primitive_absolute)
117+ (assembl_directive_primitive_symbols)
118+ (assembl_directive_primitive_common)
119+ (assembl_directive_primitive_symbolfixes)
120+ (assembl_directive_primitive_cpu)
121+ (assembl_directive_primitive_floathandling)
122+ (assembl_directive_primitive_org)
123+ (assembl_directive_primitive_sectalign)
124+ (assembl_directive_primitive_warning)
125+ (assembl_directive_primitive_map)
126+] @keyword
runtime/queries/nasm/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/nasm/textobjects.scmnew file+15
@@ -0,0 +1,15 @@
1+(preproc_multiline_macro
2+ body: (body) @function.inside) @function.around
3+(struc_declaration
4+ body: (struc_declaration_body) @class.inside) @class.around
5+(struc_instance
6+ body: (struc_instance_body) @class.inside) @class.around
7+
8+(preproc_function_def_parameters
9+ (word) @parameter.inside)
10+(call_syntax_arguments
11+ (_) @parameter.inside)
12+(operand) @parameter.inside
13+
14+(comment) @comment.inside
15+(comment)+ @comment.around