DEFINITION MODULE MASREP; (* MAS Representation Definition Module. *) FROM MASSTOR IMPORT LIST; PROCEDURE NewRep(): LIST; (*New representation. A new representation is returned. *) PROCEDURE SetRep(n,e,r: LIST); (*Set representation. r is a representation. n is a unique label, e is an expression. *) PROCEDURE GetRep(n,r: LIST): LIST; (*Get representation. r is a representation. n is a unique label, An expression e stored under n is returned. *) PROCEDURE CopyRep(r: LIST): LIST; (*Copy representation. r is a representation. A copy of r is returned. Step counters are reset. *) PROCEDURE StepRep(r: LIST): LIST; (*Step through representation. r is a representation. The next expression e and its label n are returned as pair (n,e). If all pairs (n,e) of representation r have been processed, then NIL is returned. *) PROCEDURE ForEachinRep(r, f, E: LIST): LIST; (*For each pair (n,e) in r apply function f. r is a representation. (n, e) is a pair in r, where e is an expression and n is its label. f is applied to (n, e) such that p = f(n,e) with p = (n', e') or p = NIL. If p <> NIL, then the pair (n', e') is added to the returned representation r' = { n' e' : f(n,e) <> NIL, n e in r }. E is a LISP environment, if E = NIL, then the top level environment is used. *) PROCEDURE FullRep(r: LIST): LIST; (*Full representation. Test for non-empty representation. r is a representation. *) PROCEDURE ForEachinList(r, f, E: LIST): LIST; (*For each element e in r apply function f. r is a list. e is an element in r. f is applied to e such that e' = f(e). E is a LISP environment, if E = NIL, then the top level environment is used. *) END MASREP.