diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2024-04-29 20:49:55 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2024-04-29 21:15:42 +0200 |
commit | bcec2e72909bc63bdc2cb88808789a04f3a13d72 (patch) | |
tree | dd6a0437ecc216398c324b3ce5ccea1559227831 /crates/rebel-parse/src/grammar/recipe.rs | |
parent | 62abc9e8059a70b2f8106238d724428af9bda76b (diff) | |
download | rebel-bcec2e72909bc63bdc2cb88808789a04f3a13d72.tar rebel-bcec2e72909bc63bdc2cb88808789a04f3a13d72.zip |
rebel-parse, rebel-lang: distinguish let statements and simple assignments
Diffstat (limited to 'crates/rebel-parse/src/grammar/recipe.rs')
-rw-r--r-- | crates/rebel-parse/src/grammar/recipe.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs index 6b96c85..c9fe1e2 100644 --- a/crates/rebel-parse/src/grammar/recipe.rs +++ b/crates/rebel-parse/src/grammar/recipe.rs @@ -34,10 +34,16 @@ peg::parser! { = block:block_stmt() ++ p(';') { ast::Block(block) } pub rule block_stmt() -> ast::BlockStmt<'a> - = dest:typed_pat() op:assign_op() expr:expr() { + = [Token::Keyword(Keyword::Let)] dest:typed_pat() p('=') expr:expr() { + ast::BlockStmt::let_assign(dest, Some(expr)) + } + / [Token::Keyword(Keyword::Let)] dest:typed_pat() { + ast::BlockStmt::let_assign(dest, None) + } + / dest:pat() op:assign_op() expr:expr() { ast::BlockStmt::assign(dest, op, false, expr) } - / dest:typed_pat() p2('=', '+') expr:expr() { + / dest:pat() p2('=', '+') expr:expr() { ast::BlockStmt::assign(dest, Some(Add), true, expr) } / expr:expr() { |