The Scan
interface provides procedures for reading strings,
booleans, integers, and floating-point numbers from a text string.
Similar functionality on readers is availble from the Lex
interface.
INTERFACEEach of these procedures parses a string of characters and converts it to a binary value. Leading and trailing blanks (ie. characters inScan ; IMPORT Word, Lex, FloatMode;
Lex.Blanks
) are ignored. Lex.Error
is raised if the first
non-blank substring is not generated by the corresponding Lex
grammar or if there are zero or more than one non-blank substrings.
FloatMode.Trap
is raised as per Lex
.
PROCEDURE Bool(txt: TEXT): BOOLEAN RAISES {Lex.Error}; PROCEDURE Int(txt: TEXT; defaultBase: [2..16] := 10): INTEGER RAISES {Lex.Error, FloatMode.Trap}; PROCEDURE Unsigned(txt: TEXT; defaultBase: [2..16] := 16): Word.T RAISES {Lex.Error, FloatMode.Trap}; PROCEDURE Real(txt: TEXT): REAL RAISES {Lex.Error, FloatMode.Trap}; PROCEDURE LongReal(txt: TEXT): LONGREAL RAISES {Lex.Error, FloatMode.Trap}; PROCEDURE Extended(txt: TEXT): EXTENDED RAISES {Lex.Error, FloatMode.Trap}; END Scan.