summaryrefslogtreecommitdiff
path: root/src/taiga.lalrpop
diff options
context:
space:
mode:
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)),