• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Vl-loadstate
          • Lexer
          • Parser
            • Parse-expressions
            • Parse-udps
            • Parse-statements
            • Parse-property
            • Vl-genelements
            • Parse-paramdecls
            • Parse-blockitems
            • Parse-utils
            • Parse-insts
            • Parse-functions
            • Parse-assignments
            • Parse-clocking
            • Parse-strengths
            • Vl-parse-genvar-declaration
            • Vl-parse
            • Parse-netdecls
            • Parse-asserts
            • Vl-maybe-parse-lifetime
            • Parse-dpi-import-export
            • Parse-ports
            • Parse-timeunits
            • Seq
            • Parse-packages
              • Vl-parse-package-declaration
                • Vl-parse-genelements-or-classes-until
                • Vl-skip-through-endpackage
                • Vl-parse-genelement-or-class
                • Vl-make-package-with-parse-error
              • Parse-eventctrl
            • Vl-load-merge-descriptions
            • Vl-find-basename/extension
            • Vl-load-file
            • Vl-loadresult
            • Scope-of-defines
            • Vl-find-file
            • Vl-flush-out-descriptions
            • Vl-description
            • Vl-read-file
            • Vl-includeskips-report-gather
            • Vl-load-main
            • Extended-characters
            • Vl-load
            • Vl-load-description
            • Vl-descriptions-left-to-load
            • Inject-warnings
            • Vl-preprocess-debug
            • Vl-write-preprocessor-debug-file
            • Vl-read-file-report-gather
            • Vl-load-descriptions
            • Vl-load-files
            • Translate-off
            • Vl-load-read-file-hook
            • Vl-read-file-report
            • Vl-loadstate-pad
            • Vl-load-summary
            • Vl-collect-modules-from-descriptions
            • Vl-loadstate->warnings
            • Vl-iskips-report
            • Vl-descriptionlist
          • Warnings
          • Getting-started
          • Utilities
          • Printer
          • Kit
          • Mlib
          • Transforms
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Parse-packages

    Vl-parse-package-declaration

    Signature
    (vl-parse-package-declaration atts &key (tokstream 'tokstream) 
                                  (config 'config)) 
     
      → 
    (mv errmsg? value new-tokstream)
    Arguments
    config — Guard (vl-loadconfig-p config).

    Definitions and Theorems

    Function: vl-parse-package-declaration-fn

    (defun vl-parse-package-declaration-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-package-declaration))
      (declare (ignorable __function__))
      (seq
       tokstream
       (startkwd := (vl-match-token :vl-kwd-package))
       (lifetime := (vl-maybe-parse-lifetime))
       (name := (vl-match-token :vl-idtoken))
       (return-raw
        (b*
         ((backup (vl-tokstream-save))
          (orig-warnings
               (vl-parsestate->warnings (vl-tokstream->pstate)))
          (tokstream (vl-tokstream-update-pstate
                          (change-vl-parsestate (vl-tokstream->pstate)
                                                :warnings nil)))
          ((mv err pkg tokstream)
           (seq
            tokstream (:= (vl-match-token :vl-semi))
            (items
             :=
             (vl-parse-genelements-or-classes-until :vl-kwd-endpackage))
            (endkwd := (vl-match-token :vl-kwd-endpackage))
            (:= (vl-parse-endblock-name (vl-idtoken->name name)
                                        "package/endpackage"))
            (return
             (b*
              ((warnings
                    (vl-parsestate->warnings (vl-tokstream->pstate)))
               (bad-item (vl-genelementlist-findbad
                              items
                              '(:vl-vardecl :vl-paramdecl :vl-fundecl
                                            :vl-taskdecl :vl-typedef
                                            :vl-import :vl-letdecl
                                            :vl-dpiimport :vl-dpiexport
                                            :vl-class :vl-property)))
               (warnings
                (if (not bad-item)
                    warnings
                 (fatal
                   :type :vl-bad-package-item
                   :msg "~a0: a package may not contain a ~s1."
                   :args
                   (list bad-item
                         (vl-genelement->short-kind-string bad-item)))))
               ((vl-genblob c)
                (vl-sort-genelements items)))
              (make-vl-package :name (vl-idtoken->name name)
                               :minloc (vl-token->loc startkwd)
                               :maxloc (vl-token->loc endkwd)
                               :lifetime lifetime
                               :vardecls c.vardecls
                               :paramdecls c.paramdecls
                               :fundecls c.fundecls
                               :taskdecls c.taskdecls
                               :typedefs c.typedefs
                               :imports c.imports
                               :classes c.classes
                               :dpiimports c.dpiimports
                               :dpiexports c.dpiexports
                               :warnings warnings
                               :atts atts)))))
          ((unless err)
           (let
            ((tokstream
                  (vl-tokstream-update-pstate
                       (change-vl-parsestate (vl-tokstream->pstate)
                                             :warnings orig-warnings))))
            (mv nil pkg tokstream)))
          (errtokens (vl-tokstream->tokens))
          (tokstream (vl-tokstream-restore backup)))
         (seq
          tokstream
          (endkwd
               := (vl-skip-through-endpackage (vl-idtoken->name name)))
          (return
              (vl-make-package-with-parse-error (vl-idtoken->name name)
                                                (vl-token->loc startkwd)
                                                (vl-token->loc endkwd)
                                                err errtokens))))))))

    Theorem: vl-parse-package-declaration-fails-gracefully

    (defthm vl-parse-package-declaration-fails-gracefully
      (implies (mv-nth 0 (vl-parse-package-declaration atts))
               (not (mv-nth 1
                            (vl-parse-package-declaration atts)))))

    Theorem: vl-warning-p-of-vl-parse-package-declaration

    (defthm vl-warning-p-of-vl-parse-package-declaration
      (iff (vl-warning-p (mv-nth 0 (vl-parse-package-declaration atts)))
           (mv-nth 0 (vl-parse-package-declaration atts))))

    Theorem: vl-parse-package-declaration-result

    (defthm vl-parse-package-declaration-result
     (implies
      (and (force (vl-atts-p atts)))
      (equal
           (vl-package-p (mv-nth 1 (vl-parse-package-declaration atts)))
           (not (mv-nth 0
                        (vl-parse-package-declaration atts))))))

    Theorem: vl-parse-package-declaration-count-strong

    (defthm vl-parse-package-declaration-count-strong
     (and
      (<=
         (vl-tokstream-measure
              :tokstream (mv-nth 2 (vl-parse-package-declaration atts)))
         (vl-tokstream-measure))
      (implies
       (not (mv-nth 0 (vl-parse-package-declaration atts)))
       (<
         (vl-tokstream-measure
              :tokstream (mv-nth 2 (vl-parse-package-declaration atts)))
         (vl-tokstream-measure))))
     :rule-classes ((:rewrite) (:linear)))