Spread out implementations of symbol and attrs-related things, add impl

blocks for TranslateAst

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-21 18:51:54 -04:00
parent 926447a62d
commit 7b470b1e76
14 changed files with 178 additions and 114 deletions

View File

@@ -236,7 +236,7 @@ impl Visit<FunExpr> for CollectSyms<'_, '_> {
fn visit(&mut self, expr: &FunExpr) -> Self::Out {
expr.params.iter().for_each(|name| {
self.ctx.add_sym(name.clone());
self.ctx.syms_mut().add(name.clone());
});
self.visit(&expr.expr);
}
@@ -249,11 +249,11 @@ impl Visit<BaseExpr> for CollectSyms<'_, '_> {
match &expr.kind {
BaseExprKind::Ident => {
let name = expr.text_at(self.text).to_string();
self.ctx.add_sym(name);
self.ctx.syms_mut().add(name);
}
BaseExprKind::Sym => {
let name = expr.text_at(self.text).chars().skip(1).collect::<String>();
self.ctx.add_sym(name);
self.ctx.syms_mut().add(name);
}
BaseExprKind::List(l) | BaseExprKind::Tuple(l) => {
l.iter().for_each(|expr| self.visit(expr))