/// Try to interpret a token as a unary operator.
Try to interpret a token as a unary operator.
Try to interpret a token as a unary operator .
fn as_unary_op(tkn: Token) -> Option<ast::UnaryOp> {
    Some(match tkn {
        Keyword(Kw::Inertial) => ast::UnaryOp::Inertial,
        Condition => ast::UnaryOp::Condition,
        Keyword(Kw::Not) => ast::UnaryOp::Not,
        Keyword(Kw::Abs) => ast::UnaryOp::Abs,
        Add => ast::UnaryOp::Sign(ast::Sign::Pos),
        Sub => ast::UnaryOp::Sign(ast::Sign::Neg),
        Keyword(Kw::And) => ast::UnaryOp::Logical(ast::LogicalOp::And),
        Keyword(Kw::Or) => ast::UnaryOp::Logical(ast::LogicalOp::Or),
        Keyword(Kw::Nand) => ast::UnaryOp::Logical(ast::LogicalOp::Nand),
        Keyword(Kw::Nor) => ast::UnaryOp::Logical(ast::LogicalOp::Nor),
        Keyword(Kw::Xor) => ast::UnaryOp::Logical(ast::LogicalOp::Xor),
        Keyword(Kw::Xnor) => ast::UnaryOp::Logical(ast::LogicalOp::Xnor),
        _ => return None,
    })
}
fn as_unary_op ( tkn : Token ) -> Option < ast :: UnaryOp > { Some ( match tkn { Keyword ( Kw :: Inertial ) => ast :: UnaryOp :: Inertial , Condition => ast :: UnaryOp :: Condition , Keyword ( Kw :: Not ) => ast :: UnaryOp :: Not , Keyword ( Kw :: Abs ) => ast :: UnaryOp :: Abs , Add => ast :: UnaryOp :: Sign ( ast :: Sign :: Pos ) , Sub => ast :: UnaryOp :: Sign ( ast :: Sign :: Neg ) , Keyword ( Kw :: And ) => ast :: UnaryOp :: Logical ( ast :: LogicalOp :: And ) , Keyword ( Kw :: Or ) => ast :: UnaryOp :: Logical ( ast :: LogicalOp :: Or ) , Keyword ( Kw :: Nand ) => ast :: UnaryOp :: Logical ( ast :: LogicalOp :: Nand ) , Keyword ( Kw :: Nor ) => ast :: UnaryOp :: Logical ( ast :: LogicalOp :: Nor ) , Keyword ( Kw :: Xor ) => ast :: UnaryOp :: Logical ( ast :: LogicalOp :: Xor ) , Keyword ( Kw :: Xnor ) => ast :: UnaryOp :: Logical ( ast :: LogicalOp :: Xnor ) , _ => return None , } ) }
Try to interpret a token as a unary operator.
Try to interpret a token as a unary operator .
tkn
Token