21 lines
471 B
Rust
21 lines
471 B
Rust
use super::*;
|
|
|
|
pub enum Type {
|
|
Ident(Ident),
|
|
}
|
|
|
|
impl Node for Type {
|
|
fn parse(ctx: &mut ParseCtx) -> Result<Self, CompilerMsg> {
|
|
Ok(match ctx.expect_next()? {
|
|
Token::Ident(s) => Self::Ident(ctx.ident(s)),
|
|
t => ctx.unexpected(&t, "a type")?,
|
|
})
|
|
}
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter, ctx: DisplayCtx) -> std::fmt::Result {
|
|
match self {
|
|
Type::Ident(id) => id.fmt(f, ctx),
|
|
}
|
|
}
|
|
}
|