44 Commits
Author SHA1 Message Date
0264408 131e62ddf3 chore: 为LSP客户端设置输出通道名称 2026-08-19 17:15:44 +08:00
0264408 5a2cd9a658 Merge branch 'try-catch' 2026-08-19 17:11:09 +08:00
0264408 23dd721903 Merge branch 'vm-bytecode'
# Conflicts:
#	README.md
2026-08-19 17:10:33 +08:00
0264408 1fdfdb5b2f chore: 添加.gitattributes文件以保持行结束符一致性 2026-08-19 17:06:34 +08:00
0264408andClaude af63957b11 fix: LSP补全触发和语法高亮更新
- completion_provider 注册 a-z A-Z _ . 为触发字符,解决 Copilot 拦截补全问题
- 语法高亮新增 try catch finally throw 关键字

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-26 15:13:51 +08:00
0264408andClaude a70e5fbc30 feat: try-catch-finally 异常处理
语法: try { ... } catch (e) { ... } finally { ... }
catch 和 finally 都是可选的,但至少需要一个。throw expr 抛出任意值。

- Lexer: 新增 try, catch, finally, throw 关键字
- AST: Stmt::Try { body, catch_var, catch_body, finally_body } + Stmt::Throw(Expr)
- Parser: try/catch/finally/throw 语句解析,更新 synchronize()
- Opcode: Throw = 46,FunctionProto 新增 exception_handlers 表
- ExceptionHandler: { try_start, try_end, catch_ip, catch_slot, finally_ip }
- Compiler: compile_try 将 finally 在成功/异常两条路径各内联一次
- VM: unwind() 栈展开 + find_handler() 处理器搜索
- RuntimeError(除零、未定义变量等)在 try 块内自动转为可捕获异常
- LSP: 补全关键字列表追加

已知限制: return/break/continue 在 try-finally 内部不会先执行 finally

16 个新测试,全部 343 个测试通过。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-26 14:37:38 +08:00
0264408andClaude deab894864 doc: 修正README中upvalue捕获层数限制的表述
实际机制是增量逐层建立,通过enclosing_locals合并链
理论上不限深度;仅一次性链创建受限于3层穿透

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-26 10:49:41 +08:00
0264408andClaude 9f75ec68ee doc: 更新README,反映VM-only架构
- 移除树遍历解释器相关描述
- 移除 --vm 命令行标志
- 更新架构图和模块表,添加 runtime/ 模块
- 更新关键设计决策

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-26 10:45:50 +08:00
0264408andClaude fa6ea512b3 refactor: VM-only architecture — remove tree-walking interpreter
Eliminate dual-engine architecture (Interpreter + Vm) in favor of
a single bytecode VM executor.

- Extract shared types (Value, FunctionProto, Closure, UpvalueObj,
  Runtime trait, NativeFn) into new  module
- Consolidate builtin registration in  — single
   used by VM, eliminates 40-line duplicate
- Delete tree-walker: exec.rs, eval.rs, interpreter.rs, env.rs, module.rs
- Change Value::Function(Rc<Function>) → Value::Function(Rc<Closure>)
  eliminating the closures HashMap pointer-key hack
- Fix VM semantic gaps found during migration:
  * Structural equality for Object/Array in is_equal
  * CompoundAssignGlobal opcode (global compound assigns were broken)
  * 9 string methods added to VM get_property
  * ForInInit error on non-iterable values
- Switch run_file/run_repl to VM; remove --vm CLI flag
- Move 327 tests from interpreter/ to vm/ — all pass

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-26 10:31:32 +08:00
0264408andClaude abe0844816 fix: CompoundAssignUpvalue支持 + const变量赋值检查
- 新增 CompoundAssignUpvalue 字节码,闭包中 x+=5 不再报错
- Local/Upvalue 上的 is_const 编译期检查
- globals 改为 HashMap<String, (Value, bool)> 追踪 const,StoreGlobal 运行时拒绝
- DefineGlobal 指令新增 1 字节 mutable 标志
- 更新 README:双执行模式、for-in、require()、VM 模块说明

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-26 09:42:38 +08:00
0264408 61ce3466a9 Merge branch 'master' of https://gitea.jetlumen.com/admin/aster 2026-06-26 09:27:19 +08:00
0264408 bb0cf8c558 doc: 更新README 2026-06-26 09:27:16 +08:00
0264408 99c9e9c9bd feat: 新增块注释及测试 2026-06-17 17:26:37 +08:00
0264408 df9ecb4de1 fix: 优化字符串类型在不同场景的打印形式 2026-06-17 16:08:40 +08:00
0264408 e356c208a6 feat: 实现模块引入功能以及测试 2026-06-17 15:57:45 +08:00
0264408andClaude 9428e270af refactor: 用 Value::get/set 简化属性访问,消除直接 borrow/borrow_mut 调用
- Value::set 签名改为接受 &str 并返回 RuntimeError,与 evaluator 对齐
- eval_get/eval_set/eval_index_get/eval_index_set 中统一使用 get/set
- 去掉 eval_index_get 和 eval_index_set 中不再使用的 map 绑定

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 15:05:59 +08:00
0264408 8e49df8062 feat: 添加字符串工具函数(split, trim, substring, replace, contains, upper, lower, starts_with, ends_with)及相关测试用例 2026-06-16 19:44:54 +08:00
0264408 bf705069a5 feat: 添加对数组和对象字面量的尾随逗号支持,更新相关测试用例 2026-06-16 19:40:24 +08:00
0264408 a7bedf6fa1 refactor: 优化代码组织 2026-06-16 19:33:16 +08:00
0264408 e4272943aa refactor: 抽离测试代码 2026-06-16 19:25:01 +08:00
0264408 fdd42fce19 feat: 添加对单引号字符串的支持,更新词法分析器和相关测试用例 2026-06-16 19:16:48 +08:00
0264408 5e431dbba4 feat: 添加对象索引访问和赋值支持,更新相关错误处理和测试用例 2026-06-16 19:14:00 +08:00
0264408 8b20580402 feat: 添加for-in循环支持,更新解析器、解释器和相关测试用例 2026-06-16 19:10:26 +08:00
0264408 75c1d230ad feat: 添加内置函数支持(len, typeof, push, pop),更新相关错误处理和测试用例 2026-06-16 19:03:47 +08:00
0264408 18fa53cf4a feat: 实现字符串与数字的连接操作,增强加法运算符的功能 2026-06-16 18:55:05 +08:00
0264408 db541c315b feat: 添加三元运算符支持,更新解析器和解释器以处理条件表达式 2026-06-16 18:41:42 +08:00
0264408 c2d6c518fc feat: 添加对const关键字的支持,允许定义不可变变量并增强相关错误处理 2026-06-16 17:24:17 +08:00
0264408andClaude 284a29a4be fix: 修复字符串转义、对象相等比较、除零处理
- 词法分析器:字符串字面量中支持 \n \t \r " \ 转义序列,未知转义序列报告错误并跳过剩余字符串
- 解释器:对象相等比较新增深度比较(键值对逐一比对)
- 解释器:除法和取模运算在除数为零时返回 RuntimeError,避免产生 inf/NaN

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-16 17:02:30 +08:00
0264408 983a7d8b34 feat: 添加标准测试 2026-06-16 16:56:17 +08:00
0264408 a76cd79be2 feat: 添加CLAUDE.md文件 2026-06-16 16:55:43 +08:00
0264408 c7e4e0dce0 feat: 更新错误处理机制,增强词法分析器和解析器的错误报告功能 2026-06-16 14:24:49 +08:00
0264408 e052226cdb feat: 重构main函数,添加run_file和run_repl函数以支持从文件和REPL读取输入 2026-06-16 10:11:11 +08:00
0264408 d951aa93ff feat: 优化print函数,简化参数输出逻辑 2026-06-16 09:36:41 +08:00
0264408 bd052699f5 feat: 添加取模运算符支持,更新解析器、解释器、词法分析器和相关示例以处理相关语法 2026-06-16 09:36:32 +08:00
0264408 259dcf1af9 feat: 更新赋值运算符示例,添加数组和对象操作的打印输出 2026-06-16 08:58:04 +08:00
0264408 a40c8d1e9e feat: 添加赋值运算符支持,更新解析器、解释器和词法分析器以处理相关语法 2026-06-16 08:55:21 +08:00
0264408 ae3060708d feat: 添加break和continue语句的支持,更新解析器、解释器和词法分析器以处理相关语法 2026-06-10 17:37:12 +08:00
0264408 dd3f18da6f feat: 添加数组字面量和索引访问功能,更新解析器和解释器以支持数组操作 2026-04-28 10:14:13 +08:00
0264408 5dc55c3476 feat: 实现for循环语句的解析和执行逻辑,更新词法分析器以支持for关键字 2026-02-11 09:39:06 +08:00
0264408 0e0077d96b feat: 改进Value对象的显示格式,增加键值对输出 2026-02-11 09:02:52 +08:00
0264408 e9fbb92b15 feat: 更新README 2026-02-10 17:30:44 +08:00
0264408 521c7006d9 feat: 新增对象字面量和属性访问表达式 2026-02-10 17:13:40 +08:00
0264408 5c5ca8600a feat: 新增内置函数input 2026-02-06 11:46:27 +08:00
0264408 f86300f3ce Initialize Aster project with basic structure, including Cargo configuration, lexer, parser, interpreter, and AST definitions. Add a sample script and README documentation. Implement basic error handling and environment management for variable storage. 2026-02-04 16:42:51 +08:00