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

Commit c3fa148

Browse files
committed
tool: add basic TextMate grammar
1 parent bdf7e75 commit c3fa148

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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": "#true-false"
25+
},
26+
{
27+
"include": "#numbers"
28+
},
29+
{
30+
"include": "#strings"
31+
},
32+
{
33+
"include": "#declarations"
34+
}
35+
],
36+
"repository": {
37+
"comments": {
38+
"patterns": [
39+
{
40+
"name": "comment.line.double-slash.core",
41+
"match": "^\\s*(?=//).*$"
42+
},
43+
{
44+
"begin": "/\\*",
45+
"end": "\\*/",
46+
"name": "comment.block.core"
47+
}
48+
]
49+
},
50+
"operators": {
51+
"patterns": [
52+
{
53+
"name": "keyword.operator.core",
54+
"match": "\\b(==|!=|>=|<=|\\&|\\*|=|>|<|-|\\+|/)\\b"
55+
}
56+
]
57+
},
58+
"keywords": {
59+
"patterns": [
60+
{
61+
"name": "keyword.control.core",
62+
"match": "\\b(else|if|for|return|while)\\b"
63+
},
64+
{
65+
"name": "keyword.other.core",
66+
"match": "\\b(const|class|value|union|enum|trait|impl|annotation|use|mod|is)\\b"
67+
}
68+
]
69+
},
70+
"annotations": {
71+
"patterns": [
72+
{
73+
"name": "meta.tag.core",
74+
"match": "(?<!\\w)@[\\w\\.]+\\b"
75+
}
76+
]
77+
},
78+
"true-false": {
79+
"patterns": [
80+
{
81+
"name": "constant.language.core",
82+
"match": "\\b(true|false)\\b"
83+
}
84+
]
85+
},
86+
"numbers": {
87+
"patterns": [
88+
{
89+
"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)(?!\\$)",
90+
"name": "constant.numeric.decimal.core"
91+
},
92+
{
93+
"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(?!\\$)",
94+
"name": "constant.numeric.hex.core"
95+
},
96+
{
97+
"match": "\\b(?<!\\$)0(b|B)[01]([01']*[01])?(i32|i64|u8|f32|f64)?\\b(?!\\$)",
98+
"name": "constant.numeric.binary.core"
99+
}
100+
]
101+
},
102+
"strings": {
103+
"patterns": [
104+
{
105+
"begin": "\"",
106+
"end": "\"",
107+
"name": "string.quoted.double.core"
108+
}
109+
]
110+
},
111+
"declarations": {
112+
"patterns": [
113+
{
114+
"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]*)))?",
115+
"captures": {
116+
"1": {
117+
"name": "keyword.declaration.core"
118+
},
119+
"2": {
120+
"name": "entity.name.function.declaration.core"
121+
}
122+
}
123+
},
124+
{
125+
"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]*)))?",
126+
"captures": {
127+
"1": {
128+
"name": "keyword.declaration.core"
129+
},
130+
"2": {
131+
"name": "entity.name.function.declaration.core"
132+
}
133+
}
134+
},
135+
{
136+
"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]*)))?",
137+
"captures": {
138+
"1": {
139+
"name": "keyword.declaration.core"
140+
},
141+
"2": {
142+
"name": "entity.name.function.declaration.core"
143+
}
144+
}
145+
}
146+
]
147+
}
148+
}
149+
}

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)