/* --- Copyright University of Sussex 1995. All rights reserved. --------- > File: C.all/lib/auto/forevery.p > Purpose: takes a list of patterns and tries to satisfy all. > Author: A. Sloman circa 1982 (see revisions) > Documentation: HELP * FOREVERY > Related Files: LIB * FOREACH, HELP * FOREACH, HELP * DATABASE */ compile_mode :pop11 +strict; ;;; forevery is to allpresent as foreach is to present. ;;; ;;; forevery ____________pattern_list [in ____list] do _______actions endforevery ;;; ;;; becomes, roughly: ;;; ;;; lvars tmp = consproc(____________pattern_list,____list,2,try_all_matches); ;;; while runproc(tmp, 0) do _______actions endforevery; ;;; ;;; where ____list defaults to database. section; uses-by_name $-database$-try_all_matches; vars syntax endforevery = pop_undef; define vars syntax forevery; lvars Endlab, Lab, Proc, x; pop11_loop_start(sysNEW_LABEL() ->> Lab); pop11_loop_end(sysNEW_LABEL() ->> Endlab); sysNEW_LVAR() -> Proc; pop11_comp_expr_to([do then in]) -> x; if x == "in" then pop11_comp_expr_to([do then]) -> else sysPUSH("database") endif; sysPUSHQ(2); sysPUSH("ident $-database$-try_all_matches"); sysCALL("consproc") -> sysPUSH(Proc); sysLABEL(Lab); sysCALL(sysPUSHQ(0), sysPUSH(Proc), "runproc"), sysIFNOT(Endlab); -> sysPUSH("database_them"); ;;; instance left on stack pop11_comp_stmnt_seq_to([endforevery close]) -> ; sysGOTO(Lab); sysLABEL(Endlab) enddefine; endsection; /* --- Revision History --------------------------------------------------- --- John Gibson, Dec 27 1995 Rewritten and moved to $popautolib (run-time code is now in $popliblib/S-databaseS-try_all_matches.p) --- Aaron Sloman, Jun 22 1986 comments corrected, lvars used where appropriate. */