summaryrefslogtreecommitdiff
path: root/src/taiga.lalrpop
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2017-11-06 21:12:56 -0500
committerDavid Li <li.davidm96@gmail.com>2017-11-06 21:12:56 -0500
commita90fdb63e8adb09dafcc050344c443d3b73838bc (patch)
treeaf62150d119aad693d20c97d8a503cdd6ff34c4c /src/taiga.lalrpop
parentb1ef87bc10b662d6e37f929fa86db7a20b44e7dd (diff)
Parse and typecheck function calls
Diffstat (limited to 'src/taiga.lalrpop')
-rw-r--r--src/taiga.lalrpop17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/taiga.lalrpop b/src/taiga.lalrpop
index 40830c6..9aa2f38 100644
--- a/src/taiga.lalrpop
+++ b/src/taiga.lalrpop
@@ -136,10 +136,27 @@ ExpressionSign: Box<ast::WithLocation<ast::Expression>> = {
<ExpressionBase> => <>,
};
+CallArgsList: Vec<WithLocation<ast::Expression>> = {
+ <exp: Expression> "," <rest: CallArgsList> => {
+ let mut rest = rest;
+ rest.push(*exp);
+ rest
+ },
+ <exp: Expression> "," => vec![*exp],
+ <exp: Expression> => vec![*exp],
+};
+
+CallArgs: Vec<WithLocation<ast::Expression>> = {
+ "(" <v: CallArgsList> ")" => v,
+ "(" ")" => vec![],
+};
+
ExpressionBase: Box<ast::WithLocation<ast::Expression>> = {
Num => Box::new(<>.map(|v| ast::Expression::Number(v))),
String => Box::new(<>.map(|v| ast::Expression::String(v))),
Name => Box::new(<>.map(|v| ast::Expression::Name(v))),
+ <l: @L> <func: Name> <args: CallArgs> <r: @R> =>
+ Box::new(WithLocation::new(ast::Expression::Call(func.value, args), l, r)),
Spanned<r"nil"> => Box::new(<>.map(|v| ast::Expression::Nil)),
<l: @L> "let" <d: DeclarationsList> "in" <e: Expression> "end" <r: @R> =>
Box::new(WithLocation::new(ast::Expression::Let(d, e), l, r)),