Simplified AST
This commit is contained in:
parent
bb50f1e450
commit
afef6bf6af
|
@ -12,10 +12,8 @@ pub enum Expr<'a> {
|
|||
Map(Vec<(Self, Self)>),
|
||||
Symbol(Cow<'a, str>),
|
||||
Keyword(Cow<'a, str>),
|
||||
Bool(bool),
|
||||
Number(OrderedFloat<f64>),
|
||||
String(Cow<'a, str>),
|
||||
Nil,
|
||||
}
|
||||
|
||||
impl<'a> Display for Expr<'a> {
|
||||
|
@ -31,10 +29,8 @@ impl<'a> Display for Expr<'a> {
|
|||
),
|
||||
Self::Symbol(sym) => write!(f, "{sym}"),
|
||||
Self::Keyword(kw) => write!(f, ":{kw}"),
|
||||
Self::Bool(b) => write!(f, "{b}"),
|
||||
Self::Number(n) => write!(f, "{n}"),
|
||||
Self::String(s) => write!(f, "\"{s}\""),
|
||||
Self::Nil => write!(f, "nil"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,6 @@ pub fn read(src: &str) -> Result<Vec<Expr>, Vec<Simple<Token<'_>>>> {
|
|||
fn parser<'a>() -> impl Parser<Token<'a>, Vec<Expr<'a>>, Error = Simple<Token<'a>>> {
|
||||
recursive(|expr| {
|
||||
let atom = select! {
|
||||
Token::Symbol("true") => Expr::Bool(true),
|
||||
Token::Symbol("false") => Expr::Bool(false),
|
||||
Token::Symbol("nil") => Expr::Nil,
|
||||
Token::Symbol(s) => Expr::Symbol(s.into()),
|
||||
Token::Keyword(k) => Expr::Keyword(k.into()),
|
||||
Token::String(s) => Expr::String(s.into()),
|
||||
|
|
Loading…
Reference in a new issue