Parse a list of zero or more identifiers preceded by commas.
(parse-*-comma-identifier parstate) → (mv erp idents span new-parstate)
That is, we parse a
If the next token is absent or not a comma, we return the empty list of identifiers and an irrelevant span. Otherwise, we parse an identifier, and then we recursively parse zero or more additional identifiers separated by commas. We join spans only if the recursive call returns a non-empty list.
Function:
(defun parse-*-comma-identifier (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'parse-*-comma-identifier)) (declare (ignorable __function__)) (b* (((reterr) nil (irr-span) parstate) ((erp token span parstate) (read-token parstate)) ((unless (token-punctuatorp token ",")) (b* ((parstate (if token (unread-token parstate) parstate))) (retok nil (irr-span) parstate))) ((erp ident ident-span parstate) (read-identifier parstate)) ((erp idents idents-span parstate) (parse-*-comma-identifier parstate))) (retok (cons ident idents) (if idents (span-join span idents-span) (span-join span ident-span)) parstate))))
Theorem:
(defthm ident-listp-of-parse-*-comma-identifier.idents (b* (((mv acl2::?erp ?idents ?span ?new-parstate) (parse-*-comma-identifier parstate))) (ident-listp idents)) :rule-classes :rewrite)
Theorem:
(defthm spanp-of-parse-*-comma-identifier.span (b* (((mv acl2::?erp ?idents ?span ?new-parstate) (parse-*-comma-identifier parstate))) (spanp span)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-parse-*-comma-identifier.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?idents ?span ?new-parstate) (parse-*-comma-identifier parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm parsize-of-parse-*-comma-identifier-uncond (b* (((mv acl2::?erp ?idents ?span ?new-parstate) (parse-*-comma-identifier parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)