• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
          • Transformations
          • Language
            • Abstract-syntax
            • Dynamic-semantics
            • Concrete-syntax
            • Static-soundness
            • Static-semantics
              • Static-safety-checking
              • Static-shadowing-checking
              • 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
                • Static-identifier-checking
                • Static-safety-checking-evm
                • Mode-set
                • Modes
              • Errors
            • Yul-json
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • 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)