summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2017-11-05 21:16:57 -0500
committerDavid Li <li.davidm96@gmail.com>2017-11-05 21:16:57 -0500
commit249ab68e4744aed0a93ce9ff842c9f6fe0e13201 (patch)
tree364dca9780ebd3f8aa68c16d6a089f9c6b792c8a /src/ast.rs
parente5c6400f75029124474ee989388bf2c0abdc7e0a (diff)
Parse function declarations
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ast.rs b/src/ast.rs
index d9ce406..8b93e34 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -118,7 +118,9 @@ pub enum DeclarationBody {
ty: WithLocation<Ty>,
},
Fun {
- ty: Box<WithLocation<Ty>>,
+ ty: Option<WithLocation<Ty>>,
+ params: Vec<WithLocation<RecordField>>,
+ body: Box<WithLocation<Expression>>,
},
}
@@ -142,4 +144,18 @@ impl Declaration {
}
}
}
+
+ pub fn new_fun(name: WithLocation<String>,
+ params: Vec<WithLocation<RecordField>>,
+ type_: Option<WithLocation<Ty>>,
+ body: Box<WithLocation<Expression>>) -> Declaration {
+ Declaration {
+ name: name,
+ declaration: DeclarationBody::Fun {
+ ty: type_,
+ params: params,
+ body: body,
+ }
+ }
+ }
}