summaryrefslogtreecommitdiffstats
path: root/crates/rebel-parse/src/grammar/recipe.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rebel-parse/src/grammar/recipe.rs')
-rw-r--r--crates/rebel-parse/src/grammar/recipe.rs28
1 files changed, 15 insertions, 13 deletions
diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs
index a00d150..92ab7f8 100644
--- a/crates/rebel-parse/src/grammar/recipe.rs
+++ b/crates/rebel-parse/src/grammar/recipe.rs
@@ -15,8 +15,9 @@ peg::parser! {
= keyword_fetch() name:ident() p('{') body:body() p('}') {
ast::RecipeStmt::Fetch { name, body: Vec::new() }
}
- / keyword_task() name:ident() p('(') args:argtypes() p(')') p('{') body:body() p('}') {
- ast::RecipeStmt::Task { name, args, body }
+ / keyword_task() name:ident() p('(') params:func_params() p(')')
+ p('{') body:body() p('}') {
+ ast::RecipeStmt::Task { name, params, body }
}
/ stmt:body_stmt() {
ast::RecipeStmt::BodyStmt(stmt)
@@ -63,10 +64,14 @@ peg::parser! {
p('-') expr:@ { Expr::unary(Neg, expr) }
p('!') expr:@ { Expr::unary(Not, expr) }
--
- expr:@ p('(') args:args() p(')') { Expr::apply(expr, args) }
+ expr:@ p('(') params:call_params() p(')') {
+ Expr::apply(expr, params)
+ }
expr:@ p('[') index:expr() p(']') { Expr::index(expr, index) }
--
- expr:@ p('.') method:field() p('(') args:args() p(')') { Expr::method(expr, method, args) }
+ expr:@ p('.') method:field() p('(') params:call_params() p(')') {
+ Expr::method(expr, method, params)
+ }
expr:@ p('.') field:field() { Expr::field(expr, field) }
--
p('(') e:expr() p(')') { Expr::paren(e) }
@@ -77,17 +82,14 @@ peg::parser! {
= lit:literal() { Expr::Literal(lit) }
/ path:path() { Expr::Path(path) }
- rule args() -> Vec<ast::Arg<'a>>
- = args:delimited(<arg()>, <p(',')>) { args }
-
- rule arg() -> ast::Arg<'a>
- = expr:expr() { ast::Arg { expr } }
+ rule call_params() -> Vec<ast::Expr<'a>>
+ = args:delimited(<expr()>, <p(',')>) { args }
- rule argtypes() -> Vec<ast::ArgType<'a>>
- = args:delimited(<argtype()>, <p(',')>) { args }
+ rule func_params() -> Vec<ast::FuncParam<'a>>
+ = params:delimited(<func_param()>, <p(',')>) { params }
- rule argtype() -> ast::ArgType<'a>
- = name:ident() p(':') typ:expr() { ast::ArgType { name, typ } }
+ rule func_param() -> ast::FuncParam<'a>
+ = name:ident() p(':') typ:expr() { ast::FuncParam { name, typ } }
rule literal() -> ast::Literal<'a>
= keyword_true() { ast::Literal::Boolean(true) }