diff options
Diffstat (limited to 'gcc/m2/gm2-libs-iso/TextUtil.mod')
-rw-r--r-- | gcc/m2/gm2-libs-iso/TextUtil.mod | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/m2/gm2-libs-iso/TextUtil.mod b/gcc/m2/gm2-libs-iso/TextUtil.mod new file mode 100644 index 00000000000..6f6c02e68b1 --- /dev/null +++ b/gcc/m2/gm2-libs-iso/TextUtil.mod @@ -0,0 +1,42 @@ +IMPLEMENTATION MODULE TextUtil ; + +IMPORT IOChan, 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 ; + + +(* The following procedures do not read past line marks. *) + +PROCEDURE CharAvailable (cid: IOChan.ChanId) : BOOLEAN ; +BEGIN + RETURN( (IOChan.ReadResult (cid) = IOConsts.notKnown) OR + (IOChan.ReadResult (cid) = IOConsts.allRight) ) +END CharAvailable ; + + +PROCEDURE EofOrEoln (cid: IOChan.ChanId) : BOOLEAN ; +BEGIN + RETURN( (IOChan.ReadResult (cid) = IOConsts.endOfLine) OR + (IOChan.ReadResult (cid) = IOConsts.endOfInput) ) +END EofOrEoln ; + + +END TextUtil. |