INTERFACE FGet; (* "Lex"-like procedures that die instead of raising Lex.Error. *) IMPORT Rd, Lex; CONST Blanks = Lex.Blanks; Spaces = SET OF CHAR{' ', '\t'}; PROCEDURE Skip(rd: Rd.T; READONLY cs: SET OF CHAR := Blanks); PROCEDURE Match(rd: Rd.T; t: TEXT); PROCEDURE EOL(rd: Rd.T); (* Equivalent to Skip(rd, Spaces); Match(rd, "\n"). *) PROCEDURE Colon(rd: Rd.T); (* Performs Skip(rd, Spaces); Match(rd, ":"); then skips one space or tab, if present. *) (* The procedures below will skip spaces or tabs (but not newlines, unlike their "Lex" counterparts) before the desired input. Note that "FGet.Char" will skip spaces and tabs, too. Unlike "Lex.Bool", "FGet.Bool" will accept a single character: 'T','t','1' for TRUE, 'F','f','0' for FALSE. Anything else is an error. If the reader contains "TRUE" or "FALSE", only the first letter will be consumed. *) PROCEDURE Char(rd: Rd.T): CHAR; PROCEDURE Bool(rd: Rd.T): BOOLEAN; PROCEDURE Int(rd: Rd.T): INTEGER; PROCEDURE Real(rd: Rd.T): REAL; PROCEDURE LongReal(rd: Rd.T): LONGREAL; PROCEDURE Test(rd: Rd.T; c: CHAR): BOOLEAN; (* Skips any blanks or tabs, then checks whether the next character is "c". If it is, consumes that character and returns TRUE. If it is something else (including end-of-line or end-of-file), returns FALSE and leaves the character there. *) END FGet. (* Last edited on 2000-01-13 09:23:18 by stolfi *)