Dotted pair structures
This commit is contained in:
parent
b7240fa1c1
commit
f28d454841
|
@ -43,6 +43,7 @@ impl<T: Hash> Hash for Spanned<T> {
|
||||||
pub enum Expr<'a> {
|
pub enum Expr<'a> {
|
||||||
List(Vec<Spanned<Self>>),
|
List(Vec<Spanned<Self>>),
|
||||||
Vector(Vec<Spanned<Self>>),
|
Vector(Vec<Spanned<Self>>),
|
||||||
|
Pair((Box<Spanned<Self>>, Box<Spanned<Self>>)),
|
||||||
Quote(Box<Spanned<Self>>),
|
Quote(Box<Spanned<Self>>),
|
||||||
Symbol(Cow<'a, str>),
|
Symbol(Cow<'a, str>),
|
||||||
Keyword(Cow<'a, str>),
|
Keyword(Cow<'a, str>),
|
||||||
|
@ -58,6 +59,7 @@ impl<'a> Display for Expr<'a> {
|
||||||
write!(f, "#")?;
|
write!(f, "#")?;
|
||||||
fmt_list(f, vec)
|
fmt_list(f, vec)
|
||||||
}
|
}
|
||||||
|
Self::Pair((l, r)) => write!(f, "{l} . {r}"),
|
||||||
Self::Quote(expr) => write!(f, "'{expr}"),
|
Self::Quote(expr) => write!(f, "'{expr}"),
|
||||||
Self::Symbol(sym) => write!(f, "{sym}"),
|
Self::Symbol(sym) => write!(f, "{sym}"),
|
||||||
Self::Keyword(kw) => write!(f, ":{kw}"),
|
Self::Keyword(kw) => write!(f, ":{kw}"),
|
||||||
|
|
|
@ -11,6 +11,9 @@ pub enum Token<'a> {
|
||||||
#[token(")")]
|
#[token(")")]
|
||||||
RightParen,
|
RightParen,
|
||||||
|
|
||||||
|
#[token(".")]
|
||||||
|
Dot,
|
||||||
|
|
||||||
#[token("'")]
|
#[token("'")]
|
||||||
Quote,
|
Quote,
|
||||||
|
|
||||||
|
@ -51,6 +54,7 @@ impl<'a> Display for Token<'a> {
|
||||||
match self {
|
match self {
|
||||||
Token::LeftParen => write!(f, "("),
|
Token::LeftParen => write!(f, "("),
|
||||||
Token::RightParen => write!(f, ")"),
|
Token::RightParen => write!(f, ")"),
|
||||||
|
Token::Dot => write!(f, "."),
|
||||||
Token::Quote => write!(f, "'"),
|
Token::Quote => write!(f, "'"),
|
||||||
Token::Octothrope => write!(f, "#"),
|
Token::Octothrope => write!(f, "#"),
|
||||||
Token::String(s) => write!(f, "\"{s}\""),
|
Token::String(s) => write!(f, "\"{s}\""),
|
||||||
|
|
Loading…
Reference in a new issue