Add dot as binop

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-06 17:55:56 -04:00
parent 5d3021ced7
commit d238610f33

View File

@@ -26,29 +26,31 @@ impl From<Token> for UnOp {
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BinOp { pub enum BinOp {
Plus,
Minus,
Times,
Div,
EqEq, EqEq,
Lt, Lt,
Gt, Gt,
LtEq, LtEq,
GtEq, GtEq,
Plus,
Minus,
Times,
Div,
Dot,
} }
impl From<TokenKind> for BinOp { impl From<TokenKind> for BinOp {
fn from(other: TokenKind) -> Self { fn from(other: TokenKind) -> Self {
match other { match other {
TokenKind::Plus => BinOp::Plus,
TokenKind::Minus => BinOp::Minus,
TokenKind::Splat => BinOp::Times,
TokenKind::FSlash => BinOp::Div,
TokenKind::EqEq => BinOp::EqEq, TokenKind::EqEq => BinOp::EqEq,
TokenKind::LtEq => BinOp::LtEq, TokenKind::LtEq => BinOp::LtEq,
TokenKind::GtEq => BinOp::GtEq, TokenKind::GtEq => BinOp::GtEq,
TokenKind::Lt => BinOp::Lt, TokenKind::Lt => BinOp::Lt,
TokenKind::Gt => BinOp::Gt, TokenKind::Gt => BinOp::Gt,
TokenKind::Plus => BinOp::Plus,
TokenKind::Minus => BinOp::Minus,
TokenKind::Splat => BinOp::Times,
TokenKind::FSlash => BinOp::Div,
TokenKind::Dot => BinOp::Dot,
_ => panic!("{:?} cannot be converted to a binop", other), _ => panic!("{:?} cannot be converted to a binop", other),
} }
} }