Skip to content

Commit

Permalink
Create Statements
Browse files Browse the repository at this point in the history
  • Loading branch information
coletonodonnell committed Feb 9, 2022
1 parent f408aeb commit d753016
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/stmt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::expression::Expr;

pub enum Stmt {
Expression {
expression: Expr
},
Print {
expression: Expr
}
}

pub trait StmtVisitor<T> {
fn execute(&mut self, stmt: Stmt) -> T {
match stmt {
Stmt::Expression {expression: a} => self.visit_expression(a),
Stmt::Print {expression: a} => self.visit_print(a)
}
}

fn visit_expression(&mut self, expression: Expr) -> T;
fn visit_print(&mut self, expression: Expr) -> T;
}

0 comments on commit d753016

Please sign in to comment.