summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast.rs4
-rw-r--r--src/semantic/translate.rs15
-rw-r--r--src/taiga.lalrpop6
3 files changed, 12 insertions, 13 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 3cc68c1..744397a 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -86,11 +86,11 @@ pub enum Expression {
#[derive(Debug)]
pub struct RecordField {
pub name: WithLocation<String>,
- pub ty: WithLocation<String>,
+ pub ty: WithLocation<Ty>,
}
impl RecordField {
- pub fn new(name: WithLocation<String>, ty: WithLocation<String>) -> RecordField {
+ pub fn new(name: WithLocation<String>, ty: WithLocation<Ty>) -> RecordField {
RecordField { name, ty }
}
}
diff --git a/src/semantic/translate.rs b/src/semantic/translate.rs
index 6c7f60c..dfcec68 100644
--- a/src/semantic/translate.rs
+++ b/src/semantic/translate.rs
@@ -43,14 +43,13 @@ fn trans_ty<'a>(
trans_ty(venv, tenv, &inner_ty)
},
ast::Ty::Record(ref fields) => {
- err!(ty, TypeError::Unimplemented)
- // let result = vec![];
- // for field in fields {
- // result.push(types::RecordField::new(
- // *field.name,
- // trans_ty(venv, tenv, field.ty)?));
- // }
- // Ok(Ty::Record(result))
+ let mut result = vec![];
+ for field in fields {
+ result.push(types::RecordField::new(
+ field.name.clone(),
+ trans_ty(venv, tenv, &field.ty)?));
+ }
+ Ok(Ty::Record(result))
},
}
}
diff --git a/src/taiga.lalrpop b/src/taiga.lalrpop
index 0c7fea0..bad60bb 100644
--- a/src/taiga.lalrpop
+++ b/src/taiga.lalrpop
@@ -8,13 +8,13 @@ pub Program: ast::Program = {
};
FieldList: Vec<WithLocation<ast::RecordField>> = {
- <l: @L> <n:Name> ":" <v:Name> <r: @R> "," <rest: FieldList> => {
+ <l: @L> <n:Name> ":" <v:Ty> <r: @R> "," <rest: FieldList> => {
let mut rest = rest;
rest.push(WithLocation::new(ast::RecordField::new(n, v), l, r));
rest
},
- <l: @L> <n:Name> ":" <v:Name> <r: @R> "," => vec![WithLocation::new(ast::RecordField::new(n, v), l, r)],
- <l: @L> <n:Name> ":" <v:Name> <r: @R> => vec![WithLocation::new(ast::RecordField::new(n, v), l, r)],
+ <l: @L> <n:Name> ":" <v:Ty> <r: @R> "," => vec![WithLocation::new(ast::RecordField::new(n, v), l, r)],
+ <l: @L> <n:Name> ":" <v:Ty> <r: @R> => vec![WithLocation::new(ast::RecordField::new(n, v), l, r)],
};
RecordFields: WithLocation<Vec<WithLocation<ast::RecordField>>> = {