ExpertKeepReadImpl.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Christophe Cuenod, February 1, 1988 4:03:54 pm PST
Reads a .keep file
DIRECTORY
FS USING [StreamOpen],
IO USING [EndOf, EndOfStream, GetTokenRope, STREAM],
Rope USING [ROPE, Substr],
ExpertKeepRead,
SymTab USING [Create, Fetch, Insert, Ref];
ExpertKeepReadImpl: CEDAR PROGRAM
IMPORTS FS, IO, Rope, SymTab
EXPORTS ExpertKeepRead
~
BEGIN
ROPE: TYPE = Rope.ROPE;
RefDesTable: TYPE = ExpertKeepRead.RefDesTable;
Public Procedures
ReadKeepFile:
PUBLIC
PROC [file:
ROPE]
RETURNS [refDesTable: RefDesTable] ~ {
refDes: Rope.ROPE;
in: IO.STREAM ← FS.StreamOpen[file];
refDesTable ← SymTab.Create[];
WHILE
NOT
IO.EndOf[in]
DO
refDes ← IO.GetTokenRope[in ! IO.EndOfStream => CONTINUE].token;
[] ← SymTab.Insert[refDesTable, refDes, refDes];
ENDLOOP;
};
KeepRefDes:
PUBLIC
PROC [refDesTable: RefDesTable, refDes: Rope.
ROPE]
RETURNS [found:
BOOLEAN] ~ {
found ← SymTab.Fetch[refDesTable, refDes].found;
IF
NOT found
THEN {
refDes ← Rope.Substr[refDes, 0, 1];
found ← SymTab.Fetch[refDesTable, refDes].found;
};
};
END.