docs(frontend): explain reader and syntax regression scenarios

This commit is contained in:
2026-11-15 18:51:20 +08:00
parent ce0f507953
commit e0e13ce6fc
3 changed files with 140 additions and 0 deletions
+6
View File
@@ -1,9 +1,15 @@
// frontend/tests/syntax.rs 解析此模块并检查两个声明;这里只演示 AST 输入,不自动调用函数或执行数值运算。
// Parsing produces an AST; it does not execute these functions.
// 供语法测试解析的恒等函数,显式 String 参数与返回注解均保存在 AST 中。
function echo(text: String): String {
// let 绑定把参数读取存为独立 Binding 节点,供前端检查语句结构。
let result = text
// 末尾 return 引用 result,解析后保留名称及原文范围。
return result
}
// 供语法测试解析的双参数函数;参数和返回类型名仅作为注解文本,不在前端解析其身份。
function discountedPrice(price: Number, discount: Number): Number {
// 减法在 AST 中是包含两个名称读取的 Binary 节点,此示例解析过程不计算结果。
return price - discount
}