Files
endorphin-aster-vm/crates/compiler/examples/README.md
T
codex-bot 51cd64e688
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 7m49s
ci: publish actual Endor example outputs as artifacts
2026-10-19 15:16:28 +08:00

25 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 可执行 Endor 示例
这些 UTF-8 文件由 compiler 和 CLI 集成测试直接使用;运行只在指定远端环境进行,本地不运行。
| 文件 | 输入模式与预期结果 |
| --- | --- |
| [cases.json](cases.json) | CI 实际输出报告的用例清单;覆盖本目录每个 .endor 文件,指定 run/eval 和精确预期 stdout |
| [hello.endor](hello.endor) | run;main 返回“你好,Endor 🌱” |
| [calls.endor](calls.endor) | run;前向函数引用、参数和 let,返回“函数调用已接通” |
| [shadowing.endor](shadowing.endor) | run;参数遮蔽全局函数名并传递函数值,返回“局部名称优先” |
| [number.endor](number.endor) | run;返回无损负十进制常量 -123456789012345678901234567890.00100 |
| [literal.endor](literal.endor) | eval;返回“表达式 → 字节码 → VM” |
```sh
cli run crates/compiler/examples/hello.endor
cli run crates/compiler/examples/calls.endor
cli run crates/compiler/examples/shadowing.endor
cli run crates/compiler/examples/number.endor
cli eval crates/compiler/examples/literal.endor
```
run 默认调用无参数 main,可用 --entry name 选择另一个无参数入口;eval 解析一个完整表达式,二者都支持 - 读取 stdin 到 EOF。类型名称暂只保留语法,Callable 不要求预先注册语言类。例子不依赖 print 或其他默认标准库。编译器尚无算术运行语义;前端 basic.endor 含算术,只是解析示例,不能混作可执行示例。规则见 [编译契约](../../../docs/runtime/compiler.md),返回 [compiler](../README.md)。
CI 使用 [endor_examples.py](../../../scripts/endor_examples.py) 再次执行真实 CLI 并保存实际结果,不只显示 Rust 测试名称。对应 Actions run 的 endor-execution-output-<sha> artifact 包含源码、命令、预期/实际 stdout、stderr、退出码和状态;位置与失败规则见 [验证报告](../../../docs/operations/validation.md)。新增 .endor 示例时同步 cases.json,未覆盖文件会让报告步骤失败。