1 (* Library module defined by the International Standard
2 Information technology - programming languages
3 BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language.
5 Copyright ISO/IEC (International Organization for Standardization
6 and International Electrotechnical Commission) 1996-2021.
8 It may be freely copied for the purpose of implementation (see page
9 707 of the Information technology - Programming languages Part 1:
10 Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *)
12 DEFINITION MODULE WholeConv;
14 (* Low-level whole-number/string conversions *)
20 ConvResults = ConvTypes.ConvResults;
21 (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)
23 PROCEDURE ScanInt (inputCh: CHAR;
24 VAR chClass: ConvTypes.ScanClass;
25 VAR nextState: ConvTypes.ScanState) ;
26 (* Represents the start state of a finite state scanner for signed
27 whole numbers - assigns class of inputCh to chClass and a
28 procedure representing the next state to nextState.
31 PROCEDURE FormatInt (str: ARRAY OF CHAR): ConvResults;
32 (* Returns the format of the string value for conversion to INTEGER. *)
34 PROCEDURE ValueInt (str: ARRAY OF CHAR): INTEGER;
35 (* Returns the value corresponding to the signed whole number string
36 value str if str is well-formed; otherwise raises the WholeConv
40 PROCEDURE LengthInt (int: INTEGER): CARDINAL;
41 (* Returns the number of characters in the string representation of
45 PROCEDURE ScanCard (inputCh: CHAR; VAR chClass: ConvTypes.ScanClass;
46 VAR nextState: ConvTypes.ScanState);
47 (* Represents the start state of a finite state scanner for unsigned
48 whole numbers - assigns class of inputCh to chClass and a procedure
49 representing the next state to nextState.
52 PROCEDURE FormatCard (str: ARRAY OF CHAR): ConvResults;
53 (* Returns the format of the string value for conversion to CARDINAL.
56 PROCEDURE ValueCard (str: ARRAY OF CHAR): CARDINAL;
57 (* Returns the value corresponding to the unsigned whole number string
58 value str if str is well-formed; otherwise raises the WholeConv
62 PROCEDURE LengthCard (card: CARDINAL): CARDINAL;
63 (* Returns the number of characters in the string representation of
67 PROCEDURE IsWholeConvException (): BOOLEAN;
68 (* Returns TRUE if the current coroutine is in the exceptional execution
69 state because of the raising of an exception in a routine from this
70 module; otherwise returns FALSE.