This commit is contained in:
2026-04-17 18:51:12 -04:00
parent 2f91e454dd
commit b3f77076d4
20 changed files with 244 additions and 192 deletions
+12 -3
View File
@@ -1,16 +1,25 @@
use super::*;
pub struct Ident(pub String);
pub struct Ident {
pub name: String,
pub span: Span,
}
impl Node for Ident {
fn parse(ctx: &mut super::ParseCtx) -> Result<Self, crate::io::CompilerMsg> {
match ctx.expect_next()? {
Token::Ident(ident) => Ok(Self(ident)),
Token::Ident(ident) => Ok(ctx.ident(ident)),
t => ctx.unexpected(&t, "an identifier"),
}
}
fn fmt(&self, f: &mut std::fmt::Formatter, _: DisplayCtx) -> std::fmt::Result {
write!(f, "{}", self.0)
write!(f, "{}", self.name)
}
}
impl std::fmt::Display for Ident {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.name.fmt(f)
}
}