Attempts to eat a path and build a path AST node.
(parse-path tokens) → (mv ast-node tokens-after-path)
Function:
(defun parse-path (tokens) (declare (xargs :guard (abnf::tree-listp tokens))) (let ((__function__ 'parse-path)) (declare (ignorable __function__)) (b* (((when (endp tokens)) (mv (reserrf (cons "no path here" tokens)) nil)) ((mv first-id tokens-after-first-id) (parse-identifier tokens)) ((when (null first-id)) (mv (reserrf (cons "can't be path since no identifier" tokens)) nil)) ((when (reserrp tokens-after-first-id)) (mv (reserrf (cons "can't be path since no identifier 2" tokens)) nil)) ((mv rest-ids rest-tokens) (parse-*-.-identifier tokens-after-first-id)) ((unless (mbt (< (len rest-tokens) (len tokens)))) (mv (reserrf (cons "logic error" (cons tokens-after-first-id tokens))) nil))) (mv (make-path :get (cons first-id rest-ids)) rest-tokens))))
Theorem:
(defthm path-resultp-of-parse-path.ast-node (b* (((mv ?ast-node ?tokens-after-path) (parse-path tokens))) (path-resultp ast-node)) :rule-classes :rewrite)
Theorem:
(defthm tree-listp-of-parse-path.tokens-after-path (b* (((mv ?ast-node ?tokens-after-path) (parse-path tokens))) (abnf::tree-listp tokens-after-path)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-path-< (b* (((mv ?ast-node ?tokens-after-path) (parse-path tokens))) (implies (not (reserrp ast-node)) (< (len tokens-after-path) (len tokens)))) :rule-classes :linear)