From f9c2fc3f9d48b5b29a214dfe83d5af198429b948 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 7 Aug 2018 17:09:53 -0700 Subject: [PATCH] Make code more concise --- schala-lang/src/reduced_ast.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/schala-lang/src/reduced_ast.rs b/schala-lang/src/reduced_ast.rs index 66a4865..d6dcf7b 100644 --- a/schala-lang/src/reduced_ast.rs +++ b/schala-lang/src/reduced_ast.rs @@ -116,16 +116,14 @@ impl Expression { BoolLiteral(b) => Expr::Lit(Lit::Bool(*b)), BinExp(binop, lhs, rhs) => binop.reduce(symbol_table, lhs, rhs), PrefixExp(op, arg) => op.reduce(symbol_table, arg), - Value(name) => { - match symbol_table.lookup_by_name(name) { - Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::Constructor { - type_name: type_name.clone(), - name: name.clone(), - tag: index.clone(), - arity: type_args.len(), - }, - _ => Expr::Val(name.clone()), - } + Value(name) => match symbol_table.lookup_by_name(name) { + Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::Constructor { + type_name: type_name.clone(), + name: name.clone(), + tag: index.clone(), + arity: type_args.len(), + }, + _ => Expr::Val(name.clone()), }, Call { f, arguments } => Expr::Call { f: Box::new(f.reduce(symbol_table)),