Match an optional
(vl-maybe-parse-lifetime &key (tokstream 'tokstream) (config 'config)) → (mv errmsg? value new-tokstream)
Grammar:
lifetime ::= 'static' | 'automatic'
Function:
(defun vl-maybe-parse-lifetime-fn (tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (let ((__function__ 'vl-maybe-parse-lifetime)) (declare (ignorable __function__)) (seq tokstream (when (vl-is-token? :vl-kwd-static) (:= (vl-match)) (return :vl-static)) (when (vl-is-token? :vl-kwd-automatic) (:= (vl-match)) (return :vl-automatic)) (return nil))))
Theorem:
(defthm vl-maybe-parse-lifetime-fails-gracefully (implies (mv-nth 0 (vl-maybe-parse-lifetime)) (not (mv-nth 1 (vl-maybe-parse-lifetime)))))
Theorem:
(defthm vl-warning-p-of-vl-maybe-parse-lifetime (iff (vl-warning-p (mv-nth 0 (vl-maybe-parse-lifetime))) (mv-nth 0 (vl-maybe-parse-lifetime))))
Theorem:
(defthm vl-maybe-parse-lifetime-result (implies (and t) (vl-lifetime-p (mv-nth 1 (vl-maybe-parse-lifetime)))))
Theorem:
(defthm vl-maybe-parse-lifetime-count-strong-on-value (and (<= (vl-tokstream-measure :tokstream (mv-nth 2 (vl-maybe-parse-lifetime))) (vl-tokstream-measure)) (implies (mv-nth 1 (vl-maybe-parse-lifetime)) (< (vl-tokstream-measure :tokstream (mv-nth 2 (vl-maybe-parse-lifetime))) (vl-tokstream-measure)))) :rule-classes ((:rewrite) (:linear)))