More named struct reduction work
This commit is contained in:
parent
e708c728d2
commit
c9bfa2b540
@ -137,7 +137,7 @@ impl Expr {
|
|||||||
match self {
|
match self {
|
||||||
ConditionalTargetSigilValue => replacement.clone(),
|
ConditionalTargetSigilValue => replacement.clone(),
|
||||||
Unit | Lit(_) | Func(_) | Val(_) | Constructor { .. } |
|
Unit | Lit(_) | Func(_) | Val(_) | Constructor { .. } |
|
||||||
CaseMatch { .. } | UnimplementedSigilValue => self,
|
CaseMatch { .. } | UnimplementedSigilValue | ReductionError(_) => self,
|
||||||
Tuple(exprs) => Tuple(exprs.into_iter().map(|e| e.replace_conditional_target_sigil(replacement)).collect()),
|
Tuple(exprs) => Tuple(exprs.into_iter().map(|e| e.replace_conditional_target_sigil(replacement)).collect()),
|
||||||
Call { f, args } => {
|
Call { f, args } => {
|
||||||
let new_args = args.into_iter().map(|e| e.replace_conditional_target_sigil(replacement)).collect();
|
let new_args = args.into_iter().map(|e| e.replace_conditional_target_sigil(replacement)).collect();
|
||||||
@ -227,6 +227,7 @@ impl<'a> State<'a> {
|
|||||||
CaseMatch { box cond, alternatives } => self.case_match_expression(cond, alternatives),
|
CaseMatch { box cond, alternatives } => self.case_match_expression(cond, alternatives),
|
||||||
ConditionalTargetSigilValue => Ok(Node::Expr(ConditionalTargetSigilValue)),
|
ConditionalTargetSigilValue => Ok(Node::Expr(ConditionalTargetSigilValue)),
|
||||||
UnimplementedSigilValue => Err(format!("Sigil value eval not implemented")),
|
UnimplementedSigilValue => Err(format!("Sigil value eval not implemented")),
|
||||||
|
ReductionError(err) => Err(format!("Reduction error: {}", err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,8 @@ pub enum Expr {
|
|||||||
cond: Box<Expr>,
|
cond: Box<Expr>,
|
||||||
alternatives: Vec<Alternative>
|
alternatives: Vec<Alternative>
|
||||||
},
|
},
|
||||||
UnimplementedSigilValue
|
UnimplementedSigilValue,
|
||||||
|
ReductionError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type BoundVars = Vec<Option<Rc<String>>>; //remember that order matters here
|
pub type BoundVars = Vec<Option<Rc<String>>>; //remember that order matters here
|
||||||
@ -168,11 +169,11 @@ fn reduce_lambda(params: &Vec<FormalParam>, body: &Block, symbol_table: &SymbolT
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reduce_named_struct(name: &Rc<String>, fields: &Vec<(Rc<String>, Meta<Expression>)>, symbol_table: &SymbolTable) -> Expr {
|
fn reduce_named_struct(name: &Rc<String>, fields: &Vec<(Rc<String>, Meta<Expression>)>, symbol_table: &SymbolTable) -> Expr {
|
||||||
/*
|
|
||||||
let (type_name, table_fields) = match symbol_table.lookup_by_name(name) {
|
let (type_name, table_fields) = match symbol_table.lookup_by_name(name) {
|
||||||
Some(Symbol { spec: SymbolSpec::RecordConstructor { fields }, name, .. }) => (name, fields),
|
Some(Symbol { spec: SymbolSpec::RecordConstructor { members, type_name }, .. }) => (type_name, members),
|
||||||
None => panic!("YOLO SWAGG"),
|
_ => return Expr::ReductionError("Not a record constructor".to_string()),
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
let arity = table_fields.len();
|
let arity = table_fields.len();
|
||||||
let f = Expr::Constructor {
|
let f = Expr::Constructor {
|
||||||
type_name, arity,
|
type_name, arity,
|
||||||
|
Loading…
Reference in New Issue
Block a user