Still more visitor stuff
This commit is contained in:
parent
9fa4e3797c
commit
89649273d8
@ -92,7 +92,7 @@ pub enum Declaration {
|
|||||||
body: TypeBody,
|
body: TypeBody,
|
||||||
mutable: bool
|
mutable: bool
|
||||||
},
|
},
|
||||||
TypeAlias(Rc<String>, Rc<String>), //should have TypeSingletonName in it, or maybe just String, not sure
|
TypeAlias(Rc<String>, Rc<String>), //TODO should have TypeSingletonName in it, or maybe just String, not sure
|
||||||
Binding {
|
Binding {
|
||||||
name: Rc<String>,
|
name: Rc<String>,
|
||||||
constant: bool,
|
constant: bool,
|
||||||
|
@ -28,6 +28,13 @@ pub trait ASTVisitor: Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&mut self, signature: &Signature) {
|
fn signature(&mut self, signature: &Signature) {
|
||||||
|
walker::signature(self, signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn type_declaration(&mut self, name: &TypeSingletonName, body: &TypeBody, mutable: bool) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn type_alias(&mut self, old_name: &Rc<String>, new_name: &Rc<String>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn binding(&mut self, name: &Rc<String>, constant: bool, type_anno: Option<&TypeIdentifier>, expr: &Expression) {
|
fn binding(&mut self, name: &Rc<String>, constant: bool, type_anno: Option<&TypeIdentifier>, expr: &Expression) {
|
||||||
@ -35,8 +42,13 @@ pub trait ASTVisitor: Sized {
|
|||||||
walker::expression(self, expr);
|
walker::expression(self, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn implemention(&mut self, type_name: &TypeIdentifier, interface_name: Option<&TypeSingletonName>, block: &Vec<Declaration>) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn interface(&mut self, name: &Rc<String>, signatures: &Vec<Signature>) {
|
||||||
|
}
|
||||||
|
|
||||||
fn expression(&mut self, expression: &Expression) {
|
fn expression(&mut self, expression: &Expression) {
|
||||||
println!("expr yo");
|
|
||||||
walker::expression(self, expression);
|
walker::expression(self, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import gragh
|
|||||||
|
|
||||||
let a = 20 + 84
|
let a = 20 + 84
|
||||||
let b = 28 + 1 + 2 + 2.0
|
let b = 28 + 1 + 2 + 2.0
|
||||||
|
|
||||||
"#);
|
"#);
|
||||||
|
|
||||||
tester.visit(&ast);
|
tester.visit(&ast);
|
||||||
|
@ -32,24 +32,23 @@ pub fn declaration<V: ASTVisitor>(v: &mut V, decl: &Declaration) {
|
|||||||
v.signature(&sig);
|
v.signature(&sig);
|
||||||
v.block(&block);
|
v.block(&block);
|
||||||
},
|
},
|
||||||
TypeDecl { .. } => unimplemented!(),
|
TypeDecl { name, body, mutable } => v.type_declaration(name, body, *mutable),
|
||||||
TypeAlias(_, _) => unimplemented!(),
|
TypeAlias(n, a) => v.type_alias(n, a),
|
||||||
Binding { name, constant, type_anno, expr } => {
|
Binding { name, constant, type_anno, expr } => {
|
||||||
v.binding(name, *constant, type_anno.as_ref(), expr);
|
v.binding(name, *constant, type_anno.as_ref(), expr);
|
||||||
},
|
},
|
||||||
/*
|
Impl { type_name, interface_name, block } => {
|
||||||
Impl {
|
v.implemention(type_name, interface_name.as_ref(), block);
|
||||||
type_name: TypeIdentifier,
|
}
|
||||||
interface_name: Option<TypeSingletonName>,
|
Interface { name, signatures } => v.interface(name, signatures),
|
||||||
block: Vec<Declaration>,
|
|
||||||
},
|
|
||||||
Interface {
|
|
||||||
name: Rc<String>,
|
|
||||||
signatures: Vec<Signature>
|
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
_ => (),
|
|
||||||
|
pub fn signature<V: ASTVisitor>(v: &mut V, signature: &Signature) {
|
||||||
|
for p in signature.params.iter() {
|
||||||
|
v.formal_param(p);
|
||||||
}
|
}
|
||||||
|
v.maybe_type_identifier(signature.type_anno.as_ref());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expression<V: ASTVisitor>(v: &mut V, expression: &Expression) {
|
pub fn expression<V: ASTVisitor>(v: &mut V, expression: &Expression) {
|
||||||
|
Loading…
Reference in New Issue
Block a user