blob: ad5786ca2fb28f8dd318d2c256305bee4d209b98 (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
|
IMPLEMENTATION MODULE TextUtil ;
IMPORT CharClass, IOConsts ;
(*
SkipSpaces - skips any spaces.
*)
PROCEDURE SkipSpaces (cid: IOChan.ChanId) ;
VAR
ch : CHAR ;
res: IOConsts.ReadResults ;
BEGIN
WHILE CharAvailable (cid) DO
IOChan.Look (cid, ch, res) ;
IF (res = IOConsts.allRight) AND CharClass.IsWhiteSpace (ch)
THEN
IOChan.Skip (cid)
ELSE
RETURN
END
END
END SkipSpaces ;
(* CharAvailable returns TRUE if IOChan.ReadResult is notKnown or
allRight. *)
PROCEDURE CharAvailable (cid: IOChan.ChanId) : BOOLEAN ;
BEGIN
RETURN( (IOChan.ReadResult (cid) = IOConsts.notKnown) OR
(IOChan.ReadResult (cid) = IOConsts.allRight) )
END CharAvailable ;
(* EofOrEoln returns TRUE if IOChan.ReadResult is endOfLine or
endOfInput. *)
PROCEDURE EofOrEoln (cid: IOChan.ChanId) : BOOLEAN ;
BEGIN
RETURN( (IOChan.ReadResult (cid) = IOConsts.endOfLine) OR
(IOChan.ReadResult (cid) = IOConsts.endOfInput) )
END EofOrEoln ;
END TextUtil.
|