parser: make the RHS object in module entries optional

This commit is contained in:
Alain Zscheile 2023-05-21 13:30:08 +02:00
parent 8f1f746a82
commit d17524a7d2

View File

@ -26,7 +26,8 @@ pub struct Entry {
pub nloc: Location,
// technically this is a set, but that would just waste space here...
pub args: Box<[Atom]>,
pub obj: Object,
// might be a dummy
pub obj: Option<Object>,
// we use a bitflag here to conserve memory
pub flags: EntryFlags,
}
@ -347,12 +348,15 @@ impl Module {
}
}
ctx.expect_token(Token::Assign, "=")?;
let obj = Object::parse_high(ctx)?;
if let Object::Code { cfe: true, .. } = obj {
flags |= EntryFlags::CTRLFE;
}
let obj = if ctx.maybe_eat_token(Token::Assign).is_some() {
let obj = Object::parse_high(ctx)?;
if let Object::Code { cfe: true, .. } = obj {
flags |= EntryFlags::CTRLFE;
}
Some(obj)
} else {
None
};
// code object
ret.entries.insert(