From f51e1a3c47acbe1229a7e1233689e8a9a8e96b33 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 17 Sep 2017 17:53:21 -0700 Subject: [PATCH] make Operation a tuple-style struct --- src/schala_lang/parsing.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index c8adafd..898fcbe 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -481,9 +481,7 @@ pub enum Expression { } #[derive(Debug, PartialEq)] -pub struct Operation { - op: Rc -} +pub struct Operation(Rc); impl Operation { fn min_precedence() -> i32 { @@ -630,7 +628,7 @@ impl Parser { _ => unreachable!(), }; let rhs = self.precedence_expr(new_precedence)?; - let operation = Operation { op: op_str }; + let operation = Operation(op_str); lhs = BinExp(operation, Box::new(lhs), Box::new(rhs)); } Ok(lhs) @@ -644,7 +642,7 @@ impl Parser { _ => unreachable!(), }; let expr = self.primary()?; - Ok(Expression::PrefixExp(Operation { op: op_str }, Box::new(expr))) + Ok(Expression::PrefixExp(Operation(op_str), Box::new(expr))) }, _ => self.primary() } @@ -841,7 +839,7 @@ mod parse_tests { ($op:expr, $lhs:expr) => { PrefixExp($op, Box::new($lhs)) } } macro_rules! op { - ($op:expr) => { Operation { op: Rc::new($op.to_string()) } } + ($op:expr) => { Operation(Rc::new($op.to_string())) } } macro_rules! var { ($var:expr) => { Variable(Rc::new($var.to_string())) }