feat: IDE支持 — workspace拆分、LSP服务器、VS Code扩展
**Workspace 拆分** - aster-core: 纯库,zero-dependency,包含 lexer/parser/ast/interpreter/error/analysis - aster: REPL 二进制,薄封装 aster-core - aster-lsp: LSP 语言服务器 **VS Code 扩展 (vscode-ext/)** - TextMate 语法高亮 (.ast 文件) - 语言配置 (注释切换、括号配对、自动缩进) - LSP 客户端 (extension.js) **LSP 服务端功能** - Diagnostics: 实时显示 lex/parse 错误红色波浪线 - Completion: 关键字 + 内置函数 + 用户定义符号补全 - Hover: 悬停显示变量/函数信息 - Signature Help: 函数参数提示 - Goto Definition: Ctrl+Click 跳转到声明处 - Find References: 查找所有引用位置 - Rename: F2 重命名符号 **新增 analysis 模块** - collect_symbols: AST 遍历收集符号 - find_declaration/find_all_references: Token 扫描定位声明和引用
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"name": "Aster",
|
||||
"scopeName": "source.aster",
|
||||
"fileTypes": ["ast"],
|
||||
"patterns": [
|
||||
{ "include": "#comments" },
|
||||
{ "include": "#strings" },
|
||||
{ "include": "#numbers" },
|
||||
{ "include": "#function-declaration" },
|
||||
{ "include": "#keywords" },
|
||||
{ "include": "#constants" },
|
||||
{ "include": "#builtins" },
|
||||
{ "include": "#operators" },
|
||||
{ "include": "#punctuation" },
|
||||
{ "include": "#identifiers" }
|
||||
],
|
||||
"repository": {
|
||||
"comments": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "comment.block.aster",
|
||||
"begin": "/\\*",
|
||||
"end": "\\*/",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "comment.block.aster",
|
||||
"match": "."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "comment.line.double-slash.aster",
|
||||
"match": "//.*$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"strings": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "string.quoted.double.aster",
|
||||
"begin": "\"",
|
||||
"end": "\"",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.character.escape.aster",
|
||||
"match": "\\\\[ntr\"\\\\]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "string.quoted.single.aster",
|
||||
"begin": "'",
|
||||
"end": "'",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.character.escape.aster",
|
||||
"match": "\\\\[ntr'\\\\]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"numbers": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.numeric.float.aster",
|
||||
"match": "\\b\\d+\\.\\d+\\b"
|
||||
},
|
||||
{
|
||||
"name": "constant.numeric.integer.aster",
|
||||
"match": "\\b\\d+\\b"
|
||||
}
|
||||
]
|
||||
},
|
||||
"function-declaration": {
|
||||
"match": "\\b(fn)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
||||
"captures": {
|
||||
"1": { "name": "keyword.control.aster" },
|
||||
"2": { "name": "entity.name.function.aster" }
|
||||
}
|
||||
},
|
||||
"keywords": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "keyword.control.aster",
|
||||
"match": "\\b(let|const|fn|if|else|while|for|in|break|continue|return)\\b"
|
||||
}
|
||||
]
|
||||
},
|
||||
"constants": {
|
||||
"match": "\\b(true|false|nil)\\b",
|
||||
"name": "constant.language.aster"
|
||||
},
|
||||
"builtins": {
|
||||
"match": "\\b(print|input|clock|len|typeof|push|pop|split|trim|substring|replace|contains|upper|lower|starts_with|ends_with|require)\\b",
|
||||
"name": "support.function.builtin.aster"
|
||||
},
|
||||
"operators": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "keyword.operator.assignment.compound.aster",
|
||||
"match": "\\+=|-=|\\*=|/=|%="
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.logical.aster",
|
||||
"match": "&&|\\|\\||!"
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.comparison.aster",
|
||||
"match": "==|!=|<=|>="
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.assignment.aster",
|
||||
"match": "="
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.arithmetic.aster",
|
||||
"match": "[+\\-*/%]"
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.comparison.aster",
|
||||
"match": "<|>"
|
||||
}
|
||||
]
|
||||
},
|
||||
"punctuation": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "punctuation.section.scope.aster",
|
||||
"match": "[{}]"
|
||||
},
|
||||
{
|
||||
"name": "punctuation.section.brackets.aster",
|
||||
"match": "[\\[\\]]"
|
||||
},
|
||||
{
|
||||
"name": "punctuation.section.parens.aster",
|
||||
"match": "[\\(\\)]"
|
||||
},
|
||||
{
|
||||
"name": "punctuation.separator.aster",
|
||||
"match": "[,;:\\.]"
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.ternary.question.aster",
|
||||
"match": "\\?"
|
||||
}
|
||||
]
|
||||
},
|
||||
"identifiers": {
|
||||
"match": "[a-zA-Z_][a-zA-Z0-9_]*",
|
||||
"name": "variable.other.aster"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user