Skip to content

Commit

Permalink
fix: bad block syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmasoldi3r committed Dec 7, 2023
1 parent ddc657c commit 288cec3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/block_syntax.saturn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

let foo = protect in {
print("Me");
};
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod tests;

#[derive(Parser, Clone)]
#[command(name = "Saturnus")]
#[command(version = "v1.1.0")]
#[command(version = "v1.1.1")]
#[command(author = "Pablo B. <pablobc.1995@gmail.com>")]
#[command(
about = "Saturnus: A modern language that compiles to Lua",
Expand Down
17 changes: 16 additions & 1 deletion src/parser/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,22 @@ peg::parser! {

rule call_expression() -> CallExpression
= head:(
callee:member_expression() _ arguments:call_arguments()
callee:member_expression() _ "in" _ arguments:do_literal()
{ CallSubExpression { callee: Some(callee), arguments:vec![
Expression::Lambda(Box::new(Lambda{
arguments: vec![Argument {
name: Identifier("it".into()),
spread: false,
decorators: vec![]
}, Argument {
name: Identifier("rest".into()),
spread: true,
decorators: vec![]
}],
body: ScriptOrExpression::Script(arguments.body)
}))
] }.into() }
/ callee:member_expression() _ arguments:call_arguments()
{ CallSubExpression { callee: Some(callee), arguments }.into() }
/ callee:member_expression() _ arg:table_expression()
{ CallSubExpression { callee: Some(callee), arguments: vec![arg] } }
Expand Down

0 comments on commit 288cec3

Please sign in to comment.