Simplified AST

main
ondra05 2022-07-24 21:50:35 +02:00
parent 880291d2cf
commit ee96d53c28
2 changed files with 0 additions and 7 deletions

View File

@ -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"),
}
}
}

View File

@ -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()),