Match a forward
(vl-parse-fwd-typedef atts &key (tokstream 'tokstream) (config 'config)) → (mv errmsg? value new-tokstream)
The SystemVerilog-2012 grammar groups ``forward'' type declarations in with other type declarations. Here we're just parsing:
type_declaration ::= 'typedef' [ 'enum' | 'struct' | 'union' | 'class' | 'interface class' ] type_identifier ';'
We don't match the other forms of
Function:
(defun vl-parse-fwd-typedef-fn (atts tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (declare (xargs :guard (and (vl-atts-p atts) (vl-is-token? :vl-kwd-typedef)))) (let ((__function__ 'vl-parse-fwd-typedef)) (declare (ignorable __function__)) (seq tokstream (typedef := (vl-match)) (when (vl-is-token? :vl-kwd-interface) (:= (vl-match)) (:= (vl-match-token :vl-kwd-class)) (name := (vl-match-token :vl-idtoken)) (:= (vl-match-token :vl-semi)) (return-raw (b* ((val (make-vl-fwdtypedef :kind :vl-interfaceclass :name (vl-idtoken->name name) :loc (vl-token->loc typedef) :atts atts))) (mv nil val tokstream)))) (when (vl-is-some-token? '(:vl-kwd-enum :vl-kwd-struct :vl-kwd-union :vl-kwd-class)) (type := (vl-match)) (name := (vl-match-token :vl-idtoken)) (:= (vl-match-token :vl-semi)) (return-raw (b* ((val (make-vl-fwdtypedef :kind (case (vl-token->type type) (:vl-kwd-enum :vl-enum) (:vl-kwd-struct :vl-struct) (:vl-kwd-union :vl-union) (:vl-kwd-class :vl-class)) :name (vl-idtoken->name name) :loc (vl-token->loc typedef) :atts atts))) (mv nil val tokstream)))) (return-raw (vl-parse-error "Not a valid forward typedef.")))))
Theorem:
(defthm vl-parse-fwd-typedef-fails-gracefully (implies (mv-nth 0 (vl-parse-fwd-typedef atts)) (not (mv-nth 1 (vl-parse-fwd-typedef atts)))))
Theorem:
(defthm vl-warning-p-of-vl-parse-fwd-typedef (iff (vl-warning-p (mv-nth 0 (vl-parse-fwd-typedef atts))) (mv-nth 0 (vl-parse-fwd-typedef atts))))
Theorem:
(defthm vl-parse-fwd-typedef-result (implies (and (and (force (vl-atts-p atts)) (force (vl-is-token? :vl-kwd-typedef)))) (equal (vl-fwdtypedef-p (mv-nth 1 (vl-parse-fwd-typedef atts))) (not (mv-nth 0 (vl-parse-fwd-typedef atts))))))
Theorem:
(defthm vl-parse-fwd-typedef-count-strong (and (<= (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-fwd-typedef atts))) (vl-tokstream-measure)) (implies (not (mv-nth 0 (vl-parse-fwd-typedef atts))) (< (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-fwd-typedef atts))) (vl-tokstream-measure)))) :rule-classes ((:rewrite) (:linear)))