Dotted pair structures

main
ondra05 2022-07-26 19:29:56 +02:00
parent 238d90a653
commit a42454026f
2 changed files with 6 additions and 0 deletions

View File

@ -43,6 +43,7 @@ impl<T: Hash> Hash for Spanned<T> {
pub enum Expr<'a> {
List(Vec<Spanned<Self>>),
Vector(Vec<Spanned<Self>>),
Pair((Box<Spanned<Self>>, Box<Spanned<Self>>)),
Quote(Box<Spanned<Self>>),
Symbol(Cow<'a, str>),
Keyword(Cow<'a, str>),
@ -58,6 +59,7 @@ impl<'a> Display for Expr<'a> {
write!(f, "#")?;
fmt_list(f, vec)
}
Self::Pair((l, r)) => write!(f, "{l} . {r}"),
Self::Quote(expr) => write!(f, "'{expr}"),
Self::Symbol(sym) => write!(f, "{sym}"),
Self::Keyword(kw) => write!(f, ":{kw}"),

View File

@ -11,6 +11,9 @@ pub enum Token<'a> {
#[token(")")]
RightParen,
#[token(".")]
Dot,
#[token("'")]
Quote,
@ -51,6 +54,7 @@ impl<'a> Display for Token<'a> {
match self {
Token::LeftParen => write!(f, "("),
Token::RightParen => write!(f, ")"),
Token::Dot => write!(f, "."),
Token::Quote => write!(f, "'"),
Token::Octothrope => write!(f, "#"),
Token::String(s) => write!(f, "\"{s}\""),