(vl-parse-function-declaration-2012 atts &key (tokstream 'tokstream)
(config 'config))
→
(mv errmsg? value new-tokstream)function_declaration ::= 'function' [ lifetime ] function_body_declaration
function_body_declaration ::=
function_data_type_or_implicit ; Variant 1
[ interface_identifier '.' | class_scope ] identifier ';'
{ tf_item_declaration }
{ function_statement_or_null }
'endfunction' [ ':' identifier ]
| function_data_type_or_implicit
[ interface_identifier '.' | class_scope ] identifier '(' [tf_port_list] ')' ';' ; Variant 2
{ block_item_declaration }
{ function_statement_or_null }
'endfunction' [ ':' identifier ]
As is often the case with data_type_or_implicit forms, we need to backtrack to figure out whether an identifier is a datatype or the function name with an empty implicit datatype. We do this in vl-parse-function-data-type-and-name.
BOZO we don't yet handle the interface identifier / class scope stuff, but instead just expect the function name to be a regular identifier.
Function:
(defun vl-parse-function-declaration-2012-fn (atts tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (declare (xargs :guard (vl-atts-p atts))) (let ((__function__ 'vl-parse-function-declaration-2012)) (declare (ignorable __function__)) (seq tokstream (:= (vl-match-token :vl-kwd-function)) (lifetime := (vl-maybe-parse-lifetime)) ((rettype . name) := (vl-parse-function-data-type-and-name t)) (when (vl-is-token? :vl-semi) (:= (vl-match)) (items := (vl-parse-0+-tf-item-declarations)) (body := (vl-parse-function-statements)) (:= (vl-match-token :vl-kwd-endfunction)) (:= (vl-parse-endblock-name (vl-idtoken->name name) "function/endfunction")) (return (b* (((mv portdecls blockitems) (vl-filter-portdecl-or-blockitem-list items))) (list (vl-make-fundecl-for-parser :name (vl-idtoken->name name) :lifetime lifetime :rettype (vl-datatype-or-implicit->type rettype) :inputs portdecls :decls blockitems :loaditems items :body body :atts atts :loc (vl-token->loc name)))))) (:= (vl-match-token :vl-lparen)) (unless (vl-is-token? :vl-rparen) (portdecls := (vl-parse-tf-port-list))) (:= (vl-match-token :vl-rparen)) (:= (vl-match-token :vl-semi)) (decls := (vl-parse-0+-block-item-declarations)) (body := (vl-parse-function-statements)) (:= (vl-match-token :vl-kwd-endfunction)) (:= (vl-parse-endblock-name (vl-idtoken->name name) "function/endfunction")) (return (list (vl-make-fundecl-for-parser :name (vl-idtoken->name name) :lifetime lifetime :rettype (vl-datatype-or-implicit->type rettype) :inputs portdecls :decls decls :loaditems (append portdecls decls) :body body :atts atts :loc (vl-token->loc name)))))))
Theorem:
(defthm vl-parse-function-declaration-2012-fails-gracefully (implies (mv-nth 0 (vl-parse-function-declaration-2012 atts)) (not (mv-nth 1 (vl-parse-function-declaration-2012 atts)))))
Theorem:
(defthm vl-warning-p-of-vl-parse-function-declaration-2012 (iff (vl-warning-p (mv-nth 0 (vl-parse-function-declaration-2012 atts))) (mv-nth 0 (vl-parse-function-declaration-2012 atts))))
Theorem:
(defthm vl-parse-function-declaration-2012-result (implies (and (force (vl-atts-p atts))) (vl-fundecllist-p (mv-nth 1 (vl-parse-function-declaration-2012 atts)))))
Theorem:
(defthm vl-parse-function-declaration-2012-true-listp (true-listp (mv-nth 1 (vl-parse-function-declaration-2012 atts))) :rule-classes :type-prescription)
Theorem:
(defthm vl-parse-function-declaration-2012-count-strong (and (<= (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-function-declaration-2012 atts))) (vl-tokstream-measure)) (implies (not (mv-nth 0 (vl-parse-function-declaration-2012 atts))) (< (vl-tokstream-measure :tokstream (mv-nth 2 (vl-parse-function-declaration-2012 atts))) (vl-tokstream-measure)))) :rule-classes ((:rewrite) (:linear)))