This commit is contained in:
2026-04-17 01:49:43 -04:00
parent e5ae506a84
commit 2f91e454dd
16 changed files with 268 additions and 401 deletions
+7 -11
View File
@@ -1,20 +1,16 @@
use super::*;
pub struct Ident {
pub inner: String,
}
pub struct Ident(pub String);
impl FmtNode for Ident {
fn fmt(&self, f: &mut std::fmt::Formatter, _: DisplayCtx) -> std::fmt::Result {
write!(f, "{}", self.inner)
}
}
impl Parsable for Ident {
impl Node for Ident {
fn parse(ctx: &mut super::ParseCtx) -> Result<Self, crate::io::CompilerMsg> {
match ctx.expect_next()? {
Token::Ident(ident) => Ok(Self { inner: ident }),
Token::Ident(ident) => Ok(Self(ident)),
t => ctx.unexpected(&t, "an identifier"),
}
}
fn fmt(&self, f: &mut std::fmt::Formatter, _: DisplayCtx) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}