• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
          • Preprocessor
            • Vl-iframe
            • Preprocessor-ifdef-minutia
            • Vl-preprocess
            • Vl-preprocess-loop
            • Vl-includeskips
            • Vl-read-until-end-of-define
            • Vl-define-formallist->defaults
            • Vl-define
            • Vl-expand-define
            • Vl-read-include
            • Vl-substitute-into-macro-text
            • Vl-process-ifdef
            • Ppst
            • Vl-read-define-default-text
            • Vl-process-define
            • Preprocessor-include-minutia
            • Vl-trim-for-preproc
            • Vl-line-up-define-formals-and-actuals
            • Vl-process-undef
            • Vl-split-define-text
              • Vl-parse-define-formal-arguments
              • Vl-def-context
              • Vl-process-endif
              • Scan-backward-for-non-whitespace
              • Vl-ifdef-context
              • Scan-backward-for-whitespace
              • Vl-atvl-atts-text
              • Scan-for-non-whitespace
              • Vl-check-remaining-formals-all-have-defaults
              • Vl-process-else
              • Vl-is-compiler-directive-p
              • Vl-includeskips-controller-lookup
              • Vl-ifdef-use-map
              • Vl-defines
              • Vl-def-use-map
              • Vl-nice-bytes
              • Vl-safe-previous-n
              • Vl-safe-next-n
              • Vl-ppst-pad
              • Vl-filename-to-string-literal
              • Vl-maybe-update-filemap
              • *vl-preprocess-clock*
              • Vl-ppst->warnings
              • Vl-ppst->iskips
              • Vl-ppst->ifdefmap
              • Vl-ppst->idcache
              • Vl-istack
              • Vl-ppst->istack
              • Vl-ppst->includes
              • Vl-ppst->filemap
              • Vl-ppst->defmap
              • Vl-ppst->defines
              • Vl-ppst->config
              • Vl-ppst->bytes
              • Vl-ppst->activep
              • Vl-ppst->acc
              • Vl-ppst-record-ifdef-use
              • Vl-ppst-record-def-use
              • Vl-ifdef-context-list
              • Vl-def-context-list
              • Vl-ppst-update-warnings
              • Vl-ppst-update-istack
              • Vl-ppst-update-iskips
              • Vl-ppst-update-includes
              • Vl-ppst-update-ifdefmap
              • Vl-ppst-update-idcache
              • Vl-ppst-update-filemap
              • Vl-ppst-update-defmap
              • Vl-ppst-update-defines
              • Vl-ppst-update-config
              • Vl-ppst-update-activep
              • Vl-ppst-update-bytes
              • Vl-ppst-update-acc
              • Vl-ppst-unsound-nreverse-acc
            • Vl-loadconfig
            • Vl-loadstate
            • Lexer
            • Parser
            • 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
    • Vl-split-define-text

    Vl-parse-define-formal-arguments

    Signature
    (vl-parse-define-formal-arguments text starting-loc ppst) 
      → 
    (mv successp formals body ppst)
    Arguments
    text — Text after the opening paren, or after some comma.
        Guard (vl-echarlist-p text).
    starting-loc — Context for error messages.
        Guard (vl-location-p starting-loc).
    Returns
    successp — Type (booleanp successp).
    formals — Type (vl-define-formallist-p formals).
    body — Remaining characters after the closing paren.
        Type (vl-echarlist-p body).

    Definitions and Theorems

    Function: vl-parse-define-formal-arguments

    (defun vl-parse-define-formal-arguments (text starting-loc ppst)
     (declare (xargs :stobjs (ppst)))
     (declare (xargs :guard (and (vl-echarlist-p text)
                                 (vl-location-p starting-loc))))
     (let ((__function__ 'vl-parse-define-formal-arguments))
      (declare (ignorable __function__))
      (b*
       ((text (vl-echarlist-fix text))
        ((when (atom text))
         (let
          ((ppst
            (vl-ppst-fatal :msg "~a0: `define arguments are not closed."
                           :args (list starting-loc))))
          (mv nil nil nil ppst)))
        ((mv ?ws rest)
         (vl-read-while-whitespace text))
        ((mv id rest)
         (vl-read-simple-identifier rest))
        ((unless id)
         (let
          ((ppst
               (vl-ppst-fatal :msg "~a0: invalid `define argument name."
                              :args (list (vl-echar->loc (car text))))))
          (mv nil nil nil ppst)))
        (name1 (vl-echarlist->string id))
        ((mv ?ws rest)
         (vl-read-while-whitespace rest))
        ((mv okp default rest ppst)
         (b* (((unless (and (consp rest)
                            (eql (vl-echar->char (car rest)) #\=)))
               (mv t nil rest ppst))
              (rest (cdr rest))
              ((mv okp prefix rest ppst)
               (vl-read-define-default-text rest starting-loc ppst)))
           (mv okp (vl-echarlist->string prefix)
               rest ppst)))
        ((unless okp) (mv nil nil nil ppst))
        ((mv ?ws rest)
         (vl-read-while-whitespace rest))
        (formal1 (make-vl-define-formal :name name1
                                        :default default))
        ((when (and (consp rest)
                    (eql (vl-echar->char (car rest)) #\))))
         (mv t (list formal1) (cdr rest) ppst))
        ((unless (and (consp rest)
                      (eql (vl-echar->char (car rest)) #\,)))
         (let
          ((ppst
            (vl-ppst-fatal
              :msg
              "~a0: expected next `define argument or end of arguments."
              :args (list (if (consp rest)
                              (vl-echar->loc (car rest))
                            (vl-echar->loc (car text)))))))
          (mv nil nil nil ppst)))
        (starting-loc (vl-echar->loc (car rest)))
        (rest (cdr rest))
        ((mv rest-okp rest-formals body ppst)
         (vl-parse-define-formal-arguments rest starting-loc ppst))
        ((unless rest-okp)
         (mv nil nil nil ppst))
        (formals (cons formal1 rest-formals)))
       (mv t formals body ppst))))

    Theorem: booleanp-of-vl-parse-define-formal-arguments.successp

    (defthm booleanp-of-vl-parse-define-formal-arguments.successp
      (b* (((mv ?successp ?formals ?body ?ppst)
            (vl-parse-define-formal-arguments text starting-loc ppst)))
        (booleanp successp))
      :rule-classes :type-prescription)

    Theorem: vl-define-formallist-p-of-vl-parse-define-formal-arguments.formals

    (defthm
     vl-define-formallist-p-of-vl-parse-define-formal-arguments.formals
     (b* (((mv ?successp ?formals ?body ?ppst)
           (vl-parse-define-formal-arguments text starting-loc ppst)))
       (vl-define-formallist-p formals))
     :rule-classes :rewrite)

    Theorem: vl-echarlist-p-of-vl-parse-define-formal-arguments.body

    (defthm vl-echarlist-p-of-vl-parse-define-formal-arguments.body
      (b* (((mv ?successp ?formals ?body ?ppst)
            (vl-parse-define-formal-arguments text starting-loc ppst)))
        (vl-echarlist-p body))
      :rule-classes :rewrite)