simple expression

This commit is contained in:
greg 2019-07-29 19:44:46 -07:00
parent 94c4dec9a9
commit 0903277b69

View File

@ -1,4 +1,13 @@
use crate::ast::ExpressionKind;
pub trait ASTVisitor { pub trait ExpressionKindVisitor<T> {
fn nat_literal(&mut self, n: u64) -> T;
}
pub fn dispatch<T>(input: &mut ExpressionKind, visitor: &mut dyn ExpressionKindVisitor<T>) -> T {
use ExpressionKind::*;
match input {
NatLiteral(n) => visitor.nat_literal(*n),
_ => panic!()
}
} }