21 lines
491 B
Rust
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"),
|
|
}
|
|
}
|
|
}
|