summaryrefslogtreecommitdiff
path: root/src/taiga.lalrpop
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/taiga.lalrpop
parente5c6400f75029124474ee989388bf2c0abdc7e0a (diff)
Parse function declarations
Diffstat (limited to 'src/taiga.lalrpop')
-rw-r--r--src/taiga.lalrpop4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/taiga.lalrpop b/src/taiga.lalrpop
index aa5e50e..0144aad 100644
--- a/src/taiga.lalrpop
+++ b/src/taiga.lalrpop
@@ -31,6 +31,10 @@ Declaration: Box<WithLocation<ast::Declaration>> = {
Box::new(WithLocation::new(ast::Declaration::new_var(name, None, exp), l, r)),
<l: @L> "type" <name: Name> "=" <ty: Ty> <r: @R> =>
Box::new(WithLocation::new(ast::Declaration::new_ty(name, ty), l, r)),
+ <l: @L> "function" <name: Name> "(" <params: RecordFields> ")" "=" <body: Expression> <r: @R> =>
+ Box::new(WithLocation::new(ast::Declaration::new_fun(name, params, None, body), l, r)),
+ <l: @L> "function" <name: Name> "(" <params: RecordFields> ")" ":" <ty: Ty> "=" <body: Expression> <r: @R> =>
+ Box::new(WithLocation::new(ast::Declaration::new_fun(name, params, Some(ty), body), l, r)),
};
DeclarationsList: Vec<WithLocation<ast::Declaration>> = {