• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
        • Getting-started
        • Utilities
        • Loader
        • Transforms
        • Lint
        • Mlib
        • Server
        • Kit
        • Printer
          • Ps
          • Basic-printing
          • Verilog-printing
          • Printing-locally
          • Formatted-printing
          • Accessing-printed-output
          • Vl-printedlist
            • Vl-printedlist-fix
            • Vl-printedlist-p
              • Vl-printedlist-p-basics
              • Vl-printedlist-peek
                • Vl-printedlist-length
              • Vl-printedlist-equiv
              • Vl-printedlist->string
              • Vl-printed-p
            • Json-printing
          • Esim-vl
          • Well-formedness
        • Sv
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Vl-printedlist-p

    Vl-printedlist-peek

    Extract the last character that was printed.

    Signature
    (vl-printedlist-peek x) → maybe-char
    Arguments
    x — The printed list, which we assume is in reverse order!.
        Guard (vl-printedlist-p x).
    Returns
    maybe-char — Type (or (not maybe-char) (characterp maybe-char)).

    This is generally useful for things like insert a space unless we just printed a newline, etc.

    Definitions and Theorems

    Function: vl-printedlist-peek

    (defun vl-printedlist-peek (x)
      (declare (xargs :guard (vl-printedlist-p x)))
      (let ((__function__ 'vl-printedlist-peek))
        (declare (ignorable __function__))
        (and (consp x)
             (let ((x1 (vl-printed-fix (car x))))
               (if (characterp x1)
                   x1
                 (let ((len (length x1)))
                   (if (zp len)
                       (vl-printedlist-peek (cdr x))
                     (char x1 (1- len)))))))))

    Theorem: return-type-of-vl-printedlist-peek

    (defthm return-type-of-vl-printedlist-peek
      (b* ((maybe-char (vl-printedlist-peek x)))
        (or (not maybe-char)
            (characterp maybe-char)))
      :rule-classes :type-prescription)