New Constructor

This commit is contained in:
greg 2018-08-05 16:04:52 -07:00
parent c637a922a9
commit 32acf89814
2 changed files with 8 additions and 4 deletions

View File

@ -77,7 +77,9 @@ impl Expr {
UserDefined { name: None, .. } => format!("<function>"),
UserDefined { name: Some(name), .. } => format!("<function {}>", name),
},
Expr::Constructor { name } => format!("<constructor {}>", name),
Expr::NewConstructor {
type_name, tag, arity,
} => unimplemented!(),
Expr::Tuple(exprs) => paren_wrapped_vec(exprs),
_ => format!("{:?}", self),
}

View File

@ -32,7 +32,7 @@ pub enum Expr {
NewConstructor {
type_name: Rc<String>,
tag: usize,
arg: Box<Expression>,
arity: usize,
},
Constructor {
name: Rc<String>,
@ -117,8 +117,10 @@ impl Expression {
PrefixExp(op, arg) => op.reduce(symbol_table, arg),
Value(name) => {
match symbol_table.values.get(name) {
Some(Symbol { spec: SymbolSpec::DataConstructor { type_args, .. }, .. }) => {
Expr::Constructor { name: name.clone() }
Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::NewConstructor {
type_name: type_name.clone(),
tag: index.clone(),
arity: type_args.len(),
},
_ => Expr::Val(name.clone()),
}