simplified syntax rules
This commit is contained in:
parent
a592cf80f2
commit
cb20383f08
|
@ -33,24 +33,22 @@ fn parser<'s>() -> impl Parser<Token<'s>, Vec<Spanned<Expr<'s>>>, Error = Simple
|
|||
let list = list.map(Expr::List);
|
||||
|
||||
let quote = just(Token::Quote)
|
||||
.ignore_then(expr)
|
||||
.ignore_then(expr.clone())
|
||||
.map(Box::new)
|
||||
.map(Expr::Quote);
|
||||
|
||||
let without_pair = atom
|
||||
let pair = expr
|
||||
.clone()
|
||||
.then_ignore(just(Token::Dot))
|
||||
.then(expr)
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
|
||||
.map(|(l, r)| Expr::Pair((Box::new(l), Box::new(r))));
|
||||
|
||||
atom.or(pair)
|
||||
.or(list)
|
||||
.or(vector)
|
||||
.or(quote)
|
||||
.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)
|
||||
.map_with_span(Spanned::new)
|
||||
})
|
||||
.repeated()
|
||||
.then_ignore(end())
|
||||
|
|
Loading…
Reference in a new issue