<<>> <> <> <> <> <<>> <> (cedar-imports "MobConnection") (cedar-directory "Rope") (cedar-require "Require Cedar MobConnection MobConnection") (release-as "Cedar" "MobConnection") (define-ref-type "Scheme" "Symbol") (define-enum-type "MobConnection" "FilterItem" (versions directory using imports imported-items exports type-exports exported-items modules configurations)) (primitive-enable MobConnection.Error => Complain[culprit, msg]; ) Appender: TYPE = RECORD [head, last: Pair]; (define-proc (decode-mob filename (filter)) "Extract useful information from a mob file" stack: LIST OF Appender _ NIL; Begin: PROC [id: Symbol] = { head: Pair = Cons[id, NIL]; stack _ CONS[[head, head], stack]; }; End: PROC = { a: Any _ stack.first.head; stack _ stack.rest; IF stack = NIL THEN result _ a ELSE Put[a]; }; Put: PROC [a: Any] = { stack.first.last _ stack.first.last.cdr _ Cons[a, NIL] }; PutATOM: PROC [a: Symbol] = {Put[a]}; PutROPE: PROC [a: Rope.ROPE] = {Put[StringFromRope[a]]}; PutINT: PROC [a: INT] = {Put[MakeFixnum[a]]}; PutBOOL: PROC [a: BOOL] = {Put[IF a THEN true ELSE false]}; PutModuleID: PROC [a: MobConnection.ModuleID] = { Begin[$id]; PutATOM[a.identifier]; PutATOM[a.version]; End[] }; f: MobConnection.Filter _ ALL[FALSE]; IF filter = undefined THEN f _ ALL[TRUE] ELSE { FOR tail: Any _ filter, Cdr[tail] UNTIL tail = NIL DO f[TheFilterItem[Car[tail]]] _ TRUE; ENDLOOP; }; MobConnection.DecodeMob[fileName: RopeFromString[TheString[filename]], begin: Begin, end: End, putATOM: PutATOM, putROPE: PutROPE, putINT: PutINT, putBOOL: PutBOOL, putModuleID: PutModuleID, filter: f]; IF stack # NIL THEN ERROR; ) (define mob-all '(versions directory using imports imported-items exports type-exports exported-items modules configurations))