Compatible with seq. Match any of the tokens specified in this alist, and return the corresponding vl-op-p for it.
(vl-parse-op arity alist &key (tokstream 'tokstream) (config 'config)) → (mv errmsg? value new-tokstream)
This helps to avoid many case splits throughout our operator parsing functions.
Function:
(defun vl-parse-op-fn (arity alist tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (declare (xargs :guard (vl-parse-op-alist-p arity alist))) (let ((__function__ 'vl-parse-op)) (declare (ignorable __function__)) (seq tokstream (when (or (atom (vl-tokstream->tokens)) (atom alist)) (return nil)) (when (vl-is-token? (caar alist)) (:= (vl-match)) (return (cdar alist))) (return-raw (vl-parse-op arity (cdr alist))))))
Theorem:
(defthm vl-parse-op-never-fails (not (mv-nth 0 (vl-parse-op arity alist))))
Theorem:
(defthm vl-parse-op-result (implies (and (not (mv-nth 0 (vl-parse-op arity alist))) (and (force (vl-parse-op-alist-p arity alist)))) (and (implies (equal arity 2) (iff (vl-binaryop-p (mv-nth 1 (vl-parse-op arity alist))) (mv-nth 1 (vl-parse-op arity alist)))) (implies (equal arity 1) (iff (vl-unaryop-p (mv-nth 1 (vl-parse-op arity alist))) (mv-nth 1 (vl-parse-op arity alist)))))))
Theorem:
(defthm vl-parse-op-count-strong-on-value (and (<= (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-op arity alist))) (vl-tokstream-measure)) (implies (mv-nth 1 (vl-parse-op arity alist)) (< (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-op arity alist))) (vl-tokstream-measure)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm vl-parse-op-when-atom (implies (atom (vl-tokstream->tokens)) (not (mv-nth 1 (vl-parse-op arity alist)))))
Theorem:
(defthm vl-parse-op-eof-helper (b* (((mv ?err ?val new-tokstream) (vl-parse-op arity alist :tokstream tokstream))) (implies (consp (vl-tokstream->tokens :tokstream new-tokstream)) (consp (vl-tokstream->tokens)))) :rule-classes ((:forward-chaining :trigger-terms ((vl-parse-op arity alist)))))