• Top
    • Documentation
      • Xdoc
        • Undocumented
        • Save
        • Defsection
        • Markup
        • Preprocessor
        • Terminal
        • Emacs-links
        • Defxdoc
        • Katex-integration
        • Constructors
          • Primitive-constructors
          • Composite-constructors
          • Constructor-preliminaries
            • Partition-macro-args
            • String-downcase$
            • Keyword-macro-args-to-terms
            • String-escape
              • *newline*
            • Trees
          • Entities
          • Defxdoc+
          • Save-rendered
          • Add-resource-directory
          • Testing
          • Order-subtopics
          • Save-rendered-event
          • Archive-matching-topics
          • Archive-xdoc
          • Xdoc-extend
          • Set-default-parents
          • Missing-parents
          • Defpointer
          • Defxdoc-raw
          • Xdoc-tests
          • Xdoc-prepend
          • Defsection-progn
          • Gen-xdoc-for-file
        • ACL2-doc
        • Recursion-and-induction
        • Loop$-primer
        • Operational-semantics
        • Pointers
        • Doc
        • Documentation-copyright
        • Course-materials
        • Publications
        • Args
        • ACL2-doc-summary
        • Finding-documentation
        • Broken-link
        • Doc-terminal-test-2
        • Doc-terminal-test-1
      • Books
      • Boolean-reasoning
      • Projects
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Constructor-preliminaries

    String-escape

    Escape certain characters in a string, using backslashes.

    We escape each single quote and backquote character that occurs in the string.

    This is used in generate-primitive-constructor-for-dir/&&, since some of the macros generated by that macro have names that include the characters escaped by this function. These characters would cause XDOC errors if not escaped.

    Definitions and Theorems

    Function: chars-escape

    (defun chars-escape (chars)
      (declare (xargs :guard (character-listp chars)))
      (cond ((endp chars) nil)
            (t (if (member (car chars) '(#\' #\`))
                   (list* #\\ #\' (chars-escape (cdr chars)))
                 (cons (car chars)
                       (chars-escape (cdr chars)))))))

    Theorem: character-listp-of-chars-escape

    (defthm character-listp-of-chars-escape
      (implies (character-listp chars)
               (character-listp (chars-escape chars))))

    Function: string-escape

    (defun string-escape (string)
      (declare (xargs :guard (stringp string)))
      (let* ((chars (coerce string 'list))
             (chars (chars-escape chars))
             (string (coerce chars 'string)))
        string))

    Theorem: stringp-of-string-escape

    (defthm stringp-of-string-escape
      (stringp (string-escape string)))