Merge pull request #6767 from wontem/comments-in-repl

Ignore comments in repl
This commit is contained in:
Luke Boswell 2024-05-22 11:26:10 +10:00 committed by GitHub
commit 33075285b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -2346,10 +2346,13 @@ fn parse_expr_end<'a>(
} }
pub fn loc_expr<'a>(accept_multi_backpassing: bool) -> impl Parser<'a, Loc<Expr<'a>>, EExpr<'a>> { pub fn loc_expr<'a>(accept_multi_backpassing: bool) -> impl Parser<'a, Loc<Expr<'a>>, EExpr<'a>> {
expr_start(ExprParseOptions { space0_before_e(
accept_multi_backpassing, expr_start(ExprParseOptions {
check_for_arrow: true, accept_multi_backpassing,
}) check_for_arrow: true,
}),
EExpr::IndentEnd,
)
} }
pub fn merge_spaces<'a>( pub fn merge_spaces<'a>(

View file

@ -275,6 +275,9 @@ pub fn parse_src<'a>(arena: &'a Bump, line: &'a str) -> ParseOutcome<'a> {
match roc_parse::expr::loc_expr(true).parse(arena, State::new(src_bytes), 0) { match roc_parse::expr::loc_expr(true).parse(arena, State::new(src_bytes), 0) {
Ok((_, loc_expr, _)) => ParseOutcome::Expr(loc_expr.value), Ok((_, loc_expr, _)) => ParseOutcome::Expr(loc_expr.value),
Err((roc_parse::parser::Progress::MadeProgress, EExpr::Start(_))) => {
ParseOutcome::Empty
}
// Special case some syntax errors to allow for multi-line inputs // Special case some syntax errors to allow for multi-line inputs
Err((_, EExpr::Closure(EClosure::Body(_, _), _))) Err((_, EExpr::Closure(EClosure::Body(_, _), _)))
| Err((_, EExpr::When(EWhen::Pattern(EPattern::Start(_), _), _))) | Err((_, EExpr::When(EWhen::Pattern(EPattern::Start(_), _), _)))