Skip to content

Commit

Permalink
新增:内置语法 JavaScript v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guobao2333 committed Sep 2, 2024
1 parent 98d2eb0 commit f177cd7
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mtsx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
- [gitignore](gitignore.mtsx)
- [vimscript](vim.mtsx)

<!-- ## Builtin | 内置语法
## Builtin | 内置语法
> [!NOTE]
> 内置语法是原本在MT管理器中的已有语法。
> 而我只是为其添加了一些配色,在后续可能会对语法进行一些细节调整,但目前待定。
> 而我只是为其添加了一些额外语法/配色,在后续可能会对语法进行一些细节调整,但目前待定。
<!--
- [Markdown](builtin/Markdown.mtsx)
- [JavaScript](builtin/JavaScript.mtsx)
-->
- [JavaScript++](builtin/JavaScript.mtsx)


[^GFM]: [GitHub Flavored Markdown](https://github.github.com/gfm)(通常缩写为 GFM)是 Markdown 的方言。该正式规范基于 [CommonMark](https://commonmark.org) 规范,定义了该方言的语法和语义。
84 changes: 84 additions & 0 deletions mtsx/builtin/JavaScript.mtsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 此文件为内置语法,仅对配色进行调整
// 当语法更新时,我会同步跟进
// 有bug请找bin修,我只负责调整和优化
{
name: ["JavaScript++", ".js", ".es", ".mjs"]
comment: {startsWith: "//"}
comment: {startsWith: "/*", endsWith: "*/"}
defines: [
"single-quoted-string": {
style: "string"
start: {match: /'/}
end: {match: /(?m)'|$/}
contains: [
{match: /\\\n/, 0: "strEscape"}
{builtin: #JAVA_ESCAPED_CHAR#}
]
}
"double-quoted-string": {
style: "string"
start: {match: /"/}
end: {match: /(?m)"|$/}
contains: [
{match: /\\\n/, 0: "strEscape"}
{builtin: #JAVA_ESCAPED_CHAR#}
]
}
"backtick-string": {
style: "string"
start: {match: /`/}
end: {match: /`/}
contains: [
{match: /\\`/, 0: "strEscape"}
{builtin: #JAVA_ESCAPED_CHAR#}
{include: "dollarExp"}
]
}
"regex": {
start: {match: /(?<=(?:[=,(&|!:;]|^|\breturn)\s{0,20})/ + "/"}
end: {match: "/" + /([img]*)/, 1: "operator"}
style: "meta"
contains: [
{match: /\\./, 0: "strEscape"}
{
start: {match: /\[/}
end: {match: /\]/}
contains: [
{match: /\\./, 0: "strEscape"}
]
}
]
}
"dollarExp": {
start: {match: /\$\{/}
end: {match: /\}/}
style: "strEscape"
contains: [
{include: "single-quoted-string"}
{include: "double-quoted-string"}
{include: "regex"}
{include: "backtick-string"}
{include: "dollarExp"}
]
}
]
contains: [
{include: "single-quoted-string"}
{include: "double-quoted-string"}
{include: "regex"}
{include: "backtick-string"}
{builtin: #JAVA_NUMBER#}
{match: /\basync(?=\s+function\b)/, 0: "keyword"}
{match: keywordsToRegex(
"break case catch class const continue debugger default delete do else enum export async await"
"extends false finally for function if implements import instanceof interface let"
"new null package private protected public return static super switch this with"
"throw true try typeof var void while yield function of import in from as"
), 0: "keyword"
}
{match: keywordsToRegex("Date Function Array String Math BigInt Set Object console globalThis"),0:"namespace"}
{match: keywordsToRegex("prototype Infinity NaN undefined"),0:"variable"}
{match: keywordsToRegex("Error AggregateError EvalError RangeError ReferenceError SynatxError TypeError URIError InternalError"),0:"error"}
]
codeFormatter: #BUILT_IN_JS_FORMATTER#
}

0 comments on commit f177cd7

Please sign in to comment.