From a90fdb63e8adb09dafcc050344c443d3b73838bc Mon Sep 17 00:00:00 2001 From: David Li Date: Mon, 6 Nov 2017 21:12:56 -0500 Subject: Parse and typecheck function calls --- src/taiga.lalrpop | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/taiga.lalrpop') 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> = { => <>, }; +CallArgsList: Vec> = { + "," => { + let mut rest = rest; + rest.push(*exp); + rest + }, + "," => vec![*exp], + => vec![*exp], +}; + +CallArgs: Vec> = { + "(" ")" => v, + "(" ")" => vec![], +}; + ExpressionBase: Box> = { 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))), + => + Box::new(WithLocation::new(ast::Expression::Call(func.value, args), l, r)), Spanned => Box::new(<>.map(|v| ast::Expression::Nil)), "let" "in" "end" => Box::new(WithLocation::new(ast::Expression::Let(d, e), l, r)), -- cgit v1.2.3