Added dotted pairs
This commit is contained in:
parent
f28d454841
commit
8518098e89
|
@ -29,7 +29,7 @@ fn parser<'a>() -> impl Parser<Token<'a>, Vec<Spanned<Expr<'a>>>, Error = Simple
|
|||
let vector = just(Token::Octothrope)
|
||||
.ignore_then(list.clone())
|
||||
.map(Expr::Vector);
|
||||
|
||||
|
||||
let list = list.map(Expr::List);
|
||||
|
||||
let quote = just(Token::Quote)
|
||||
|
@ -37,10 +37,20 @@ fn parser<'a>() -> impl Parser<Token<'a>, Vec<Spanned<Expr<'a>>>, Error = Simple
|
|||
.map(Box::new)
|
||||
.map(Expr::Quote);
|
||||
|
||||
atom.or(list)
|
||||
let without_pair = atom
|
||||
.or(list)
|
||||
.or(vector)
|
||||
.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()
|
||||
.then_ignore(end())
|
||||
|
|
Loading…
Reference in a new issue