Parse a specified
(parse-separator separator token input) → (mv tree next-token rest-input)
This is used to check the presence of an expected separator.
We return it as a leaf tree as the first result,
because this is how an separator occurs
in the CSTs of the syntactic grammar.
In other words, the
This is consistent with the fact that
the rule for
Function:
(defun parse-separator (separator token input) (declare (xargs :guard (and (stringp separator) (abnf::tree-optionp token) (abnf::tree-listp input)))) (declare (xargs :guard (member-equal separator *separators*))) (let ((__function__ 'parse-separator)) (declare (ignorable __function__)) (b* ((tree (check-token-root "separator" token)) ((when (reserrp tree)) (perr (reserrf-push tree))) ((unless (equal (abnf::tree->string tree) (string=>nats (str-fix separator)))) (perr (list :required (str-fix separator) :found (abnf::tree-option-fix token)))) (tree (abnf::tree-leafterm (string=>nats (str-fix separator)))) ((mv token input) (parse-token input))) (mv tree token input))))
Theorem:
(defthm tree-resultp-of-parse-separator.tree (b* (((mv ?tree ?next-token ?rest-input) (parse-separator separator token input))) (abnf::tree-resultp tree)) :rule-classes :rewrite)
Theorem:
(defthm tree-optionp-of-parse-separator.next-token (b* (((mv ?tree ?next-token ?rest-input) (parse-separator separator token input))) (abnf::tree-optionp next-token)) :rule-classes :rewrite)
Theorem:
(defthm tree-listp-of-parse-separator.rest-input (b* (((mv ?tree ?next-token ?rest-input) (parse-separator separator token input))) (abnf::tree-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-parse-separator-<= (b* (((mv ?tree ?next-token ?rest-input) (parse-separator separator token input))) (<= (parsize next-token rest-input) (parsize token input))) :rule-classes :linear)
Theorem:
(defthm parsize-of-parse-separator-< (b* (((mv ?tree ?next-token ?rest-input) (parse-separator separator token input))) (implies (not (reserrp tree)) (< (parsize next-token rest-input) (parsize token input)))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-separator-<= (b* (((mv ?tree ?next-token ?rest-input) (parse-separator separator token input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-separator-< (b* (((mv ?tree ?next-token ?rest-input) (parse-separator separator token input))) (implies (and (not (reserrp tree)) next-token) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm parse-separator-of-str-fix-separator (equal (parse-separator (str-fix separator) token input) (parse-separator separator token input)))
Theorem:
(defthm parse-separator-streqv-congruence-on-separator (implies (acl2::streqv separator separator-equiv) (equal (parse-separator separator token input) (parse-separator separator-equiv token input))) :rule-classes :congruence)
Theorem:
(defthm parse-separator-of-tree-option-fix-token (equal (parse-separator separator (abnf::tree-option-fix token) input) (parse-separator separator token input)))
Theorem:
(defthm parse-separator-tree-option-equiv-congruence-on-token (implies (abnf::tree-option-equiv token token-equiv) (equal (parse-separator separator token input) (parse-separator separator token-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-separator-of-tree-list-fix-input (equal (parse-separator separator token (abnf::tree-list-fix input)) (parse-separator separator token input)))
Theorem:
(defthm parse-separator-tree-list-equiv-congruence-on-input (implies (abnf::tree-list-equiv input input-equiv) (equal (parse-separator separator token input) (parse-separator separator token input-equiv))) :rule-classes :congruence)