start tests

This commit is contained in:
greg 2018-11-17 19:24:11 -08:00
parent 401d5aabd6
commit 627a740b0d
1 changed files with 21 additions and 1 deletions

View File

@ -1,3 +1,5 @@
use std::rc::Rc;
use ast::*;
pub fn dispatch<T, V: ASTVisitor<T>>(visitor: &mut V, ast: &AST) -> T {
@ -45,7 +47,7 @@ pub trait DeclarationVisitor<T> {
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<T> {
fn func_signature(&mut self, _sig: &Signature) { }
fn func_declaration(&mut self, _sig: &Signature, _block: &Vec<Statement>) { }
fn type_declaration(&mut self, _name: &TypeSingletonName, _body: &TypeBody, _mutable: &bool) { }
fn type_alias(&mut self, _alias: &Rc<String>, _name: &Rc<String>) { }
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<AST> {
let tokens = tokenize(input);
let mut parser = ::parsing::Parser::new(tokens);
parser.parse()
}
#[test]
fn test() {
let q = parse("foo");
}
}