Article View: comp.lang.modula2
Article #3751Number 2 of five Mailings of Proposed BSI Standard I/O Library
From: Roger Henry
Date: Wed, 19 Aug 1987 16:31
Date: Wed, 19 Aug 1987 16:31
132 lines
4740 bytes
4740 bytes
**************
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.
Technical Details
Message-ID:
<8708191646.AA11763@cayuga.cs.rochester.edu>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!ucla-cs!zen!ucbvax!computer-science.nottingham.ac.UK!rbhShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!ucla-cs!zen!ucbvax!computer-science.nottingham.ac.UK!rbh From: rbh@computer-science.nottingham.ac.UK (Roger Henry) Newsgroups: comp.lang.modula2 Subject: Number 2 of five Mailings of Proposed BSI Standard I/O Library Message-ID: <8708191646.AA11763@cayuga.cs.rochester.edu> Date: Wed, 19-Aug-87 12:31:00 EDT Article-I.D.: cayuga.8708191646.AA11763 Posted: Wed Aug 19 12:31:00 1987 Date-Received: Sat, 22-Aug-87 02:04:28 EDT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 132