moxie.tmLanguage.json raw
1 {
2 "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3 "name": "Moxie",
4 "scopeName": "source.moxie",
5 "fileTypes": ["mx"],
6 "patterns": [
7 { "include": "#pragmas" },
8 { "include": "#comments" },
9 { "include": "#raw-strings" },
10 { "include": "#strings" },
11 { "include": "#rune-literals" },
12 { "include": "#numbers" },
13 { "include": "#func-declaration" },
14 { "include": "#type-declaration" },
15 { "include": "#keywords" },
16 { "include": "#builtin-types" },
17 { "include": "#builtin-functions" },
18 { "include": "#removed-names" },
19 { "include": "#constants" },
20 { "include": "#operators" },
21 { "include": "#identifiers" }
22 ],
23 "repository": {
24 "pragmas": {
25 "patterns": [
26 {
27 "name": "meta.pragma.moxie",
28 "match": "^\\s*(//:build|//:generate|//:linkname|//:extern|//:inline|//:noinline|//:wasmexport|//:section|//:align|//export)\\b.*$"
29 },
30 {
31 "name": "meta.pragma.moxie",
32 "match": "^\\s*(//go:[a-z]+)\\b.*$"
33 }
34 ]
35 },
36 "comments": {
37 "patterns": [
38 {
39 "name": "comment.line.double-slash.moxie",
40 "match": "//.*$"
41 },
42 {
43 "name": "comment.block.moxie",
44 "begin": "/\\*",
45 "end": "\\*/"
46 }
47 ]
48 },
49 "raw-strings": {
50 "name": "string.quoted.backtick.moxie",
51 "begin": "`",
52 "end": "`"
53 },
54 "strings": {
55 "name": "string.quoted.double.moxie",
56 "begin": "\"",
57 "end": "\"",
58 "patterns": [
59 {
60 "name": "constant.character.escape.moxie",
61 "match": "\\\\[abfnrtv\\\\'\"0-7xuU]"
62 }
63 ]
64 },
65 "rune-literals": {
66 "name": "string.quoted.single.moxie",
67 "begin": "'",
68 "end": "'",
69 "patterns": [
70 {
71 "name": "constant.character.escape.moxie",
72 "match": "\\\\."
73 }
74 ]
75 },
76 "numbers": {
77 "patterns": [
78 {
79 "name": "constant.numeric.imaginary.moxie",
80 "match": "\\b[0-9][0-9_]*(\\.[0-9_]*)?([eE][+-]?[0-9_]+)?i\\b"
81 },
82 {
83 "name": "constant.numeric.hex.moxie",
84 "match": "\\b0[xX][0-9a-fA-F_]+(\\.[0-9a-fA-F_]*)?([pP][+-]?[0-9_]+)?\\b"
85 },
86 {
87 "name": "constant.numeric.binary.moxie",
88 "match": "\\b0[bB][01_]+\\b"
89 },
90 {
91 "name": "constant.numeric.octal.moxie",
92 "match": "\\b0[oO][0-7_]+\\b"
93 },
94 {
95 "name": "constant.numeric.float.moxie",
96 "match": "\\b[0-9][0-9_]*\\.[0-9_]*([eE][+-]?[0-9_]+)?\\b"
97 },
98 {
99 "name": "constant.numeric.float.moxie",
100 "match": "\\b[0-9][0-9_]*[eE][+-]?[0-9_]+\\b"
101 },
102 {
103 "name": "constant.numeric.integer.moxie",
104 "match": "\\b[0-9][0-9_]*\\b"
105 }
106 ]
107 },
108 "func-declaration": {
109 "patterns": [
110 {
111 "name": "meta.function.moxie",
112 "begin": "\\b(func)\\s+(\\([^)]*\\)\\s+)?([A-Za-z_][A-Za-z0-9_]*)",
113 "beginCaptures": {
114 "1": { "name": "storage.type.func.moxie" },
115 "2": { "name": "meta.receiver.moxie" },
116 "3": { "name": "entity.name.function.moxie" }
117 },
118 "end": "(?<=\\{)|$",
119 "patterns": [
120 { "include": "#parameters" },
121 { "include": "#builtin-types" },
122 { "include": "#identifiers" }
123 ]
124 }
125 ]
126 },
127 "parameters": {
128 "patterns": [
129 {
130 "name": "variable.parameter.moxie",
131 "match": "\\b[A-Za-z_][A-Za-z0-9_]*(?=\\s+[\\[\\*\\.A-Za-z_])"
132 },
133 {
134 "name": "punctuation.separator.moxie",
135 "match": "[,\\(\\)\\*\\[\\]]"
136 }
137 ]
138 },
139 "type-declaration": {
140 "patterns": [
141 {
142 "name": "meta.type.moxie",
143 "match": "\\b(type)\\s+([A-Za-z_][A-Za-z0-9_]*)",
144 "captures": {
145 "1": { "name": "storage.type.type.moxie" },
146 "2": { "name": "entity.name.type.moxie" }
147 }
148 }
149 ]
150 },
151 "keywords": {
152 "patterns": [
153 {
154 "name": "keyword.control.moxie",
155 "match": "\\b(break|case|continue|default|defer|else|for|goto|if|range|return|select|switch)\\b"
156 },
157 {
158 "name": "keyword.other.moxie",
159 "match": "\\b(chan|const|func|import|interface|map|package|struct|var)\\b"
160 },
161 {
162 "name": "constant.language.moxie",
163 "match": "\\b(true|false|nil|iota)\\b"
164 }
165 ]
166 },
167 "builtin-types": {
168 "patterns": [
169 {
170 "name": "support.type.moxie",
171 "match": "\\b(bool|byte|rune|string|error|uintptr|comparable|any|int8|int16|int32|int64|uint8|uint16|uint32|uint64|float32|float64)\\b"
172 },
173 {
174 "name": "support.type.unsafe.moxie",
175 "match": "\\bunsafe\\.(Pointer|Sizeof|Offsetof|Alignof|Slice|SliceData|String|StringData|TypeOf)\\b"
176 }
177 ]
178 },
179 "builtin-functions": {
180 "patterns": [
181 {
182 "name": "support.function.moxie",
183 "match": "\\b(push|pop|resize|len|cap|copy|delete|close|clear|min|max|panic|recover|print|println|spawn)\\b(?=\\s*\\()"
184 }
185 ]
186 },
187 "removed-names": {
188 "comment": "Names Go has and Moxie does not: not predeclared, they resolve as undefined (a user may declare their own).",
189 "patterns": [
190 {
191 "name": "invalid.illegal.removed.moxie",
192 "match": "\\b(int|uint|complex64|complex128)\\b(?=\\s*[;,)\\]\\}={]|\\s+[A-Za-z_(\\[\\*])"
193 },
194 {
195 "name": "invalid.deprecated.removed.moxie",
196 "match": "\\b(make|new|append|complex|real|imag|reflect)\\b(?=\\s*[\\(.;,)\\]])"
197 }
198 ]
199 },
200 "constants": {
201 "patterns": [
202 {
203 "name": "constant.other.placeholder.moxie",
204 "match": "%[+#\\- 0]*[0-9]*(\\.[0-9]+)?[a-zA-Z%]"
205 }
206 ]
207 },
208 "operators": {
209 "patterns": [
210 {
211 "name": "keyword.operator.moxie",
212 "match": "<-|\\.\\.\\.|&&|\\|\\||==|!=|<=|>=|<<|>>|&\\^|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|<<=|>>=|&\\^=|:=|\\+\\+|--"
213 },
214 {
215 "name": "keyword.operator.moxie",
216 "match": "[+\\-*/%&|^<>=!:~]"
217 },
218 {
219 "name": "punctuation.moxie",
220 "match": "[,;.()\\[\\]{}]"
221 }
222 ]
223 },
224 "identifiers": {
225 "patterns": [
226 {
227 "name": "entity.name.type.moxie",
228 "match": "\\b[A-Z][A-Za-z0-9_]*\\b"
229 }
230 ]
231 }
232 }
233 }
234