a
This commit is contained in:
parent
9747990c12
commit
acebeaa332
4 changed files with 34 additions and 6 deletions
7
example
7
example
|
@ -1,7 +1,6 @@
|
|||
fn main
|
||||
{
|
||||
urmom();
|
||||
isEven();
|
||||
fn main {
|
||||
urmom();
|
||||
isEven();
|
||||
5
|
||||
}
|
||||
|
||||
|
|
10
src/ast.rs
10
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<Decl>,
|
||||
}
|
||||
|
||||
#[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<Ident>);
|
||||
|
|
10
src/hoas.rs
10
src/hoas.rs
|
@ -8,6 +8,10 @@ use crate::utils::Id;
|
|||
type Graph = DiGraphMap<Id, ()>;
|
||||
type Scopes = Vec<HashSet<String>>;
|
||||
|
||||
pub enum HExpr {
|
||||
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Namespaces {
|
||||
funcs: HashMap<Id, Func>,
|
||||
|
@ -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) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
traits
Normal file
13
traits
Normal file
|
@ -0,0 +1,13 @@
|
|||
trait Foo {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
struct Bar impls Foo {
|
||||
|
||||
}
|
||||
|
||||
fn test(f: impl Foo) {
|
||||
}
|
||||
|
||||
x = Bar {}
|
||||
test(x)
|
Loading…
Reference in a new issue