-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMindustryLogicBangLang.mtsx
More file actions
137 lines (136 loc) · 3.07 KB
/
MindustryLogicBangLang.mtsx
File metadata and controls
137 lines (136 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// mindustry logic bang lang 的语法高亮规则
// https://github.com/A4-Tacks/mindustry_logic_bang_lang
{
name: ["MindustryLogicBangLang", ".mdtlbl"]
// no hidden
hide: false
comment: { startsWith: "#", addToContains: false }
defines: [
"ws": /(?:[\s\r\n]*)/
]
contains: [
{ // long comments
start: { match: /#\*/ }
end: { match: /\*#/ }
color: "comment"
}
{ // inline comments
start: { match: /#(?!=\*)/ }
end: { match: /(?=\n|$)/ }
color: "comment"
}
{ // number
match: /-?(?:\b0x[+-]?[\da-fA-F][\da-fA-F_]*|0b[+-]?[01][_01]*/
+ /|\b\d[0-9_]*(?:\.\d[\d_]*|e[+\-]?\d[\d_]*)?)/
0: "number"
}
{ // boolean
match: /\b(?:true|false)\b/
0: "number"
}
{ // null
match: /\bnull\b/
0: "number"
}
{ // DExp result handle define
match: /\(/+include("ws")+/([a-zA-Z_][a-zA-Z0-9_\-]*:)/
1: "keyword2"
}
{ // string
start: {match: /"/}
end: {match: /"/}
color: "string"
contains: [
{ // string escape
match: /(?:(?<=\n)\s*\\ |\\(?:[n\[\\]|\r?\n)|(\\.))/
0: "strEscape"
1: "error"
}
{ // string color
match: /\[(?:#[\da-fA-F]{6,8}|(?:c(?:lear|yan|oral)|b(?:l(?:ack|ue)|r(?:own|ick))|white|li(?:ghtgray|me)|g(?:r(?:ay|een)|old(?:enrod)?)|darkgray|navy|r(?:oyal|ed)|s(?:late|ky|carlet|almon)|t(?:eal|an)|acid|forest|o(?:live|range)|yellow|p(?:ink|urple)|ma(?:genta|roon)|violet))?\]/
0: "strEscape"
}
]
}
{ // 元标识符
match: /@[a-zA-Z_][a-zA-Z0-9_\-]*/
0: "meta"
}
{ // 原始标识符
match: /'[^\s']+'/
0: "constant"
}
{ // 参数展开
match: /@/
0: "keyword"
}
{ // control can star
match: keywordsToRegex("case") + /\*?/
0: "keyword"
}
{ // control
match: keywordsToRegex(
"while gwhile do skip goto if elif else switch"
"select break continue"
)
0: "keyword"
}
{ // 返回句柄替换符
match: /\$/
0: "keyword2"
}
{ // 绑定者
match: /\.\./
0: "keyword2"
}
{ // other keywords can star
match: keywordsToRegex("take inline") + /\*?/
0: "keyword2"
}
{ // other keywords
match: keywordsToRegex(
"const match setres print set op noop"
)
0: "keyword2"
}
{ // operator
match: keywordsToRegex(
"abs sign acos add always and angle angleDiff asin atan ceil"
"round cos div equal floor greaterThan greaterThanEq"
"idiv land len lessThan lessThanEq lnot log logn log10"
"max min mod emod mul noise not notEqual or"
"pow rand shl shr ushr sin sqrt strictEqual"
"strictNotEqual sub tan xor"
)
0: "tagName"
}
{ // cmp operator
match: /[<>](?![<>])=?|[=!]==?/
0: "default"
}
{ // match fat arrow
match: /=>/
0: "keyword2"
}
{ // self inc and dec
match: /([+\-])\1/
0: "tagName"
}
{ // self operator
match: /(?:\/\/|\*\*|&&|<<|>>>?|[+\-*\/%|&^])?=/
0: "tagName"
}
{ // label
match: /:(?:[a-zA-Z]|[a-zA-Z_][a-zA-Z0-9_]+)\b/
0: "label"
}
{ // quick dexp take
match: /(?:(?:[a-zA-Z_][a-zA-Z0-9_]*)(?:!|(?:->)?\[)|[\[\]]|->|\b_\b)/
0: "variable"
}
{ // control operator
match: /&&|\|\||!/
0: "keyword"
}
]
}