work
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
use super::*;
|
||||
|
||||
pub enum Item {
|
||||
Module(Id<Module>),
|
||||
Statement(Id<Statement>),
|
||||
}
|
||||
|
||||
impl Parsable for Item {
|
||||
fn parse(ctx: &mut ParseCtx) -> Result<Self, CompilerMsg> {
|
||||
Ok(match ctx.expect_peek()? {
|
||||
Token::Fn => Self::Module(ctx.parse()?),
|
||||
_ => Self::Statement(ctx.parse()?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl FmtNode for Item {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter, ctx: DisplayCtx) -> std::fmt::Result {
|
||||
match self {
|
||||
Item::Module(id) => write!(f, "{}", id.dsp(ctx)),
|
||||
Item::Statement(id) => write!(f, "{}", id.dsp(ctx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user