use tokenizer::Token; #[derive(Debug, Clone)] pub enum ASTNode { ExprNode(Expression), FuncNode(Function), } #[derive(Debug, Clone)] pub struct Function { pub prototype: Prototype, pub body: Expression } #[derive(Debug, Clone)] pub struct Prototype { pub name: String, pub args: Vec } #[derive(Debug, Clone)] pub enum Expression { Literal(f64), Variable(String), BinExp(String, Box, Box), Call(String, Vec), } pub type AST = Vec; //TODO make this support incomplete parses pub type ParseResult = Result; #[derive(Debug)] pub struct ParseError { pub msg: String } impl ParseError { fn new(msg: &str) -> ParseResult { Err(ParseError { msg: msg.to_string() }) } } pub fn parse(tokens: &[Token], parsed_tree: &[ASTNode]) -> ParseResult { let rest = tokens.to_vec().reverse(); let mut ast = parsed_tree.to_vec(); ParseError::new("Parsing not implemented") }