Initial WIP code
This commit is contained in:
parent
ae65455374
commit
39bb175722
@ -2,6 +2,7 @@ use std::rc::Rc;
|
||||
|
||||
use crate::derivative::Derivative;
|
||||
|
||||
mod visitor;
|
||||
mod operators;
|
||||
pub use operators::*;
|
||||
|
||||
|
33
schala-lang/language/src/ast/visitor.rs
Normal file
33
schala-lang/language/src/ast/visitor.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use std::error::Error;
|
||||
use crate::ast::*;
|
||||
|
||||
|
||||
pub trait ASTVisitor {
|
||||
fn visit(&mut self, ast: &mut AST) {
|
||||
self.block(&ast.statements);
|
||||
}
|
||||
|
||||
fn block(&mut self, statements: &Vec<Statement>) {
|
||||
for statement in statements {
|
||||
self.statement(statement);
|
||||
}
|
||||
}
|
||||
|
||||
fn statement(&mut self, statement: &Statement) {
|
||||
use StatementKind::*;
|
||||
match statement.kind {
|
||||
Expression(ref expr) => self.expression(expr),
|
||||
Declaration(ref decl) => self.declaration(decl),
|
||||
Import(ref import_spec) => self.import(import_spec),
|
||||
}
|
||||
}
|
||||
|
||||
fn expression(&mut self, expression: &Expression) {
|
||||
}
|
||||
|
||||
fn declaration(&mut self, declaration: &Declaration) {
|
||||
}
|
||||
|
||||
fn import(&mut self, import: &ImportSpecifier) {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user