diff --git a/src/parser.rs b/src/parser.rs index 68ca577..ca33a70 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -111,7 +111,7 @@ impl Parser { } fn get_precedence(&self, op: &Op) -> Precedence { - match &op.repr[..] { + match &op.0[..] { "+" => 10, "-" => 10, "*" => 20, @@ -297,7 +297,7 @@ impl Parser { } } - lhs = Expression::BinExp(op.repr, Box::new(lhs), Box::new(rhs)); + lhs = Expression::BinExp(op.0, Box::new(lhs), Box::new(rhs)); } Ok(lhs) diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 167e087..64ea8cf 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -15,9 +15,7 @@ pub enum Token { } #[derive(Debug, Clone, PartialEq)] -pub struct Op { - pub repr: String, -} +pub struct Op(pub String); #[derive(Debug, Clone, PartialEq)] pub enum Kw { @@ -100,7 +98,7 @@ pub fn tokenize(input: &str) -> TokenizeResult { break; } } - Operator(Op { repr: buffer }) + Operator(Op(buffer)) } c => { if c == '.' && !iter.peek().map_or(false, |x| is_digit(x)) {