Provide better parse errors in trace when using comma instead of colon.
This commit is contained in:
parent
2922c0aa6f
commit
30ddfa23d9
|
@ -29,11 +29,22 @@ pub fn parser<'a>(
|
||||||
just(Token::Trace)
|
just(Token::Trace)
|
||||||
.ignore_then(choice((string::hybrid(), expression.clone())))
|
.ignore_then(choice((string::hybrid(), expression.clone())))
|
||||||
.then(
|
.then(
|
||||||
just(Token::Colon)
|
choice((just(Token::Colon), just(Token::Comma)))
|
||||||
.ignore_then(
|
.then(
|
||||||
choice((string::hybrid(), expression.clone()))
|
choice((string::hybrid(), expression.clone()))
|
||||||
.separated_by(just(Token::Comma)),
|
.separated_by(just(Token::Comma)),
|
||||||
)
|
)
|
||||||
|
.validate(|(token, arguments), span, emit| {
|
||||||
|
if token != Token::Colon {
|
||||||
|
emit(ParseError::expected_but_got(
|
||||||
|
Pattern::Token(Token::Colon),
|
||||||
|
Pattern::Token(token),
|
||||||
|
span.map(|start, _end| (start, start + 1)),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
arguments
|
||||||
|
})
|
||||||
.or_not()
|
.or_not()
|
||||||
.map(|opt| opt.unwrap_or_default()),
|
.map(|opt| opt.unwrap_or_default()),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue