diff --git a/schala-lang/language/src/ast_visitor.rs b/schala-lang/language/src/ast_visitor.rs index f346785..a65bcbf 100644 --- a/schala-lang/language/src/ast_visitor.rs +++ b/schala-lang/language/src/ast_visitor.rs @@ -1,3 +1,5 @@ +use std::rc::Rc; + use ast::*; pub fn dispatch>(visitor: &mut V, ast: &AST) -> T { @@ -45,7 +47,7 @@ pub trait DeclarationVisitor { FuncSig(sig) => visitor.func_signature(sig), FuncDecl(sig, block) => visitor.func_declaration(sig, block), TypeDecl { name, body, mutable } => visitor.type_declaration(name, body, mutable), - TypeAlias(..) => unimplemented!(), + TypeAlias(alias, name) => visitor.type_alias(alias, name), Binding { .. } => unimplemented!(), Impl { .. } => unimplemented!(), Interface { .. } => unimplemented!(), @@ -57,6 +59,7 @@ pub trait DeclarationVisitor { fn func_signature(&mut self, _sig: &Signature) { } fn func_declaration(&mut self, _sig: &Signature, _block: &Vec) { } fn type_declaration(&mut self, _name: &TypeSingletonName, _body: &TypeBody, _mutable: &bool) { } + fn type_alias(&mut self, _alias: &Rc, _name: &Rc) { } fn done(&mut self) -> T; } @@ -92,3 +95,20 @@ impl DeclarationVisitor<()> for NullVisitor { } } +#[cfg(test)] +mod visitor_tests { + use ::tokenizing::{Token, tokenize}; + use ::parsing::ParseResult; + use ::ast::AST; + + fn parse(input: &str) -> ParseResult { + let tokens = tokenize(input); + let mut parser = ::parsing::Parser::new(tokens); + parser.parse() + } + + #[test] + fn test() { + let q = parse("foo"); + } +}