• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
        • Transformations
        • Language
          • Abstract-syntax
          • Dynamic-semantics
            • Exec
            • Find-fun
            • Init-local
            • Write-vars-values
            • Add-vars-values
            • Add-funs
            • Eoutcome
            • Soutcome
            • Ensure-funscope-disjoint
            • Write-var-value
            • Restrict-vars
            • Add-var-value
            • Funinfo
            • Exec-top-block
            • Values
            • Cstate
            • Funinfo+funenv
            • Read-vars-values
            • Read-var-value
            • Funenv
            • Funscope-for-fundefs
            • Exec-path
            • Path-to-var
            • Funinfo+funenv-result
            • Exec-literal
            • Soutcome-result
            • Mode-set-result
            • Literal-evaluation
              • Eval-literal
              • Eval-hex-string-literal
              • Eval-plain-string-literal
              • Ubyte16-to-utf8
              • Eval-escape
                • Eval-string-element
                • Eval-hex-string-rest-element-list
                • Eval-hex-string-rest-element
                • Eval-hex-string-content
                • Eval-string-element-list
                • Eval-hex-quad
                • Eval-hex-pair
              • Funscope-result
              • Funinfo-result
              • Funenv-result
              • Eoutcome-result
              • Cstate-result
              • Paths-to-vars
              • Funinfo-for-fundef
              • Lstate
              • Funscope
              • Mode-set
              • Modes
            • Concrete-syntax
            • Static-soundness
            • Static-semantics
            • Errors
          • Yul-json
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Literal-evaluation

    Eval-escape

    Evaluate an escape to a list of bytes.

    Signature
    (eval-escape esc) → bytes
    Arguments
    esc — Guard (escapep esc).
    Returns
    bytes — Type (ubyte8-listp bytes).

    The evaluation of plain string literals involves first turning the string into a sequence of bytes. Here we turn an escape into a sequence of bytes. An escape consisting of a backslash followed by a single character is turned into a singleton byte list with the character's code. A \x... escape is turned into a singleton byte list with the value of the escape. A \u... escape is turned into a list of 1, 2, or 3 bytes that is the UTF-8 encoding of the code point.

    Definitions and Theorems

    Function: eval-escape

    (defun eval-escape (esc)
      (declare (xargs :guard (escapep esc)))
      (let ((__function__ 'eval-escape))
        (declare (ignorable __function__))
        (escape-case esc
                     :single-quote (list (char-code #\'))
                     :double-quote (list (char-code #\"))
                     :backslash (list (char-code #\\))
                     :letter-n (list 10)
                     :letter-r (list 13)
                     :letter-t (list 9)
                     :line-feed (list 10)
                     :carriage-return (list 13)
                     :x (list (eval-hex-pair esc.get))
                     :u (ubyte16-to-utf8 (eval-hex-quad esc.get)))))

    Theorem: ubyte8-listp-of-eval-escape

    (defthm ubyte8-listp-of-eval-escape
      (b* ((bytes (eval-escape esc)))
        (ubyte8-listp bytes))
      :rule-classes :rewrite)

    Theorem: eval-escape-of-escape-fix-esc

    (defthm eval-escape-of-escape-fix-esc
      (equal (eval-escape (escape-fix esc))
             (eval-escape esc)))

    Theorem: eval-escape-escape-equiv-congruence-on-esc

    (defthm eval-escape-escape-equiv-congruence-on-esc
      (implies (escape-equiv esc esc-equiv)
               (equal (eval-escape esc)
                      (eval-escape esc-equiv)))
      :rule-classes :congruence)