-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,101 @@ | ||
// mindustry logic bang lang 的语法高亮规则 | ||
// https://github.com/A4-Tacks/mindustry_logic_bang_lang | ||
{ | ||
name: ["MindustryLogicBangLang", ".mdtlbl"], | ||
name: ["MindustryLogicBangLang", ".mdtlbl"] | ||
// no hidden | ||
hide: false, | ||
comment: { startsWith: "#", addToContains: false }, | ||
hide: false | ||
comment: { startsWith: "#", addToContains: false } | ||
defines: [ | ||
"ws": /(?:[\s\r\n]*)/ | ||
] | ||
contains: [ | ||
{ | ||
// long comments | ||
start: { match: /#\*/ }, | ||
end: { match: /\*#/ }, | ||
{ // long comments | ||
start: { match: /#\*/ } | ||
end: { match: /\*#/ } | ||
color: "comment" | ||
}, | ||
{ | ||
// inline comments | ||
start: { match: /#/ }, | ||
end: { match: /\n|$/ }, | ||
} | ||
{ // inline comments | ||
start: { match: /#(?!=\*)/ } | ||
end: { match: /(?=\n|$)/ } | ||
color: "comment" | ||
|
||
}, | ||
{ | ||
// number | ||
match: /\b(?:0(?:x-?[\da-fA-F][_\da-fA-F]*|b-?[01][_01]*)/ | ||
+ /|-?\d[_\d]*(?:\.\d[\d_]*|e[+\-]?\d[\d_]*)?)\b/, | ||
} | ||
{ // number | ||
match: /(?:\b0(?:x\-?[\da-fA-F][\da-fA-F_]*|b\-?[01][_01]*)/ | ||
+ /|\-?\b\d[0-9_]*(?:\.\d[\d_]*|e[+\-]?\d[\d_]*)?)\b/ | ||
0: "number" | ||
} | ||
{ // boolean | ||
match: /\b(?:true|false)\b/ | ||
0: "number" | ||
}, | ||
{ | ||
// string | ||
match: /"(?:(\\n)|[^"])*"/, | ||
0: "string", | ||
1: "strEscape" | ||
}, | ||
{ | ||
// 元标识符,由于MT管理器的正则并没有\i \I \p [[:idnet:]]等匹配标识符的手段 | ||
// 只能手动枚举ASCII字符 | ||
match: /@[a-zA-Z_][a-zA-Z0-9_\-]*/, | ||
} | ||
{ // 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']*'/, | ||
} | ||
{ // 原始标识符 | ||
match: /'[^\s']+'/ | ||
0: "constant" | ||
}, | ||
{ | ||
// control | ||
} | ||
{ // control | ||
match: keywordsToRegex( | ||
"while gwhile do skip goto if elif else switch case" | ||
"select break continue" | ||
), | ||
) | ||
0: "keyword" | ||
}, | ||
} | ||
{ // 返回句柄替换符 | ||
match: /\$/, | ||
match: /\$/ | ||
0: "keyword2" | ||
}, | ||
{ | ||
// other | ||
} | ||
{ // other | ||
match: keywordsToRegex( | ||
"const take setres inline print set op noop" | ||
), | ||
) | ||
0: "keyword2" | ||
}, | ||
{ | ||
// operator | ||
} | ||
{ // operator | ||
match: keywordsToRegex( | ||
"abs", "acos", "add", "and", "angle", "asin", "atan", "ceil", | ||
"cos", "div", "equal", "floor", "greaterThan", "greaterThanEq", | ||
"idiv", "land", "len", "lessThan", "lessThanEq", "lnot", "log", | ||
"max", "min", "mod", "mul", "noise", "not", "notEqual", "or", | ||
"pow", "rand", "shl", "shr", "sin", "sqrt", "strictEqual", | ||
"strictNotEqual", "sub", "tan", "xor", | ||
), | ||
"abs acos add and angle asin atan ceil" | ||
"cos div equal floor greaterThan greaterThanEq" | ||
"idiv land len lessThan lessThanEq lnot log" | ||
"max min mod mul noise not notEqual or" | ||
"pow rand shl shr sin sqrt strictEqual" | ||
"strictNotEqual sub tan xor" | ||
) | ||
0: "tagName" | ||
}, | ||
{ | ||
// label | ||
match: /:(?:[a-zA-Z]|[a-zA-Z_][a-zA-Z0-9_]+)\b/, | ||
} | ||
{ // 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_\-]*)?/+include("ws")+/\[|\])/ | ||
0: "variable" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters