Evaluate an escape to a list of bytes.
(eval-escape esc) → 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
Function:
(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:
(defthm ubyte8-listp-of-eval-escape (b* ((bytes (eval-escape esc))) (acl2::ubyte8-listp bytes)) :rule-classes :rewrite)
Theorem:
(defthm eval-escape-of-escape-fix-esc (equal (eval-escape (escape-fix esc)) (eval-escape esc)))
Theorem:
(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)