rbh@computer-science.nottingham.ac.UK (Roger Henry) (08/19/87)
**************
Number two of five mailings of the Proposed BSI I/O Library Def Mods
Please see an earlier message for the complete list
**************
::::::::::::::
CharIs.def
::::::::::::::
DEFINITION MODULE CharIs;
(* Proposed BSI Standard Modula-2 I/O Library
* Copyright Roger Henry, University of Nottingham
* Version WG/2.0, August 17th 1987
* Permission is given to copy this Definition Module, with the
* copyright notice intact, for the purposes of evaluation and test.
* At the stage of a formal draft standard, Copyright will be transferred
* to BSI (and through BSI to other recognised standards bodies).
* Status: For review by BSI/IST/5/13
*)
(*
Predicates for character class testing
*)
(*
EXPORT QUALIFIED
Nl, Digit, Space, Sign, Upper, Lower;
*)
PROCEDURE Nl(ch: CHAR): BOOLEAN;
(* post : returns TRUE iff "ch" is the implementations new line character *)
PROCEDURE Digit(ch: CHAR): BOOLEAN;
(* post : returns TRUE iff "ch" is a decimal digit *)
PROCEDURE Space(ch: CHAR): BOOLEAN;
(* post : returns TRUE iff "ch" is a whitespace character (space or tab) *)
PROCEDURE Sign(ch: CHAR): BOOLEAN;
(* post : returns TRUE iff "ch" is + or - sign *)
PROCEDURE Upper(ch: CHAR): BOOLEAN;
(* post : returns TRUE iff "ch" is an upper case letter *)
PROCEDURE Lower(ch: CHAR): BOOLEAN;
(* post : returns TRUE iff "ch" is a lower case letter *)
END CharIs.
::::::::::::::
IntConv.def
::::::::::::::
DEFINITION MODULE IntConv;
(* Proposed BSI Standard Modula-2 I/O Library
* Copyright Roger Henry, University of Nottingham
* Version WG/2.0, August 17th 1987
* Permission is given to copy this Definition Module, with the
* copyright notice intact, for the purposes of evaluation and test.
* At the stage of a formal draft standard, Copyright will be transferred
* to BSI (and through BSI to other recognised standards bodies).
* Status: For review by BSI/IST/5/13
*)
(*
Integer/String conversions.
*)
FROM ConvTypes IMPORT
ConvResults, Justifications;
(*
EXPORT QUALIFIED
FromStr, ToStr, ToField;
*)
(* well-formed character representation:
any number of leading white-space characters but not NlCh,
optional +/- sign,
followed immediately by a sequence of decimal digits,
terminated by the first non-digit or end of array.
*)
PROCEDURE FromStr(
VAR str: ARRAY OF CHAR;
VAR index: CARDINAL;
VAR int: INTEGER;
VAR res: ConvResults
);
(* pre : "index" gives position from which to start conversion *)
(* post : "res" gives result of conversion *)
(* iff "res" is goodValue *)
(* converted value stored in "int", and *)
(* "index" updated to position after last character of integer *)
(* no specified field width:
leading sign for negative integers, space for non-negative,
0C terminator stored if room in array.
*)
PROCEDURE ToStr(
int: INTEGER;
VAR str: ARRAY OF CHAR;
VAR index: CARDINAL
);
(* pre : "index" is position relative to start of "str" at which to *)
(* store character representation of "int" *)
(* post : "index" = old "index" + number of characters in representation. *)
(* Characters stored at corresponding positions in "str" if within *)
(* the array bounds, including 0C at str[index]. *)
(* with specified field width:
leading sign for negative integers, space for non-negative,
left, centre, or right justified within the given minimum field width.
In the special case of a specified field width of 0, the leading space
for non-negative values shall be suppressed.
*)
PROCEDURE ToField(
int: INTEGER;
VAR str: ARRAY OF CHAR;
VAR index: CARDINAL;
width: CARDINAL;
where: Justifications
);
(* pre : "index" is position relative to start of "str" at which to *)
(* store character representation of "int" *)
(* post : "index" = old "index" + number of characters in representation. *)
(* Characters stored at corresponding positions in "str" if within *)
(* the array bounds. *)
END IntConv.