Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit d3e4295

Browse files
committed
tool: add basic TextMate grammar
1 parent 3045694 commit d3e4295

File tree

2 files changed

+207
-0
lines changed

2 files changed

+207
-0
lines changed
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3+
"name": "Core",
4+
"scopeName": "source.core",
5+
"foldingStartMarker": "\\{\\s*$",
6+
"foldingStopMarker": "^\\s*\\}",
7+
"fileTypes": [
8+
"core"
9+
],
10+
"patterns": [
11+
{
12+
"include": "#comments"
13+
},
14+
{
15+
"include": "#operators"
16+
},
17+
{
18+
"include": "#keywords"
19+
},
20+
{
21+
"include": "#annotations"
22+
},
23+
{
24+
"include": "#literals-bool"
25+
},
26+
{
27+
"include": "#literals-char"
28+
},
29+
{
30+
"include": "#literals-number"
31+
},
32+
{
33+
"include": "#literals-string"
34+
},
35+
{
36+
"include": "#declarations-use"
37+
},
38+
{
39+
"include": "#declarations-mod"
40+
},
41+
{
42+
"include": "#declarations-member"
43+
}
44+
],
45+
"repository": {
46+
"comments": {
47+
"patterns": [
48+
{
49+
"name": "comment.line.double-slash.core",
50+
"match": "^\\s*(?=//).*$"
51+
},
52+
{
53+
"begin": "/\\*",
54+
"end": "\\*/",
55+
"name": "comment.block.core"
56+
}
57+
]
58+
},
59+
"operators": {
60+
"patterns": [
61+
{
62+
"name": "keyword.operator.core",
63+
"match": "===|!==|==|!=|>=|<=|&|\\*|>|<|-|\\+|\\/"
64+
}
65+
]
66+
},
67+
"keywords": {
68+
"patterns": [
69+
{
70+
"name": "keyword.control.core",
71+
"match": "\\b(if|else|is|for|in|while|return)\\b"
72+
},
73+
{
74+
"name": "keyword.other.core",
75+
"match": "\\b(const|class|value|union|enum|trait|impl|annotation)\\b"
76+
}
77+
]
78+
},
79+
"annotations": {
80+
"patterns": [
81+
{
82+
"name": "meta.tag.core",
83+
"match": "(?<!\\w)@[\\w\\.]+\\b"
84+
}
85+
]
86+
},
87+
"literals-bool": {
88+
"patterns": [
89+
{
90+
"name": "constant.language.core",
91+
"match": "\\b(true|false)\\b"
92+
}
93+
]
94+
},
95+
"literals-char": {
96+
"patterns": [
97+
{
98+
"begin": "'",
99+
"end": "'",
100+
"name": "string.quoted.single.core"
101+
}
102+
]
103+
},
104+
"literals-number": {
105+
"patterns": [
106+
{
107+
"match": "(?<!\\$)(\\b\\d([0-9']*\\d)?\\.\\B(?!\\.)|\\b\\d([0-9']*\\d)?\\.([Ee][+-]?\\d([0-9']*\\d)?)(i32|i64|u8|f32|f64)?\\b|\\b\\d([0-9']*\\d)?\\.([Ee][+-]?\\d([0-9']*\\d)?)?(i32|i64|u8|f32|f64)\\b|\\b\\d([0-9']*\\d)?\\.(\\d([0-9']*\\d)?)([Ee][+-]?\\d([0-9']*\\d)?)?(i32|i64|u8|f32|f64)?\\b|(?<!\\.)\\B\\.\\d([0-9']*\\d)?([Ee][+-]?\\d([0-9']*\\d)?)?(i32|i64|u8|f32|f64)?\\b|\\b\\d([0-9']*\\d)?([Ee][+-]?\\d([0-9']*\\d)?)(i32|i64|u8|f32|f64)?\\b|\\b\\d([0-9']*\\d)?([Ee][+-]?\\d([0-9']*\\d)?)?(i32|i64|u8|f32|f64)\\b|\\b(0|[1-9]([0-9']*\\d)?)(?!\\.)(i32|i64|u8|f32|f64)?\\b)(?!\\$)",
108+
"name": "constant.numeric.decimal.core"
109+
},
110+
{
111+
"match": "\\b(?<!\\$)0(x|X)((?<!\\.)[0-9a-fA-F]([0-9a-fA-F']*[0-9a-fA-F])?(i32|i64|u8|f32|f64)?(?!\\.)|([0-9a-fA-F]([0-9a-fA-F']*[0-9a-fA-F])?\\.?|([0-9a-fA-F]([0-9a-fA-F']*[0-9a-fA-F])?)?\\.[0-9a-fA-F]([0-9a-fA-F']*[0-9a-fA-F])?)[Pp][+-]?\\d([0-9']*\\d)?(i32|i64|u8|f32|f64)?)\\b(?!\\$)",
112+
"name": "constant.numeric.hex.core"
113+
},
114+
{
115+
"match": "\\b(?<!\\$)0(b|B)[01]([01']*[01])?(i32|i64|u8|f32|f64)?\\b(?!\\$)",
116+
"name": "constant.numeric.binary.core"
117+
}
118+
]
119+
},
120+
"literals-string": {
121+
"patterns": [
122+
{
123+
"begin": "\"",
124+
"end": "\"",
125+
"name": "string.quoted.double.core"
126+
}
127+
]
128+
},
129+
"declarations-use": {
130+
"patterns": [
131+
{
132+
"match": "\\b(use)\\b\\s*(?!//|/\\*)([^;]*)(;*)",
133+
"captures": {
134+
"1": {
135+
"name": "keyword.declaration.core"
136+
},
137+
"2": {
138+
"name": "string.quoted.double.core"
139+
}
140+
}
141+
}
142+
]
143+
},
144+
"declarations-mod": {
145+
"patterns": [
146+
{
147+
"match": "\\b(mod)\\b\\s*(?!//|/\\*)([^\\.,;]*)(;*)",
148+
"captures": {
149+
"1": {
150+
"name": "keyword.declaration.core"
151+
},
152+
"2": {
153+
"name": "string.quoted.double.core"
154+
}
155+
}
156+
}
157+
]
158+
},
159+
"declarations-member": {
160+
"patterns": [
161+
{
162+
"match": "\\b(fun)\\b\\s*(?!//|/\\*)((?:(?:[A-Z\\p{Lt}\\p{Lu}_a-z$\\p{Lo}\\p{Nl}\\p{Ll}][A-Z\\p{Lt}\\p{Lu}_a-z$\\p{Lo}\\p{Nl}\\p{Ll}0-9]*)))?",
163+
"captures": {
164+
"1": {
165+
"name": "keyword.declaration.core"
166+
},
167+
"2": {
168+
"name": "entity.name.function.declaration.core"
169+
}
170+
}
171+
},
172+
{
173+
"match": "\\b(let)\\b\\s*(?!//|/\\*)((?:(?:[A-Z\\p{Lt}\\p{Lu}_a-z$\\p{Lo}\\p{Nl}\\p{Ll}][A-Z\\p{Lt}\\p{Lu}_a-z$\\p{Lo}\\p{Nl}\\p{Ll}0-9]*)))?",
174+
"captures": {
175+
"1": {
176+
"name": "keyword.declaration.core"
177+
},
178+
"2": {
179+
"name": "entity.name.function.declaration.core"
180+
}
181+
}
182+
},
183+
{
184+
"match": "\\b(var)\\b\\s*(?!//|/\\*)((?:(?:[A-Z\\p{Lt}\\p{Lu}_a-z$\\p{Lo}\\p{Nl}\\p{Ll}][A-Z\\p{Lt}\\p{Lu}_a-z$\\p{Lo}\\p{Nl}\\p{Ll}0-9]*)))?",
185+
"captures": {
186+
"1": {
187+
"name": "keyword.declaration.core"
188+
},
189+
"2": {
190+
"name": "entity.name.function.declaration.core"
191+
}
192+
}
193+
}
194+
]
195+
}
196+
}
197+
}

tooling/core.tmbundle/info.plist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<key>name</key>
5+
<string>core</string>
6+
<key>description</key>
7+
<string>Core</string>
8+
<key>uuid</key>
9+
<string>96925448-7219-41E9-A7F0-8D5B70E9B877</string>
10+
</plist>

0 commit comments

Comments
 (0)