Map a token that is a unary operator to the corresponding unary operator.
By this we mean a unary operator according to the grammar, not our abstract syntax, which has a broader notion of unary operator.
Function:
(defun token-to-unary-operator (token) (declare (xargs :guard (tokenp token))) (declare (xargs :guard (token-unary-operator-p token))) (let ((__function__ 'token-to-unary-operator)) (declare (ignorable __function__)) (cond ((token-punctuatorp token "&") (unop-address)) ((token-punctuatorp token "*") (unop-indir)) ((token-punctuatorp token "+") (unop-plus)) ((token-punctuatorp token "-") (unop-minus)) ((token-punctuatorp token "~") (unop-bitnot)) ((token-punctuatorp token "!") (unop-lognot)) (t (prog2$ (impossible) (irr-unop))))))
Theorem:
(defthm unopp-of-token-to-unary-operator (b* ((op (token-to-unary-operator token))) (unopp op)) :rule-classes :rewrite)