Added dotted pairs

This commit is contained in:
Erin 2022-07-26 19:45:50 +02:00 committed by ondra05
parent f28d454841
commit 8518098e89

View file

@ -37,10 +37,20 @@ fn parser<'a>() -> impl Parser<Token<'a>, Vec<Spanned<Expr<'a>>>, Error = Simple
.map(Box::new) .map(Box::new)
.map(Expr::Quote); .map(Expr::Quote);
atom.or(list) let without_pair = atom
.or(list)
.or(vector) .or(vector)
.or(quote) .or(quote)
.map_with_span(Spanned::new) .map_with_span(Spanned::new);
let pair = without_pair
.clone()
.then_ignore(just(Token::Dot))
.then(without_pair.clone())
.map(|(l, r)| Expr::Pair((Box::new(l), Box::new(r))))
.map_with_span(Spanned::new);
pair.or(without_pair)
}) })
.repeated() .repeated()
.then_ignore(end()) .then_ignore(end())