Fix todo/error parsing

This was a bit more tricky than anticipated but played out nicely in
  the end. Now we have one holistic way of parsing todos and errors
  instead of it being duplicated between when/clause and sequence. The
  error/todo parser has been moved up to the expression part rather than
  being managed when parsing sequences. Not sure what motivated that to
  begin with.

  Fixes #621.
This commit is contained in:
KtorZ
2023-07-05 20:12:57 +02:00
parent 6d7aec804c
commit ed85cb1c00
15 changed files with 525 additions and 209 deletions

View File

@@ -27,7 +27,7 @@ pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError
|((((public, name), (arguments, args_span)), return_annotation), body), span| {
ast::UntypedDefinition::Fn(ast::Function {
arguments,
body: body.unwrap_or_else(|| UntypedExpr::todo(span, None)),
body: body.unwrap_or_else(|| UntypedExpr::todo(None, span)),
doc: None,
location: ast::Span {
start: span.start,

View File

@@ -23,7 +23,7 @@ pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError
.map_with_span(|(((fail, name), span_end), body), span| {
ast::UntypedDefinition::Test(ast::Function {
arguments: vec![],
body: body.unwrap_or_else(|| UntypedExpr::todo(span, None)),
body: body.unwrap_or_else(|| UntypedExpr::todo(None, span)),
doc: None,
location: span_end,
end_position: span.end - 1,