Matches port stuff for UDPs with traditional, separated ports and port declarations lists.
(vl-parse-traditional-udp-head udpname &key (tokstream 'tokstream) (config 'config)) → (mv errmsg? value new-tokstream)
This is for UDPs like:
primitive foo(o, a, b); output o; reg o; input a; input b; ... endprimitive
The formal syntax we're working with here is:
udp_declaration ::= {attribute_instance} 'primitive' udp_identifier '(' udp_port_list ')' ';' udp_port_declaration { udp_port_declaration } udp_body 'endprimitive'
We assume we've already read the attributes, primitive keyword, udp identifier, and leading open paren. So what remains is to match:
udp_port_list ')' ';' udp_port_declaration { udp_port_declaration }
If the port list and port declaration lists are sensible, we'll return a vl-udp-head-p that captures the semantic content of these ports and their declarations.
Function:
(defun vl-parse-traditional-udp-head-fn (udpname tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (declare (xargs :guard (vl-idtoken-p udpname))) (let ((__function__ 'vl-parse-traditional-udp-head)) (declare (ignorable __function__)) (seq tokstream (ports := (vl-parse-1+-identifiers-separated-by-commas)) (:= (vl-match-token :vl-rparen)) (:= (vl-match-token :vl-semi)) (decls := (vl-parse-1+-udp-port-declarations)) (return-raw (b* (((mv warning head) (vl-make-traditional-udp-head udpname ports decls))) (mv warning head tokstream))))))
Theorem:
(defthm vl-parse-traditional-udp-head-fails-gracefully (implies (mv-nth 0 (vl-parse-traditional-udp-head udpname)) (not (mv-nth 1 (vl-parse-traditional-udp-head udpname)))))
Theorem:
(defthm vl-warning-p-of-vl-parse-traditional-udp-head (iff (vl-warning-p (mv-nth 0 (vl-parse-traditional-udp-head udpname))) (mv-nth 0 (vl-parse-traditional-udp-head udpname))))
Theorem:
(defthm vl-parse-traditional-udp-head-result (implies (and (force (vl-idtoken-p udpname))) (equal (vl-udp-head-p (mv-nth 1 (vl-parse-traditional-udp-head udpname))) (not (mv-nth 0 (vl-parse-traditional-udp-head udpname))))))
Theorem:
(defthm vl-parse-traditional-udp-head-count-strong (and (<= (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-traditional-udp-head udpname))) (vl-tokstream-measure)) (implies (not (mv-nth 0 (vl-parse-traditional-udp-head udpname))) (< (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-traditional-udp-head udpname))) (vl-tokstream-measure)))) :rule-classes ((:rewrite) (:linear)))