From acebeaa332259192321da4e2bd50a85a34ab1a02 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 25 Jan 2021 16:08:34 -0600 Subject: [PATCH] a --- example | 7 +++---- src/ast.rs | 10 ++++++++++ src/hoas.rs | 10 ++++++++-- traits | 13 +++++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 traits diff --git a/example b/example index dce12e8..b6048ce 100644 --- a/example +++ b/example @@ -1,7 +1,6 @@ -fn main -{ -urmom(); -isEven(); +fn main { + urmom(); + isEven(); 5 } diff --git a/src/ast.rs b/src/ast.rs index 36ed48b..8d1131f 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -5,9 +5,16 @@ pub struct Program { #[derive(Debug)] pub enum Decl { + Mod(Mod), Func(Func), } +#[derive(Debug)] +pub struct Mod { + pub name: Ident, + pub decls: Vec, +} + #[derive(Debug)] pub struct Func { pub name: Ident, @@ -39,3 +46,6 @@ pub enum Type {} #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct Ident(pub String); + +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub struct Path(pub Vec); diff --git a/src/hoas.rs b/src/hoas.rs index b01f362..aa124dd 100644 --- a/src/hoas.rs +++ b/src/hoas.rs @@ -8,6 +8,10 @@ use crate::utils::Id; type Graph = DiGraphMap; type Scopes = Vec>; +pub enum HExpr { + +} + #[derive(Debug)] pub struct Namespaces { funcs: HashMap, @@ -20,9 +24,9 @@ pub struct Namespaces { impl Namespaces { pub fn create(program: Program) -> Self { let mut funcs = HashMap::new(); - let mut types = HashMap::new(); + let types = HashMap::new(); let mut func_names = HashMap::new(); - let mut type_names = HashMap::new(); + let type_names = HashMap::new(); for decl in program.decls { match decl { @@ -31,6 +35,8 @@ impl Namespaces { func_names.insert(func.name.0.clone(), id); funcs.insert(id, func); } + Decl::Mod(_mod) => { + } } } diff --git a/traits b/traits new file mode 100644 index 0000000..be53ba2 --- /dev/null +++ b/traits @@ -0,0 +1,13 @@ +trait Foo { + fn foo(); +} + +struct Bar impls Foo { + +} + +fn test(f: impl Foo) { +} + +x = Bar {} +test(x)