Check if the given token is present and has the given string as fringe.
(check-token-string string token) → tree
If the check is successful, return the token. Using this function ensures that we get a CST tree or reserr.
Function:
(defun check-token-string (string token) (declare (xargs :guard (and (stringp string) (abnf::tree-optionp token)))) (let ((__function__ 'check-token-string)) (declare (ignorable __function__)) (abnf::tree-option-case token :some (if (token-stringp string token.val) token.val (reserrf (list :required (str-fix string) :found token.val))) :none (reserrf (list :required (str-fix string) :found nil)))))
Theorem:
(defthm tree-resultp-of-check-token-string (b* ((tree (check-token-string string token))) (abnf::tree-resultp tree)) :rule-classes :rewrite)
Theorem:
(defthm check-token-string-of-str-fix-string (equal (check-token-string (str-fix string) token) (check-token-string string token)))
Theorem:
(defthm check-token-string-streqv-congruence-on-string (implies (acl2::streqv string string-equiv) (equal (check-token-string string token) (check-token-string string-equiv token))) :rule-classes :congruence)
Theorem:
(defthm check-token-string-of-tree-option-fix-token (equal (check-token-string string (abnf::tree-option-fix token)) (check-token-string string token)))
Theorem:
(defthm check-token-string-tree-option-equiv-congruence-on-token (implies (abnf::tree-option-equiv token token-equiv) (equal (check-token-string string token) (check-token-string string token-equiv))) :rule-classes :congruence)