simple expression
This commit is contained in:
parent
94c4dec9a9
commit
0903277b69
@ -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!()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user