-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathORTexts.Mod.txt
More file actions
33 lines (27 loc) · 764 Bytes
/
ORTexts.Mod.txt
File metadata and controls
33 lines (27 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
MODULE ORTexts;
IMPORT Files;
TYPE Text* = POINTER TO TextDesc;
TextDesc = RECORD
f: Files.File;
END;
Reader* = RECORD
eot*: BOOLEAN;
off, len: INTEGER;
rider: Files.Rider
END;
PROCEDURE Open* (T: Text; name: ARRAY OF CHAR);
BEGIN T.f := Files.Old(name); ASSERT(T.f # NIL)
END Open;
PROCEDURE OpenReader* (VAR R: Reader; T: Text; pos: INTEGER);
BEGIN R.off := pos; R.len := Files.Length(T.f); Files.Set(R.rider, T.f, pos); R.eot := FALSE
END OpenReader;
PROCEDURE Read* (VAR R: Reader; VAR ch: CHAR);
BEGIN Files.Read(R.rider, ch);
INC(R.off);
IF R.off = R.len THEN R.eot := TRUE END
END Read;
PROCEDURE Pos* (VAR R: Reader): INTEGER;
BEGIN RETURN R.off
END Pos;
BEGIN
END ORTexts.