Parser for SystemVerilog-2012 data types.
Function:
(defun vl-parse-datatype-or-void-fn (tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (let ((__function__ 'vl-parse-datatype-or-void)) (declare (ignorable __function__)) (seq tokstream (when (vl-is-token? :vl-kwd-void) (:= (vl-match-any)) (return (make-vl-coretype :name :vl-void))) (type :s= (vl-parse-datatype)) (return type))))
Function:
(defun vl-parse-datatype-fn (tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (let ((__function__ 'vl-parse-datatype)) (declare (ignorable __function__)) (seq tokstream (when (vl-is-token? :vl-kwd-type) (return-raw (vl-parse-error "type references are not yet implemented."))) (when (vl-is-token? :vl-kwd-virtual) (return-raw (vl-parse-error "virtual interfaces are not yet implemented."))) (when (vl-is-some-token? *vl-core-data-type-keywords*) (ret := (vl-parse-core-data-type)) (return ret)) (when (vl-is-some-token? '(:vl-kwd-struct :vl-kwd-union)) (kind := (vl-match)) (when (and (vl-is-token? :vl-kwd-tagged) (eq (vl-token->type kind) :vl-kwd-union)) (tagged := (vl-match))) (when (vl-is-token? :vl-kwd-packed) (packed := (vl-match)) (when (vl-is-some-token? '(:vl-kwd-signed :vl-kwd-unsigned)) (signed := (vl-match)))) (:= (vl-match-token :vl-lcurly)) (members := (vl-parse-structmembers)) (:= (vl-match-token :vl-rcurly)) (dims := (vl-parse-0+-packed-dimensions)) (return (b* ((packedp (acl2::bool-fix packed)) (signedp (and signed (eq (vl-token->type signed) :vl-kwd-signed))) ((when (eq (vl-token->type kind) :vl-kwd-struct)) (make-vl-struct :packedp packedp :signedp signedp :members members :pdims dims))) (make-vl-union :packedp packedp :signedp signedp :taggedp (acl2::bool-fix tagged) :members members :pdims dims)))) (when (vl-is-token? :vl-kwd-enum) (:= (vl-match)) (unless (vl-is-token? :vl-lcurly) (basetype := (vl-parse-enum-base-type))) (:= (vl-match-token :vl-lcurly)) (items := (vl-parse-1+-enum-name-declarations-separated-by-commas)) (:= (vl-match-token :vl-rcurly)) (dims := (vl-parse-0+-packed-dimensions)) (return (make-vl-enum :basetype (or basetype (make-vl-enumbasetype :kind :vl-int :signedp t :dim nil)) :items items :pdims dims))) (expr := (vl-parse-simple-type)) (dims := (vl-parse-0+-packed-dimensions)) (return (make-vl-usertype :kind expr :pdims dims)))))
Function:
(defun vl-parse-structmembers-fn (tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (let ((__function__ 'vl-parse-structmembers)) (declare (ignorable __function__)) (seq tokstream (first :s= (vl-parse-structmember)) (when (vl-is-token? :vl-rcurly) (return first)) (rest := (vl-parse-structmembers)) (return (append first rest)))))
Function:
(defun vl-parse-structmember-fn (tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (let ((__function__ 'vl-parse-structmember)) (declare (ignorable __function__)) (seq tokstream (atts := (vl-parse-0+-attribute-instances)) (when (vl-is-some-token? '(:vl-kwd-rand :vl-kwd-randc)) (rand := (vl-match))) (type :s= (vl-parse-datatype-or-void)) (decls := (vl-parse-1+-variable-decl-assignments-separated-by-commas)) (:= (vl-match-token :vl-semi)) (return (let ((rand (and rand (case (vl-token->type rand) (:vl-kwd-rand :vl-rand) (:vl-kwd-randc :vl-randc))))) (vl-make-structmembers atts rand type decls))))))