error on whitespaces / newlines :(

This commit is contained in:
LunarAkai 2025-08-07 20:05:16 +02:00
commit 3de0631341

View file

@ -64,19 +64,21 @@ where
add_sub add_sub
}); });
let decl = recursive(|decl| {
let var = just(Token::Var) let r#var = just(Token::Var)
.ignore_then(ident) .ignore_then(ident)
.then_ignore(just(Token::Assign)) .then_ignore(just(Token::Assign))
.then(expr.clone()) .then(expr.clone())
.then_ignore(just(Token::NewLine).or_not()) .then_ignore(just(Token::NewLine).or_not())
.then(decl)
.map(|(name, rhs)| Expr::Assignment { .map(|(name, rhs)| Expr::Assignment {
target: Box::new(Expr::Ident(name)), target: Box::new(Expr::Ident(name.0)),
value: Box::new(rhs), value: Box::new(rhs),
}); });
r#var.or(expr)
});
decl.then_ignore(end())
var.or(expr)
} }