Debian Codegraph @

gcc/m2/gm2-libs-iso/TextUtil.mod

raw
1 IMPLEMENTATION MODULE TextUtil ;
2
3 IMPORT CharClass, IOConsts ;
4
5 (*
6 SkipSpaces - skips any spaces.
7 *)
8
9 PROCEDURE SkipSpaces (cid: IOChan.ChanId) ;
10 VAR
11 ch : CHAR ;
12 res: IOConsts.ReadResults ;
13 BEGIN
14 WHILE CharAvailable (cid) DO
15 IOChan.Look (cid, ch, res) ;
16 IF (res = IOConsts.allRight) AND CharClass.IsWhiteSpace (ch)
17 THEN
18 IOChan.Skip (cid)
19 ELSE
20 RETURN
21 END
22 END
23 END SkipSpaces ;
24
25
26 (* CharAvailable returns TRUE if IOChan.ReadResult is notKnown or
27 allRight. *)
28
29 PROCEDURE CharAvailable (cid: IOChan.ChanId) : BOOLEAN ;
30 BEGIN
31 RETURN( (IOChan.ReadResult (cid) = IOConsts.notKnown) OR
32 (IOChan.ReadResult (cid) = IOConsts.allRight) )
33 END CharAvailable ;
34
35
36 (* EofOrEoln returns TRUE if IOChan.ReadResult is endOfLine or
37 endOfInput. *)
38
39 PROCEDURE EofOrEoln (cid: IOChan.ChanId) : BOOLEAN ;
40 BEGIN
41 RETURN( (IOChan.ReadResult (cid) = IOConsts.endOfLine) OR
42 (IOChan.ReadResult (cid) = IOConsts.endOfInput) )
43 END EofOrEoln ;
44
45
46 END TextUtil.