NewConstructor -> Constructor

This commit is contained in:
greg 2018-08-05 19:14:02 -07:00
parent 348a6f7c76
commit 5ead1e5d44
2 changed files with 5 additions and 5 deletions

View File

@ -77,7 +77,7 @@ impl Expr {
UserDefined { name: None, .. } => format!("<function>"), UserDefined { name: None, .. } => format!("<function>"),
UserDefined { name: Some(name), .. } => format!("<function '{}'>", name), UserDefined { name: Some(name), .. } => format!("<function '{}'>", name),
}, },
Expr::NewConstructor { Expr::Constructor {
type_name, name, tag, arity, type_name, name, tag, arity,
} => if *arity == 0 { } => if *arity == 0 {
format!("{}", name) format!("{}", name)
@ -152,13 +152,13 @@ impl<'a> State<'a> {
literal @ Lit(_) => Ok(literal), literal @ Lit(_) => Ok(literal),
Call { box f, args } => { Call { box f, args } => {
match self.expression(f)? { match self.expression(f)? {
NewConstructor { type_name, name, tag, arity} => self.apply_data_constructor(type_name, name, tag, arity, args), Constructor { type_name, name, tag, arity} => self.apply_data_constructor(type_name, name, tag, arity, args),
Func(f) => self.apply_function(f, args), Func(f) => self.apply_function(f, args),
other => return Err(format!("Tried to call {:?} which is not a function or data constructor", other)), other => return Err(format!("Tried to call {:?} which is not a function or data constructor", other)),
} }
}, },
Val(v) => self.value(v), Val(v) => self.value(v),
constructor @ NewConstructor { .. } => Ok(constructor), constructor @ Constructor { .. } => Ok(constructor),
func @ Func(_) => Ok(func), func @ Func(_) => Ok(func),
Tuple(exprs) => Ok(Tuple(exprs.into_iter().map(|expr| self.expression(expr)).collect::<Result<Vec<Expr>,_>>()?)), Tuple(exprs) => Ok(Tuple(exprs.into_iter().map(|expr| self.expression(expr)).collect::<Result<Vec<Expr>,_>>()?)),
Conditional { box cond, then_clause, else_clause } => self.conditional(cond, then_clause, else_clause), Conditional { box cond, then_clause, else_clause } => self.conditional(cond, then_clause, else_clause),

View File

@ -29,7 +29,7 @@ pub enum Expr {
Tuple(Vec<Expr>), Tuple(Vec<Expr>),
Func(Func), Func(Func),
Val(Rc<String>), Val(Rc<String>),
NewConstructor { Constructor {
type_name: Rc<String>, type_name: Rc<String>,
name: Rc<String>, name: Rc<String>,
tag: usize, tag: usize,
@ -118,7 +118,7 @@ impl Expression {
PrefixExp(op, arg) => op.reduce(symbol_table, arg), PrefixExp(op, arg) => op.reduce(symbol_table, arg),
Value(name) => { Value(name) => {
match symbol_table.lookup_by_name(name) { match symbol_table.lookup_by_name(name) {
Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::NewConstructor { Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::Constructor {
type_name: type_name.clone(), type_name: type_name.clone(),
name: name.clone(), name: name.clone(),
tag: index.clone(), tag: index.clone(),