bdffe9e3c5
**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 扫描定位声明和引用
40 lines
626 B
Plaintext
40 lines
626 B
Plaintext
let arr = [10, 20, 30, 40, 50]
|
|
print(arr)
|
|
|
|
print(arr[0] + arr[4])
|
|
|
|
let i = 1
|
|
while(i < 4) {
|
|
print(arr[i])
|
|
i = i + 1
|
|
}
|
|
|
|
arr[0] = 99
|
|
print(arr)
|
|
|
|
for (let j = 0; j < 3; j = j + 1) {
|
|
arr[j] = arr[j] * 2
|
|
}
|
|
print(arr)
|
|
|
|
let nested = [[1, 2], [3, 4], [5, 6]]
|
|
print(nested[1][0])
|
|
|
|
let empty = []
|
|
print(empty)
|
|
|
|
let mixed = [1, "hello", true, nil]
|
|
print(mixed)
|
|
print(mixed[1][0])
|
|
|
|
let same = [1, 2, 3]
|
|
let other = [1, 2, 3]
|
|
print(same == other)
|
|
print(same != [3, 2, 1])
|
|
|
|
let item = { name: "sword", price: 100 }
|
|
let items = [item, { name: "shield", price: 50 }]
|
|
print(items[0].name)
|
|
items[1].price = 75
|
|
print(items[1].price)
|