• 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
          • Printing-locally
          • Formatted-printing
          • Accessing-printed-output
          • Json-printing
            • Json-encoders
              • Vl-jp-expr
              • Vl-jp-module
              • Vl-jp-interface
              • Vl-jp-design
              • Vl-jp-warning
              • Vl-jp-package
              • Vl-jp-vardecl
              • Vl-jp-class
              • Vl-jp-ansi-portdecl
              • Vl-jp-udp
              • Vl-jp-taskdecl
              • Vl-jp-fundecl
              • Vl-jp-constint
              • Vl-jp-clkdecl
              • Jp-sym-main
              • Vl-jp-modinst
              • Vl-jp-dpiimport
              • Vl-jp-typedef
              • Vl-jp-propport
              • Vl-jp-program
              • Vl-jp-portdecl
              • Vl-jp-paramdecl
              • Vl-jp-gateinst
              • Vl-jp-dpiexport
              • Vl-jp-config
              • Vl-jp-sequence
              • Vl-jp-property
              • Vl-jp-parse-temps
              • Vl-jp-namedparamvaluelist
              • Vl-jp-modport-port
              • Vl-jp-interfaceport
              • Vl-jp-clkassign
              • Vl-jp-assign
              • Jp-str
                • Jp-col-after-printing-string-aux
              • Vl-jp-warninglist
              • Vl-jp-vardecllist
              • Vl-jp-udplinelist
              • Vl-jp-udpentrylist
              • Vl-jp-typedeflist
              • Vl-jp-taskdecllist
              • Vl-jp-sequencelist
              • Vl-jp-regularport
              • Vl-jp-propspec
              • Vl-jp-propportlist
              • Vl-jp-propertylist
              • Vl-jp-programlist
              • Vl-jp-portdecllist
              • Vl-jp-plainarglist
              • Vl-jp-plainarg
              • Vl-jp-paramvaluelist
              • Vl-jp-paramdecllist
              • Vl-jp-packagelist
              • Vl-jp-namedarglist
              • Vl-jp-namedarg
              • Vl-jp-modulelist
              • Vl-jp-modportlist
              • Vl-jp-modport-portlist
              • Vl-jp-modport
              • Vl-jp-modinstlist
              • Vl-jp-locationlist
              • Vl-jp-interfacelist
              • Vl-jp-initiallist
              • Vl-jp-importlist
              • Vl-jp-import
              • Vl-jp-genvarlist
              • Vl-jp-gclkdecllist
              • Vl-jp-gclkdecl
              • Vl-jp-gateinstlist
              • Vl-jp-fwdtypedeflist
              • Vl-jp-fwdtypedef
              • Vl-jp-fundecllist
              • Vl-jp-finallist
              • Vl-jp-exprdistlist
              • Vl-jp-elabtasklist
              • Vl-jp-dpiimportlist
              • Vl-jp-dpiexportlist
              • Vl-jp-distitemlist
              • Vl-jp-distitem
              • Vl-jp-defaultdisablelist
              • Vl-jp-defaultdisable
              • Vl-jp-covergrouplist
              • Vl-jp-configlist
              • Vl-jp-clkdecllist
              • Vl-jp-clkassignlist
              • Vl-jp-classlist
              • Vl-jp-cassertionlist
              • Vl-jp-blockitemlist
              • Vl-jp-bind
              • Vl-jp-assignlist
              • Vl-jp-assertionlist
              • Vl-jp-ansi-portdecllist
              • Vl-jp-alwayslist
              • Vl-jp-always
              • Vl-jp-aliaslist
              • Vl-jp-alias
              • Jp-nat
              • Vl-jp-udplist
              • Vl-jp-udpline
              • Vl-jp-timeunitdecl
              • Vl-jp-timeprecisiondecl
              • Vl-jp-timeliteral
              • Vl-jp-repetition
              • Vl-jp-repeateventcontrol
              • Vl-jp-portlist
              • Vl-jp-namedparamvalue
              • Vl-jp-initial
              • Vl-jp-genvar
              • Vl-jp-gatestrength
              • Vl-jp-gatedelay
              • Vl-jp-final
              • Vl-jp-exprdist
              • Vl-jp-eventcontrol
              • Vl-jp-covergroup
              • Vl-jp-clkskew
              • Vl-jp-bindlist
              • Jp-object
              • Vl-jp-udpedge
              • Vl-jp-maybe-timeunitdecl
              • Vl-jp-maybe-timeprecisiondecl
              • Vl-jp-maybe-timeliteral
              • Vl-jp-maybe-parse-temps
              • Vl-jp-maybe-nettypename
              • Vl-jp-maybe-gatestrength
              • Vl-jp-maybe-delayoreventcontrol
              • Vl-jp-elabtask
              • Vl-jp-delaycontrol
              • Vl-jp-value
              • Vl-jp-maybe-udpsymbol
              • Vl-jp-maybe-scopeid
              • Vl-jp-maybe-rhs
              • Vl-jp-maybe-paramvalue
              • Vl-jp-maybe-module
              • Vl-jp-maybe-gatedelay
              • Vl-jp-maybe-exprdist
              • Vl-jp-maybe-clkskew
              • Vl-jp-weirdint
              • Vl-jp-time
              • Vl-jp-string
              • Vl-jp-real
              • Vl-jp-maybe-direction
              • Vl-jp-maybe-cstrength
              • Vl-jp-extint
              • Jp-timeunit
              • Jp-bool
              • Jp-bitlist
              • Jp-bit
              • Jp-bignat
              • Vl-jp-maybe-exprsign
              • Vl-jp-gatetype
              • Vl-jp-exprsign
              • Vl-jp-evatomtype
              • Vl-jp-dstrength
              • Vl-jp-direction
              • Vl-jp-deassign-type
              • Vl-jp-cstrength
              • Vl-jp-casetype
              • Vl-jp-casekey
              • Vl-jp-casecheck
              • Vl-jp-assign-type
              • Vl-jp-alwaystype
              • Jp-maybe-string
              • Jp-maybe-nat
              • Jp-sym
          • Vl-printedlist
        • Kit
        • Mlib
        • Transforms
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Testing-utilities
    • Math
  • Json-encoders

Jp-str

Print the JSON encoding of a string, handling all escaping correctly and including the surrounding quotes.

Signature
(jp-str x &key (ps 'ps)) → ps

We go to some effort to make this fast.

Definitions and Theorems

Function: jp-str-fn

(defun
 jp-str-fn (x ps)
 (declare (xargs :stobjs (ps)))
 (declare (type string x))
 (let
  ((__function__ 'jp-str))
  (declare (ignorable __function__))
  (b*
   ((rchars (vl-ps->rchars))
    (col (vl-ps->col))
    (xl (length x))
    (rchars
      (cons #\"
            (bridge::json-encode-str-aux x 0 xl (cons #\" rchars))))
    (col (+ 2
            (jp-col-after-printing-string-aux col x 0 xl))))
   (vl-ps-seq (vl-ps-update-rchars rchars)
              (vl-ps-update-col col)))))

Subtopics

Jp-col-after-printing-string-aux
Fast way to figure out the new column after printing a JSON string with proper encoding.