Fix parser for index and call exprs, remove old test that didn't work, add visitor pattern
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
24
src/syn/visit.rs
Normal file
24
src/syn/visit.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use crate::syn::ast::*;
|
||||
|
||||
pub trait Accept<V: Visit + ?Sized> {
|
||||
fn accept(&self, visitor: &mut V) -> V::Out;
|
||||
}
|
||||
|
||||
pub trait DefaultAccept<V: Visit + ?Sized> {
|
||||
fn default_accept(&self, visitor: &mut V) -> V::Out;
|
||||
}
|
||||
|
||||
pub trait Visit {
|
||||
type Out;
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &Stmt) -> Self::Out;
|
||||
fn visit_assign_stmt(&mut self, assign: &AssignStmt) -> Self::Out;
|
||||
fn visit_lhs_expr(&mut self, lhs_expr: &LhsExpr) -> Self::Out;
|
||||
fn visit_expr(&mut self, expr: &Expr) -> Self::Out;
|
||||
fn visit_bin_expr(&mut self, expr: &BinExpr) -> Self::Out;
|
||||
fn visit_un_expr(&mut self, expr: &UnExpr) -> Self::Out;
|
||||
fn visit_call_expr(&mut self, expr: &CallExpr) -> Self::Out;
|
||||
fn visit_index_expr(&mut self, expr: &IndexExpr) -> Self::Out;
|
||||
fn visit_access_expr(&mut self, expr: &AccessExpr) -> Self::Out;
|
||||
fn visit_atom(&mut self, atom: &Atom) -> Self::Out;
|
||||
}
|
||||
Reference in New Issue
Block a user