From 434248352901e37f4d86979c4a1009a19d41739f Mon Sep 17 00:00:00 2001 From: John Date: Fri, 12 Apr 2024 14:36:58 -0500 Subject: [PATCH] Update to match changes in cl-token --- src/lib.rs | 72 +++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a366d8e..bb61a54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -214,10 +214,10 @@ pub mod token { let (ty, data) = (token.ty(), token.into_data()); match data { - Data::Integer(v) => return Some(Token::Int(v as _)), - Data::Character(v) => return Some(Token::Char(v)), - Data::Identifier(v) => return Some(Token::Ident(v.into_string())), - Data::String(v) => return Some(Token::Str(v.to_owned())), + TokenData::Integer(v) => return Some(Token::Int(v as _)), + TokenData::Character(v) => return Some(Token::Char(v)), + TokenData::Identifier(v) => return Some(Token::Ident(v.into_string())), + TokenData::String(v) => return Some(Token::Str(v.to_owned())), _ => {} } @@ -274,12 +274,12 @@ pub mod token { match self { $($Name::$name => $rep,)* }.fmt(f) } } - impl TryFrom for $Name { + impl TryFrom for $Name { type Error = $crate::token::Er; - fn try_from(value: cl_token::Type) -> Result { + fn try_from(value: cl_token::TokenKind) -> Result { match value { - cl_token::Type::Comment | - cl_token::Type::Invalid => Err(Er::Invalid), + cl_token::TokenKind::Comment | + cl_token::TokenKind::Invalid => Err(Er::Invalid), $($try_from => Ok($Name::$name),)* _ => Err(Er::NotAnOp) } @@ -291,44 +291,44 @@ pub mod token { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Op { // Delimiter - #["("] Lpa = Type::LParen, - #[")"] Rpa = Type::RParen, - #["["] Lbk = Type::LBrack, - #["]"] Rbk = Type::RBrack, + #["("] Lpa = TokenKind::LParen, + #[")"] Rpa = TokenKind::RParen, + #["["] Lbk = TokenKind::LBrack, + #["]"] Rbk = TokenKind::RBrack, // Member - #["."] Dot = Type::Dot, + #["."] Dot = TokenKind::Dot, // Factor - #["*"] Mul = Type::Star, - #["/"] Div = Type::Slash, - #["%"] Rem = Type::Rem, + #["*"] Mul = TokenKind::Star, + #["/"] Div = TokenKind::Slash, + #["%"] Rem = TokenKind::Rem, // Term - #["+"] Add = Type::Plus, - #["-"] Sub = Type::Minus, + #["+"] Add = TokenKind::Plus, + #["-"] Sub = TokenKind::Minus, // Shift - #["<<"] Shl = Type::LtLt, - #[">>"] Shr = Type::GtGt, + #["<<"] Shl = TokenKind::LtLt, + #[">>"] Shr = TokenKind::GtGt, // Bitwise - #["&"] Ban = Type::Amp, - #["|"] Bor = Type::Bar, - #["^"] Bxr = Type::Xor, + #["&"] Ban = TokenKind::Amp, + #["|"] Bor = TokenKind::Bar, + #["^"] Bxr = TokenKind::Xor, // Logic - #["&&"] Lan = Type::AmpAmp, - #["||"] Lor = Type::BarBar, - #["^^"] Lxr = Type::XorXor, + #["&&"] Lan = TokenKind::AmpAmp, + #["||"] Lor = TokenKind::BarBar, + #["^^"] Lxr = TokenKind::XorXor, // Range - #["..="] Inc = Type::DotDotEq, - #[".."] Exc = Type::DotDot, + #["..="] Inc = TokenKind::DotDotEq, + #[".."] Exc = TokenKind::DotDot, // Compare - #["<"] Lt = Type::Lt, - #["<="] Lte = Type::LtEq, - #["=="] Eq = Type::EqEq, - #["!="] Neq = Type::BangEq, - #[">="] Gte = Type::GtEq, - #[">"] Gt = Type::Gt, + #["<"] Lt = TokenKind::Lt, + #["<="] Lte = TokenKind::LtEq, + #["=="] Eq = TokenKind::EqEq, + #["!="] Neq = TokenKind::BangEq, + #[">="] Gte = TokenKind::GtEq, + #[">"] Gt = TokenKind::Gt, // Unary-only - #["!"] Not = Type::Bang, + #["!"] Not = TokenKind::Bang, // Postfix unary - #["?"] Huh = Type::Question, + #["?"] Huh = TokenKind::Question, } }