Move PEG grammar into a dedicated source file
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 6m48s
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 6m48s
This commit is contained in:
@@ -4,6 +4,12 @@ frontend 包提供手写 Rust lexer 和 rust-peg 生成的 token parser。当前
|
||||
|
||||
首版以 Endorphin-Language 设计稿的基础词法、表达式与函数章节为起点,语法可以继续修改;设计稿中的未完成部分不作为阻塞前端实现的前置条件,也不被整体视作已经实现的语言能力。这里维护当前解析契约;源码位置见 [frontend](../../crates/frontend/README.md)。
|
||||
|
||||
## 语法文件
|
||||
|
||||
实际 PEG 规则集中在 [grammar.peg](../../crates/frontend/src/grammar.peg),包含 token 匹配、函数/绑定/return、表达式优先级与 AST 构造动作。[parser.rs](../../crates/frontend/src/parser.rs) 保留解析入口、诊断转换和 AST 辅助函数,通过 include!("grammar.peg") 在编译期引入规则。
|
||||
|
||||
grammar.peg 保留 rust-peg 0.8 的 peg::parser! 外层声明,因此是直接参与编译的语法源文件;不另存一份说明性文法,也不新增生成脚本或 build-dependencies。修改规则后随 frontend 重新编译。远端检查脚本单独用 rustfmt 检查该扩展名文件的格式。
|
||||
|
||||
## 入口和所有权
|
||||
|
||||
| API | 输入与结果 |
|
||||
|
||||
Reference in New Issue
Block a user