Operator only needs to be a tuple struct
This commit is contained in:
parent
e5ee072b00
commit
297003c0b0
@ -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)
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user