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