1
0
Fork 0
forked from koniifer/ableos

adding struct syntax

This commit is contained in:
mlokr 2024-05-12 12:21:40 +02:00
parent 4bb5ec1953
commit 80b05779ea

View file

@ -251,7 +251,7 @@ struct Loop {
}
struct Struct {
name: Rc<str>,
id: Ident,
fields: Vec<(Rc<str>, Type)>,
}
@ -397,6 +397,18 @@ impl<'a> Codegen<'a> {
fn expr(&mut self, expr: &'a parser::Expr<'a>, expeted: Option<Type>) -> Option<Value> {
match *expr {
E::BinOp {
left: E::Ident { id, .. },
op: T::Decl,
right: E::Struct { fields, .. },
} => {
let fields = fields
.iter()
.map(|&(name, ty)| (name.into(), self.ty(&ty)))
.collect();
self.records.push(Struct { id: *id, fields });
None
}
E::UnOp {
op: T::Amp, val, ..
} => {