diff options
Diffstat (limited to 'crates/rebel-parse/src/grammar/recipe.rs')
-rw-r--r-- | crates/rebel-parse/src/grammar/recipe.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs index 6c52367..71c2733 100644 --- a/crates/rebel-parse/src/grammar/recipe.rs +++ b/crates/rebel-parse/src/grammar/recipe.rs @@ -19,17 +19,21 @@ peg::parser! { p('{') body:body() p('}') { ast::RecipeStmt::Task { name, params, body } } - / stmt:body_stmt() { + / stmt:body_stmt() p(';') { ast::RecipeStmt::BodyStmt(stmt) } pub rule body() -> ast::Body<'a> - = body:body_stmt()* { body } + = body:body_stmt() ++ p(';') { body } pub rule body_stmt() -> ast::BodyStmt<'a> - = left:typed_expr() op:assign_op() right:expr() p(';') { - ast::BodyStmt::assign(left, op, right) + = dest:typed_expr() op:assign_op() expr:expr() { + ast::BodyStmt::assign(dest, op, expr) } + / expr:expr() { + ast::BodyStmt::Expr { expr } + } + / { ast::BodyStmt::Empty } rule assign_op() -> Option<ast::OpBinary> = p2('+', '=') { Some(Add) } |