fn as_binary_op(tkn: Token) -> Option<ast::BinaryOp> {
    Some(match tkn {
        Keyword(Kw::To) => ast::BinaryOp::Dir(ast::Dir::To),
        Keyword(Kw::Downto) => ast::BinaryOp::Dir(ast::Dir::Downto),

        Keyword(Kw::And) => ast::BinaryOp::Logical(ast::LogicalOp::And),
        Keyword(Kw::Or) => ast::BinaryOp::Logical(ast::LogicalOp::Or),
        Keyword(Kw::Nand) => ast::BinaryOp::Logical(ast::LogicalOp::Nand),
        Keyword(Kw::Nor) => ast::BinaryOp::Logical(ast::LogicalOp::Nor),
        Keyword(Kw::Xor) => ast::BinaryOp::Logical(ast::LogicalOp::Xor),
        Keyword(Kw::Xnor) => ast::BinaryOp::Logical(ast::LogicalOp::Xnor),

        Eq => ast::BinaryOp::Rel(ast::RelationalOp::Eq),
        Neq => ast::BinaryOp::Rel(ast::RelationalOp::Neq),
        Lt => ast::BinaryOp::Rel(ast::RelationalOp::Lt),
        Leq => ast::BinaryOp::Rel(ast::RelationalOp::Leq),
        Gt => ast::BinaryOp::Rel(ast::RelationalOp::Gt),
        Geq => ast::BinaryOp::Rel(ast::RelationalOp::Geq),

        MatchEq => ast::BinaryOp::Match(ast::RelationalOp::Eq),
        MatchNeq => ast::BinaryOp::Match(ast::RelationalOp::Neq),
        MatchLt => ast::BinaryOp::Match(ast::RelationalOp::Lt),
        MatchLeq => ast::BinaryOp::Match(ast::RelationalOp::Leq),
        MatchGt => ast::BinaryOp::Match(ast::RelationalOp::Gt),
        MatchGeq => ast::BinaryOp::Match(ast::RelationalOp::Geq),

        Keyword(Kw::Sll) => ast::BinaryOp::Shift(ast::ShiftOp::Sll),
        Keyword(Kw::Srl) => ast::BinaryOp::Shift(ast::ShiftOp::Srl),
        Keyword(Kw::Sla) => ast::BinaryOp::Shift(ast::ShiftOp::Sla),
        Keyword(Kw::Sra) => ast::BinaryOp::Shift(ast::ShiftOp::Sra),
        Keyword(Kw::Rol) => ast::BinaryOp::Shift(ast::ShiftOp::Rol),
        Keyword(Kw::Ror) => ast::BinaryOp::Shift(ast::ShiftOp::Ror),

        Add => ast::BinaryOp::Add,
        Sub => ast::BinaryOp::Sub,
        Ampersand => ast::BinaryOp::Concat,

        Mul => ast::BinaryOp::Mul,
        Div => ast::BinaryOp::Div,
        Keyword(Kw::Mod) => ast::BinaryOp::Mod,
        Keyword(Kw::Rem) => ast::BinaryOp::Rem,
        Pow => ast::BinaryOp::Pow,
        _ => return None,
    })
}
/// Try to interpret a token as a binary operator.
Try to interpret a token as a binary operator.
Try to interpret a token as a binary operator .
fn as_binary_op(tkn: Token) -> Option<ast::BinaryOp> {
    Some(match tkn {
        Keyword(Kw::To) => ast::BinaryOp::Dir(ast::Dir::To),
        Keyword(Kw::Downto) => ast::BinaryOp::Dir(ast::Dir::Downto),
        Keyword(Kw::And) => ast::BinaryOp::Logical(ast::LogicalOp::And),
        Keyword(Kw::Or) => ast::BinaryOp::Logical(ast::LogicalOp::Or),
        Keyword(Kw::Nand) => ast::BinaryOp::Logical(ast::LogicalOp::Nand),
        Keyword(Kw::Nor) => ast::BinaryOp::Logical(ast::LogicalOp::Nor),
        Keyword(Kw::Xor) => ast::BinaryOp::Logical(ast::LogicalOp::Xor),
        Keyword(Kw::Xnor) => ast::BinaryOp::Logical(ast::LogicalOp::Xnor),
        Eq => ast::BinaryOp::Rel(ast::RelationalOp::Eq),
        Neq => ast::BinaryOp::Rel(ast::RelationalOp::Neq),
        Lt => ast::BinaryOp::Rel(ast::RelationalOp::Lt),
        Leq => ast::BinaryOp::Rel(ast::RelationalOp::Leq),
        Gt => ast::BinaryOp::Rel(ast::RelationalOp::Gt),
        Geq => ast::BinaryOp::Rel(ast::RelationalOp::Geq),
        MatchEq => ast::BinaryOp::Match(ast::RelationalOp::Eq),
        MatchNeq => ast::BinaryOp::Match(ast::RelationalOp::Neq),
        MatchLt => ast::BinaryOp::Match(ast::RelationalOp::Lt),
        MatchLeq => ast::BinaryOp::Match(ast::RelationalOp::Leq),
        MatchGt => ast::BinaryOp::Match(ast::RelationalOp::Gt),
        MatchGeq => ast::BinaryOp::Match(ast::RelationalOp::Geq),
        Keyword(Kw::Sll) => ast::BinaryOp::Shift(ast::ShiftOp::Sll),
        Keyword(Kw::Srl) => ast::BinaryOp::Shift(ast::ShiftOp::Srl),
        Keyword(Kw::Sla) => ast::BinaryOp::Shift(ast::ShiftOp::Sla),
        Keyword(Kw::Sra) => ast::BinaryOp::Shift(ast::ShiftOp::Sra),
        Keyword(Kw::Rol) => ast::BinaryOp::Shift(ast::ShiftOp::Rol),
        Keyword(Kw::Ror) => ast::BinaryOp::Shift(ast::ShiftOp::Ror),
        Add => ast::BinaryOp::Add,
        Sub => ast::BinaryOp::Sub,
        Ampersand => ast::BinaryOp::Concat,
        Mul => ast::BinaryOp::Mul,
        Div => ast::BinaryOp::Div,
        Keyword(Kw::Mod) => ast::BinaryOp::Mod,
        Keyword(Kw::Rem) => ast::BinaryOp::Rem,
        Pow => ast::BinaryOp::Pow,
        _ => return None,
    })
}
fn as_binary_op ( tkn : Token ) -> Option < ast :: BinaryOp > { Some ( match tkn { Keyword ( Kw :: To ) => ast :: BinaryOp :: Dir ( ast :: Dir :: To ) , Keyword ( Kw :: Downto ) => ast :: BinaryOp :: Dir ( ast :: Dir :: Downto ) , Keyword ( Kw :: And ) => ast :: BinaryOp :: Logical ( ast :: LogicalOp :: And ) , Keyword ( Kw :: Or ) => ast :: BinaryOp :: Logical ( ast :: LogicalOp :: Or ) , Keyword ( Kw :: Nand ) => ast :: BinaryOp :: Logical ( ast :: LogicalOp :: Nand ) , Keyword ( Kw :: Nor ) => ast :: BinaryOp :: Logical ( ast :: LogicalOp :: Nor ) , Keyword ( Kw :: Xor ) => ast :: BinaryOp :: Logical ( ast :: LogicalOp :: Xor ) , Keyword ( Kw :: Xnor ) => ast :: BinaryOp :: Logical ( ast :: LogicalOp :: Xnor ) , Eq => ast :: BinaryOp :: Rel ( ast :: RelationalOp :: Eq ) , Neq => ast :: BinaryOp :: Rel ( ast :: RelationalOp :: Neq ) , Lt => ast :: BinaryOp :: Rel ( ast :: RelationalOp :: Lt ) , Leq => ast :: BinaryOp :: Rel ( ast :: RelationalOp :: Leq ) , Gt => ast :: BinaryOp :: Rel ( ast :: RelationalOp :: Gt ) , Geq => ast :: BinaryOp :: Rel ( ast :: RelationalOp :: Geq ) , MatchEq => ast :: BinaryOp :: Match ( ast :: RelationalOp :: Eq ) , MatchNeq => ast :: BinaryOp :: Match ( ast :: RelationalOp :: Neq ) , MatchLt => ast :: BinaryOp :: Match ( ast :: RelationalOp :: Lt ) , MatchLeq => ast :: BinaryOp :: Match ( ast :: RelationalOp :: Leq ) , MatchGt => ast :: BinaryOp :: Match ( ast :: RelationalOp :: Gt ) , MatchGeq => ast :: BinaryOp :: Match ( ast :: RelationalOp :: Geq ) , Keyword ( Kw :: Sll ) => ast :: BinaryOp :: Shift ( ast :: ShiftOp :: Sll ) , Keyword ( Kw :: Srl ) => ast :: BinaryOp :: Shift ( ast :: ShiftOp :: Srl ) , Keyword ( Kw :: Sla ) => ast :: BinaryOp :: Shift ( ast :: ShiftOp :: Sla ) , Keyword ( Kw :: Sra ) => ast :: BinaryOp :: Shift ( ast :: ShiftOp :: Sra ) , Keyword ( Kw :: Rol ) => ast :: BinaryOp :: Shift ( ast :: ShiftOp :: Rol ) , Keyword ( Kw :: Ror ) => ast :: BinaryOp :: Shift ( ast :: ShiftOp :: Ror ) , Add => ast :: BinaryOp :: Add , Sub => ast :: BinaryOp :: Sub , Ampersand => ast :: BinaryOp :: Concat , Mul => ast :: BinaryOp :: Mul , Div => ast :: BinaryOp :: Div , Keyword ( Kw :: Mod ) => ast :: BinaryOp :: Mod , Keyword ( Kw :: Rem ) => ast :: BinaryOp :: Rem , Pow => ast :: BinaryOp :: Pow , _ => return None , } ) }
Try to interpret a token as a binary operator.
Try to interpret a token as a binary operator .
tkn
Token
tkn
Token