Files
endorphin-aster-vm/crates/compiler/examples/README.md
T
codex-bot aa3257bfe6
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 7m56s
feat: connect source compilation and VM execution
2026-10-19 14:50:37 +08:00

22 lines
1.4 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 集成测试直接使用;运行只在指定远端环境进行,本地不运行。
| 文件 | 输入模式与预期结果 |
| --- | --- |
| [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)。