Parse a list of zero or more external declarations.
(parse-*-external-declaration parstate) → (mv erp extdecls span eof-pos new-parstate)
This is called by parse-translation-unit to parse all the external declarations in a file. If successful, we return the list of external declarations.
We also return the position just past the end of the file. The latter is used for a check performed by the caller.
Function:
(defun parse-*-external-declaration (parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (parstatep parstate))) (let ((__function__ 'parse-*-external-declaration)) (declare (ignorable __function__)) (b* (((reterr) nil (irr-span) (irr-position) parstate) ((erp token span parstate) (read-token parstate)) ((when (not token)) (retok nil span (span->start span) parstate)) (parstate (unread-token parstate)) ((erp extdecl first-span parstate) (parse-external-declaration parstate)) ((erp extdecls last-span eof-pos parstate) (parse-*-external-declaration parstate))) (retok (cons extdecl extdecls) (span-join first-span last-span) eof-pos parstate))))
Theorem:
(defthm ext-declon-listp-of-parse-*-external-declaration.extdecls (b* (((mv acl2::?erp ?extdecls ?span ?eof-pos ?new-parstate) (parse-*-external-declaration parstate))) (ext-declon-listp extdecls)) :rule-classes :rewrite)
Theorem:
(defthm spanp-of-parse-*-external-declaration.span (b* (((mv acl2::?erp ?extdecls ?span ?eof-pos ?new-parstate) (parse-*-external-declaration parstate))) (spanp span)) :rule-classes :rewrite)
Theorem:
(defthm positionp-of-parse-*-external-declaration.eof-pos (b* (((mv acl2::?erp ?extdecls ?span ?eof-pos ?new-parstate) (parse-*-external-declaration parstate))) (positionp eof-pos)) :rule-classes :rewrite)
Theorem:
(defthm parstatep-of-parse-*-external-declaration.new-parstate (implies (parstatep parstate) (b* (((mv acl2::?erp ?extdecls ?span ?eof-pos ?new-parstate) (parse-*-external-declaration parstate))) (parstatep new-parstate))) :rule-classes :rewrite)
Theorem:
(defthm true-listp-of-parse-*-external-declaration.extdecls (b* (((mv acl2::?erp ?extdecls ?span ?eof-pos ?new-parstate) (parse-*-external-declaration parstate))) (true-listp extdecls)) :rule-classes :type-prescription)
Theorem:
(defthm parsize-of-parse-*-external-declaration-uncond (b* (((mv acl2::?erp ?extdecls ?span ?eof-pos ?new-parstate) (parse-*-external-declaration parstate))) (<= (parsize new-parstate) (parsize parstate))) :rule-classes :linear)