docs: clarify event failure cleanup and VM sequence contracts

This commit is contained in:
2026-11-12 20:53:49 +08:00
parent f0bfbc9fc1
commit 2d5138c7ad
3 changed files with 10 additions and 4 deletions
+3 -2
View File
@@ -32,6 +32,7 @@ impl SourcePlan {
/// endor_host 执行入口调用,优先接受完整 Module,失败则按顶层换行候选边界拼出 Aster 可解析的交互输入。
/// 模块解析失败本身不立即作为最终错误:普通顶层脚本本就需要走后面的 Interactive 解析路径。
/// 这里只产出 AST 计划,不执行已接受的片段;endor_host 先完成所有根的预算检查和编译,再进入源代码执行。
pub fn parse(source: &SourceUnit) -> Result<SourcePlan> {
// 完整模块优先;只有模块解析失败才退回连续交互输入模式,宿主不自行实现 Endor 语法。
if let Ok(module) = frontend::parse_source_ast(source, ParseMode::Module) {
@@ -99,9 +100,9 @@ pub fn parse(source: &SourceUnit) -> Result<SourcePlan> {
}
}
}
// 空输入不能静默产生空计划;再次委托交互入口给出解析器自己的空输入诊断与来源。
// 没有接受任何片段时,再把完整输入交给前端校验;是否为空输入/注释及是否可接受,仍由前端定义。
if roots.is_empty() {
// 不自造宿主错误字符串,保留前端对空输入的原始诊断和 SourceUnit 来源信息。
// 不自造宿主错误字符串;失败则保留前端诊断,成功也不把这次仅用于校验的根追加到 roots。
frontend::parse_source_ast(source, ParseMode::Interactive)?;
}
Ok(SourcePlan::Script(roots))