feat: support bare name assignments in interactive and function scopes
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
// Generated by scripts/generate_ast.py from Endor.asdl. Do not edit.
|
||||
|
||||
use super::{
|
||||
AstDocument, AstRoot, BinaryOp, Binding, Block, Decl, DeclKind, Expr, ExprKind, Function,
|
||||
InteractiveInput, Name, Parameter, Program, ReturnStatement, Spanned, Stmt, StmtKind, UnaryOp,
|
||||
Assignment, AstDocument, AstRoot, BinaryOp, Binding, Block, Decl, DeclKind, Expr, ExprKind,
|
||||
Function, InteractiveInput, Name, Parameter, Program, ReturnStatement, Spanned, Stmt, StmtKind,
|
||||
UnaryOp,
|
||||
};
|
||||
use crate::Span;
|
||||
pub trait Visitor {
|
||||
@@ -83,6 +84,12 @@ pub trait Visitor {
|
||||
self.leave_node();
|
||||
result
|
||||
}
|
||||
fn visit_assignment(&mut self, node: &Assignment) -> Result<(), Self::Error> {
|
||||
self.enter_node(node.span())?;
|
||||
let result = walk_assignment(self, node);
|
||||
self.leave_node();
|
||||
result
|
||||
}
|
||||
fn visit_return_statement(&mut self, node: &ReturnStatement) -> Result<(), Self::Error> {
|
||||
self.enter_node(node.span())?;
|
||||
let result = walk_return_statement(self, node);
|
||||
@@ -201,6 +208,9 @@ pub fn walk_stmt_kind<V: Visitor + ?Sized>(
|
||||
StmtKind::Binding(value) => {
|
||||
visitor.visit_binding(value)?;
|
||||
}
|
||||
StmtKind::Assignment(value) => {
|
||||
visitor.visit_assignment(value)?;
|
||||
}
|
||||
StmtKind::Return(value) => {
|
||||
visitor.visit_return_statement(value)?;
|
||||
}
|
||||
@@ -219,6 +229,15 @@ pub fn walk_binding<V: Visitor + ?Sized>(visitor: &mut V, node: &Binding) -> Res
|
||||
visitor.visit_span(&node.span)?;
|
||||
Ok(())
|
||||
}
|
||||
pub fn walk_assignment<V: Visitor + ?Sized>(
|
||||
visitor: &mut V,
|
||||
node: &Assignment,
|
||||
) -> Result<(), V::Error> {
|
||||
visitor.visit_name(&node.name)?;
|
||||
visitor.visit_expr(&node.value)?;
|
||||
visitor.visit_span(&node.span)?;
|
||||
Ok(())
|
||||
}
|
||||
pub fn walk_return_statement<V: Visitor + ?Sized>(
|
||||
visitor: &mut V,
|
||||
node: &ReturnStatement,
|
||||
|
||||
Reference in New Issue
Block a user