Given a string, extract all text that occurs between two vl-location-ps.
(vl-string-between-locs x loc1 loc2) → text
If both locations refer to valid places in
Function:
(defun vl-string-between-locs (x loc1 loc2) (declare (xargs :guard (and (stringp x) (vl-location-p loc1) (vl-location-p loc2)))) (let ((__function__ 'vl-string-between-locs)) (declare (ignorable __function__)) (b* ((x (string-fix x)) ((mv loc1 loc2) (if (vl-location-before-nofilename loc1 loc2) (mv loc1 loc2) (mv loc2 loc1))) (xl (length x)) (tline1 (vl-location->line loc1)) (tcol1 (vl-location->col loc1)) (pos1 (vl-string-findloc-aux x 0 xl 1 0 tline1 tcol1)) ((unless pos1) nil) (tline2 (vl-location->line loc2)) (tcol2 (vl-location->col loc2)) (pos2 (vl-string-findloc-aux x pos1 xl tline1 tcol1 tline2 tcol2)) ((unless pos2) nil)) (subseq x pos1 pos2))))
Theorem:
(defthm maybe-stringp-of-vl-string-between-locs (b* ((text (vl-string-between-locs x loc1 loc2))) (maybe-stringp text)) :rule-classes :type-prescription)