Match all leading characters in some charset-p.
(sin-match-charset* set sin) → (mv match sin)
Examples:
(defcharset num (str::digitp x)) (sin-match-charset* (num-chars) [apple123]) --> (nil [apple123]) (sin-match-charset* (num-chars) [123apple]) --> ("123" [apple])
Function:
(defun sin-match-charset* (set sin) (declare (xargs :stobjs (sin))) (declare (xargs :guard (charset-p set))) (let ((__function__ 'sin-match-charset*)) (declare (ignorable __function__)) (b* ((num-matches (sin-count-charset set sin)) ((when (zp num-matches)) (mv nil sin)) (match1 (sin-firstn num-matches sin)) (sin (sin-nthcdr num-matches sin))) (mv match1 sin))))
Theorem:
(defthm return-type-of-sin-match-charset*.match (b* (((mv ?match ?sin) (sin-match-charset* set sin))) (or (stringp match) (not match))) :rule-classes :type-prescription)
Theorem:
(defthm stringp-of-sin-match-charset*.match (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (equal (stringp match) (if match t nil))))
Theorem:
(defthm non-empty-of-sin-match-charset*.match (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (equal (equal match "") nil)))
Theorem:
(defthm sin-match-charset*-progress-weak (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (<= (len (strin-left new-sin)) (len (strin-left sin)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm sin-match-charset*-progress-strong (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (implies match (< (len (strin-left new-sin)) (len (strin-left sin))))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm sin-match-charset*-reconstruction (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (equal (append (explode match) (strin-left new-sin)) (strin-left sin))))
Theorem:
(defthm sin-match-charset*-graceful-failure (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (implies (not match) (equal new-sin sin))))
Theorem:
(defthm sin-match-charset*-reconstruction-free (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (implies (equal chars (explode match)) (equal (append chars (strin-left new-sin)) (strin-left sin)))))
Theorem:
(defthm sin-match-charset*.match-succeeds (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (implies (char-in-charset-p (sin-car sin) set) match)))
Theorem:
(defthm chars-in-charset-p-of-sin-match-charset*.match (b* (((mv ?match ?new-sin) (sin-match-charset* set sin))) (chars-in-charset-p (explode match) set)))