SystemVerilog-2012 only. Top-level function for parsing port lists in both ANSI and non-ANSI styles.
(vl-parse-module-port-list-top-2012 &key (tokstream 'tokstream) (config 'config)) → (mv errmsg? value new-tokstream)
We match the following, contrived grammar rule:
vl_module_port_list ::= list_of_ports | [list_of_port_declarations]
Function:
(defun vl-parse-module-port-list-top-2012-fn (tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (let ((__function__ 'vl-parse-module-port-list-top-2012)) (declare (ignorable __function__)) (seq tokstream (unless (vl-is-token? :vl-lparen) (return (make-vl-nonansi-ports :ports nil))) (:= (vl-match)) (when (vl-is-token? :vl-rparen) (:= (vl-match)) (return (make-vl-nonansi-ports :ports nil))) (return-raw (b* ((backup (vl-tokstream-save)) ((mv err port1 tokstream) (seq tokstream (atts := (vl-parse-0+-attribute-instances)) (port1 := (vl-parse-ansi-port-declaration atts)) (return port1))) (ansi-p (and (not err) (vl-port-starts-ansi-port-list-p port1))) (tokstream (vl-tokstream-restore backup)) ((when ansi-p) (seq tokstream (decls := (vl-parse-1+-ansi-port-declarations)) (:= (vl-match-token :vl-rparen)) (return (make-vl-ansi-ports :decls decls))))) (seq tokstream (ports := (vl-parse-1+-ports-separated-by-commas)) (:= (vl-match-token :vl-rparen)) (return (make-vl-nonansi-ports :ports ports))))))))
Theorem:
(defthm vl-parse-module-port-list-top-2012-fails-gracefully (implies (mv-nth 0 (vl-parse-module-port-list-top-2012)) (not (mv-nth 1 (vl-parse-module-port-list-top-2012)))))
Theorem:
(defthm vl-warning-p-of-vl-parse-module-port-list-top-2012 (iff (vl-warning-p (mv-nth 0 (vl-parse-module-port-list-top-2012))) (mv-nth 0 (vl-parse-module-port-list-top-2012))))
Theorem:
(defthm vl-parse-module-port-list-top-2012-result (implies (and t) (equal (vl-parsed-ports-p (mv-nth 1 (vl-parse-module-port-list-top-2012))) (not (mv-nth 0 (vl-parse-module-port-list-top-2012))))))
Theorem:
(defthm vl-parse-module-port-list-top-2012-count-weak (<= (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-module-port-list-top-2012))) (vl-tokstream-measure)) :rule-classes ((:rewrite) (:linear)))