diff --git a/crates/compiler/src/analysis.rs b/crates/compiler/src/analysis.rs index 80ed0aa..d17bc7a 100644 --- a/crates/compiler/src/analysis.rs +++ b/crates/compiler/src/analysis.rs @@ -332,7 +332,7 @@ impl Builder { binding, }); } - ExprKind::Unary { operand, .. } | ExprKind::Await { operand } => { + ExprKind::Unary { operand, .. } | ExprKind::Await(operand) => { self.expression(operand, globals)? } ExprKind::Binary { left, right, .. } => { diff --git a/crates/compiler/src/codegen.rs b/crates/compiler/src/codegen.rs index 6854569..cb44739 100644 --- a/crates/compiler/src/codegen.rs +++ b/crates/compiler/src/codegen.rs @@ -300,7 +300,7 @@ impl<'a> Emitter<'a> { } self.emit(Opcode::Call, arguments.len())?; } - ExprKind::Await { operand } => { + ExprKind::Await(operand) => { self.expression(operand)?; self.simple(Opcode::Await); } diff --git a/crates/frontend/src/grammar.peg b/crates/frontend/src/grammar.peg index 163b591..db41e03 100644 --- a/crates/frontend/src/grammar.peg +++ b/crates/frontend/src/grammar.peg @@ -147,7 +147,7 @@ peg::parser! { left:(@) slash() right:@ { binary(left, BinaryOp::Divide, right) } -- start:keyword("await") operand:@ { - Expr { span: start.through(operand.span), kind: ExprKind::Await { operand: Box::new(operand) } } + Expr { span: start.through(operand.span), kind: ExprKind::Await(Box::new(operand)) } } start:minus() operand:@ { Expr { span: start.through(operand.span), kind: ExprKind::Unary { operation: UnaryOp::Negate, operand: Box::new(operand) } } diff --git a/docs/runtime/frontend.md b/docs/runtime/frontend.md index 265ed3e..2bc29b8 100644 --- a/docs/runtime/frontend.md +++ b/docs/runtime/frontend.md @@ -84,4 +84,4 @@ use、namespace、trait、agent、完整类型语法、条件/循环、比较 源码类实现子集采用 `class Name: Base { field: TypeName function method(self: Name): ResultType { ... } }`;基类可省略,执行环境须提供 Object。成员函数沿用既有 function 语法,接收者 self 为显式首参数。普通类字段按基类字段、再本类字段的顺序接收位置构造实参。这里记录实现范围,不确认语言文档中的全部候选构造语法;详细限制见[名义类型](types.md)。 -`await expression` 解析为 ExprKind::Await { operand },优先级与前缀负号同级,成员/调用绑定更紧;例如await task.result()等待该调用的返回对象,(await task).field先等待task。await按表达式前缀位置识别,不引入async函数声明。执行是否允许等待由调用上下文决定,见字节码VM的Await章节。 +`await expression` 解析为 ExprKind::Await(operand),优先级与前缀负号同级,成员/调用绑定更紧;例如await task.result()等待该调用的返回对象,(await task).field先等待task。await按表达式前缀位置识别,不引入async函数声明。执行是否允许等待由调用上下文决定,见字节码VM的Await章节。