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 list = list.map(Expr::List);
|
||||||
|
|
||||||
let quote = just(Token::Quote)
|
let quote = just(Token::Quote)
|
||||||
.ignore_then(expr)
|
.ignore_then(expr.clone())
|
||||||
.map(Box::new)
|
.map(Box::new)
|
||||||
.map(Expr::Quote);
|
.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(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())
|
||||||
|
|
Loading…
Reference in a new issue