• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Vwsim
      • Fgl
      • Vl
        • Syntax
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
          • Ps
          • Verilog-printing
          • Basic-printing
            • Vl-println?
              • Vl-printable-p
              • Vl-print
              • Vl-col-after-printing-chars
              • Vl-print-strings-with-commas
              • Vl-col-after-printing-string
              • Vl-string-needs-html-encoding-p
              • Vl-println-markup
              • Vl-print-strings-as-lines
              • Vl-print-url
              • Vl-print-nat
              • Vl-indent
              • Vl-println
              • Vl-print-markup
              • Vl-ps-seq
              • Vl-cw-ps-seq
              • Vl-when-html
              • Vl-ps-span
            • Printing-locally
            • Formatted-printing
            • Accessing-printed-output
            • Json-printing
            • Vl-printedlist
          • Kit
          • Mlib
          • Transforms
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Testing-utilities
      • Math
    • Basic-printing

    Vl-println?

    (vl-println? x &key (ps 'ps)) prints text with automatic encoding, and may also inserts a newline if we have gone past the autowrap-col.

    Signature
    (vl-println? x &key (ps 'ps)) → ps
    Arguments
    x — Guard (vl-printable-p x).

    This function is like vl-print, except that after x is printed, we check to see whether the current col exceeds the autowrap-col for ps. If so, we insert a newline (and, in HTML mode, a <br/> tag) as in vl-println, and indent the next line to the column specified by the ps's autowrap-ind.

    When writing pretty-printers, it is useful to call this function in places that would be acceptable line-break points, so that very long lines will be split up at reasonably good places.

    Definitions and Theorems

    Function: vl-println?-fn

    (defun
     vl-println?-fn (x ps)
     (declare (xargs :stobjs (ps)))
     (declare (xargs :guard (vl-printable-p x)))
     (let
      ((__function__ 'vl-println?))
      (declare (ignorable __function__))
      (let*
       ((rchars (vl-ps->rchars))
        (col (vl-ps->col))
        (htmlp (vl-ps->htmlp))
        (autowrap-col (vl-ps->autowrap-col))
        (x (vl-printable-fix x))
        (x (cond ((stringp x) x)
                 ((and (atom x) x) (explode-atom x 10))
                 (t x))))
       (if
          htmlp
          (b* ((tabsize (vl-ps->tabsize))
               ((mv col rchars)
                (if (stringp x)
                    (str::html-encode-string-aux x 0 (length x)
                                                 col tabsize rchars)
                    (str::html-encode-chars-aux x col tabsize rchars)))
               ((when (< col autowrap-col))
                (vl-ps-seq (vl-ps-update-rchars rchars)
                           (vl-ps-update-col col)))
               (indent (vl-ps->autowrap-ind))
               (rchars (revappend (str::html-newline) rchars))
               (rchars (str::repeated-revappend indent (str::html-space)
                                                rchars)))
              (vl-ps-seq (vl-ps-update-rchars rchars)
                         (vl-ps-update-col indent)))
          (b* ((col (if (stringp x)
                        (vl-col-after-printing-string col x)
                        (vl-col-after-printing-chars col x)))
               (rchars (if (stringp x)
                           (cons x rchars)
                           (revappend x rchars)))
               ((when (< col autowrap-col))
                (vl-ps-seq (vl-ps-update-rchars rchars)
                           (vl-ps-update-col col)))
               (indent (vl-ps->autowrap-ind))
               (rchars (cons #\Newline rchars))
               (rchars (make-list-ac indent #\Space rchars)))
              (vl-ps-seq (vl-ps-update-rchars rchars)
                         (vl-ps-update-col indent)))))))

    Theorem: vl-println?-fn-of-vl-printable-fix-x

    (defthm vl-println?-fn-of-vl-printable-fix-x
            (equal (vl-println?-fn (vl-printable-fix x) ps)
                   (vl-println?-fn x ps)))

    Theorem: vl-println?-fn-vl-printable-equiv-congruence-on-x

    (defthm vl-println?-fn-vl-printable-equiv-congruence-on-x
            (implies (vl-printable-equiv x x-equiv)
                     (equal (vl-println?-fn x ps)
                            (vl-println?-fn x-equiv ps)))
            :rule-classes :congruence)