From c225e469ee54406d1b1f7fb84d10bf3873b682be Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 24 Jan 2019 20:47:20 -0800 Subject: [PATCH] Change Record variant representation --- schala-lang/language/src/ast.rs | 5 ++++- schala-lang/language/src/parsing.rs | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index e937c48..05fad6e 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -84,7 +84,10 @@ pub struct TypeBody(pub Vec); pub enum Variant { UnitStruct(Rc), TupleStruct(Rc, Vec), - Record(Rc, Vec<(Rc, TypeIdentifier)>), + Record { + name: Rc, + members: Vec<(Rc, TypeIdentifier)>, + } } #[derive(Debug, PartialEq, Clone)] diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 99133c7..f2e4313 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -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![ - (rc!(a), Singleton(TypeSingletonName { name: rc!(Int), params: vec![] })), - (rc!(b), Singleton(TypeSingletonName { name: rc!(String), params: 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 }))]));