split expression types

This commit is contained in:
Alain Zscheile 2023-05-22 21:07:32 +02:00
parent 3703b65e41
commit 35ada4a21d

View file

@ -35,7 +35,10 @@ pub struct Entry {
#[derive(Clone, Debug)]
pub enum Expression {
Code {
cfe: bool,
data: Box<[Expression]>,
ret: Option<Box<Expression>>,
},
CodeCfe {
data: Box<[Expression]>,
ret: Option<Box<Expression>>,
},
@ -47,6 +50,10 @@ pub enum Expression {
obj: Box<Expression>,
args: BTreeMap<Box<[Atom]>, (Location, Expression)>,
},
Tag {
obj: Box<Expression>,
args: BTreeMap<Box<[Atom]>, (Location, Expression)>,
},
}
#[derive(Clone, Debug)]
@ -201,10 +208,16 @@ impl Expression {
break;
}
}
Ok(Expression::Code {
cfe,
data: codata.into_boxed_slice(),
ret,
Ok(if cfe {
Expression::CodeCfe {
data: codata.into_boxed_slice(),
ret,
}
} else {
Expression::Code {
data: codata.into_boxed_slice(),
ret,
}
})
}
Some(&(loc, _)) if cfe => Err(Error {
@ -329,7 +342,7 @@ impl Module {
let obj = if ctx.maybe_eat_token(Token::Assign).is_some() {
let obj = Expression::parse_high(ctx)?;
if let Expression::Code { cfe: true, .. } = obj {
if let Expression::CodeCfe { .. } = obj {
flags |= EntryFlags::CTRLFE;
}
Some(obj)