Change Record variant representation

This commit is contained in:
greg 2019-01-24 20:47:20 -08:00
parent 1ce06bc0ef
commit c225e469ee
2 changed files with 12 additions and 6 deletions

View File

@ -84,7 +84,10 @@ pub struct TypeBody(pub Vec<Variant>);
pub enum Variant {
UnitStruct(Rc<String>),
TupleStruct(Rc<String>, Vec<TypeIdentifier>),
Record(Rc<String>, Vec<(Rc<String>, TypeIdentifier)>),
Record {
name: Rc<String>,
members: Vec<(Rc<String>, TypeIdentifier)>,
}
}
#[derive(Debug, PartialEq, Clone)]

View File

@ -368,7 +368,7 @@ impl Parser {
},
LCurlyBrace => {
let typed_identifier_list = delimited!(self, LCurlyBrace, typed_identifier, Comma, RCurlyBrace);
Ok(Record(name, typed_identifier_list))
Ok(Record {name, members: typed_identifier_list })
},
_ => Ok(UnitStruct(name))
}
@ -1346,10 +1346,13 @@ fn a(x) {
Singleton(TypeSingletonName { name: rc!(Int), params: vec![] }),
Singleton(TypeSingletonName { name: rc!(Option), params: vec![Singleton(TypeSingletonName { name: rc!(a), params: vec![] })] }),
]),
Record(rc!(Esperanza), vec![
Record{
name: rc!(Esperanza),
members: vec![
(rc!(a), Singleton(TypeSingletonName { name: rc!(Int), params: vec![] })),
(rc!(b), Singleton(TypeSingletonName { name: rc!(String), params: vec![] })),
])
]
}
]),
mutable: false
}))]));