Update to match changes in cl-token
This commit is contained in:
parent
edad0a2685
commit
4342483529
72
src/lib.rs
72
src/lib.rs
@ -214,10 +214,10 @@ pub mod token {
|
|||||||
let (ty, data) = (token.ty(), token.into_data());
|
let (ty, data) = (token.ty(), token.into_data());
|
||||||
|
|
||||||
match data {
|
match data {
|
||||||
Data::Integer(v) => return Some(Token::Int(v as _)),
|
TokenData::Integer(v) => return Some(Token::Int(v as _)),
|
||||||
Data::Character(v) => return Some(Token::Char(v)),
|
TokenData::Character(v) => return Some(Token::Char(v)),
|
||||||
Data::Identifier(v) => return Some(Token::Ident(v.into_string())),
|
TokenData::Identifier(v) => return Some(Token::Ident(v.into_string())),
|
||||||
Data::String(v) => return Some(Token::Str(v.to_owned())),
|
TokenData::String(v) => return Some(Token::Str(v.to_owned())),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,12 +274,12 @@ pub mod token {
|
|||||||
match self { $($Name::$name => $rep,)* }.fmt(f)
|
match self { $($Name::$name => $rep,)* }.fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl TryFrom<cl_token::Type> for $Name {
|
impl TryFrom<cl_token::TokenKind> for $Name {
|
||||||
type Error = $crate::token::Er;
|
type Error = $crate::token::Er;
|
||||||
fn try_from(value: cl_token::Type) -> Result<Self, Self::Error> {
|
fn try_from(value: cl_token::TokenKind) -> Result<Self, Self::Error> {
|
||||||
match value {
|
match value {
|
||||||
cl_token::Type::Comment |
|
cl_token::TokenKind::Comment |
|
||||||
cl_token::Type::Invalid => Err(Er::Invalid),
|
cl_token::TokenKind::Invalid => Err(Er::Invalid),
|
||||||
$($try_from => Ok($Name::$name),)*
|
$($try_from => Ok($Name::$name),)*
|
||||||
_ => Err(Er::NotAnOp)
|
_ => Err(Er::NotAnOp)
|
||||||
}
|
}
|
||||||
@ -291,44 +291,44 @@ pub mod token {
|
|||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum Op {
|
pub enum Op {
|
||||||
// Delimiter
|
// Delimiter
|
||||||
#["("] Lpa = Type::LParen,
|
#["("] Lpa = TokenKind::LParen,
|
||||||
#[")"] Rpa = Type::RParen,
|
#[")"] Rpa = TokenKind::RParen,
|
||||||
#["["] Lbk = Type::LBrack,
|
#["["] Lbk = TokenKind::LBrack,
|
||||||
#["]"] Rbk = Type::RBrack,
|
#["]"] Rbk = TokenKind::RBrack,
|
||||||
// Member
|
// Member
|
||||||
#["."] Dot = Type::Dot,
|
#["."] Dot = TokenKind::Dot,
|
||||||
// Factor
|
// Factor
|
||||||
#["*"] Mul = Type::Star,
|
#["*"] Mul = TokenKind::Star,
|
||||||
#["/"] Div = Type::Slash,
|
#["/"] Div = TokenKind::Slash,
|
||||||
#["%"] Rem = Type::Rem,
|
#["%"] Rem = TokenKind::Rem,
|
||||||
// Term
|
// Term
|
||||||
#["+"] Add = Type::Plus,
|
#["+"] Add = TokenKind::Plus,
|
||||||
#["-"] Sub = Type::Minus,
|
#["-"] Sub = TokenKind::Minus,
|
||||||
// Shift
|
// Shift
|
||||||
#["<<"] Shl = Type::LtLt,
|
#["<<"] Shl = TokenKind::LtLt,
|
||||||
#[">>"] Shr = Type::GtGt,
|
#[">>"] Shr = TokenKind::GtGt,
|
||||||
// Bitwise
|
// Bitwise
|
||||||
#["&"] Ban = Type::Amp,
|
#["&"] Ban = TokenKind::Amp,
|
||||||
#["|"] Bor = Type::Bar,
|
#["|"] Bor = TokenKind::Bar,
|
||||||
#["^"] Bxr = Type::Xor,
|
#["^"] Bxr = TokenKind::Xor,
|
||||||
// Logic
|
// Logic
|
||||||
#["&&"] Lan = Type::AmpAmp,
|
#["&&"] Lan = TokenKind::AmpAmp,
|
||||||
#["||"] Lor = Type::BarBar,
|
#["||"] Lor = TokenKind::BarBar,
|
||||||
#["^^"] Lxr = Type::XorXor,
|
#["^^"] Lxr = TokenKind::XorXor,
|
||||||
// Range
|
// Range
|
||||||
#["..="] Inc = Type::DotDotEq,
|
#["..="] Inc = TokenKind::DotDotEq,
|
||||||
#[".."] Exc = Type::DotDot,
|
#[".."] Exc = TokenKind::DotDot,
|
||||||
// Compare
|
// Compare
|
||||||
#["<"] Lt = Type::Lt,
|
#["<"] Lt = TokenKind::Lt,
|
||||||
#["<="] Lte = Type::LtEq,
|
#["<="] Lte = TokenKind::LtEq,
|
||||||
#["=="] Eq = Type::EqEq,
|
#["=="] Eq = TokenKind::EqEq,
|
||||||
#["!="] Neq = Type::BangEq,
|
#["!="] Neq = TokenKind::BangEq,
|
||||||
#[">="] Gte = Type::GtEq,
|
#[">="] Gte = TokenKind::GtEq,
|
||||||
#[">"] Gt = Type::Gt,
|
#[">"] Gt = TokenKind::Gt,
|
||||||
// Unary-only
|
// Unary-only
|
||||||
#["!"] Not = Type::Bang,
|
#["!"] Not = TokenKind::Bang,
|
||||||
// Postfix unary
|
// Postfix unary
|
||||||
#["?"] Huh = Type::Question,
|
#["?"] Huh = TokenKind::Question,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user