Files
lang/src/parser/nodes/ident.rs
T
2026-04-11 03:50:43 -04:00

21 lines
491 B
Rust

use super::*;
pub struct Ident {
pub inner: 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 {
fn parse(ctx: &mut super::ParseCtx) -> Result<Self, crate::io::CompilerMsg> {
match ctx.expect_next()? {
Token::Ident(ident) => Ok(Self { inner: ident }),
t => ctx.unexpected(&t, "an identifier"),
}
}
}