Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

IO Module BOOLEAN

Spec.IOModuleBOOLEAN History

Hide minor edits - Show changes to markup

2010-05-24 12:43 by benjk -
Changed lines 3-4 from:

(* File based I/O for type BOOLEAN *)

to:

(* I/O Module for Type BOOLEAN *)

Changed line 7 from:

(* The EBNF of values of type BOOLEAN is as follows:

to:

(* EBNF of the textual representation of BOOLEAN values:

Changed lines 9-23 from:
    trueFalseFormat : 'TRUE' | 'FALSE' ;
    yesNoFormat : 'YES' | 'NO' ; *)

PROCEDURE Read( infile : File; VAR b : BOOLEAN ); (* If possible, does a Read Rest Line? on the input file and assigns the value determined

   from the first letter of the string obtained to b. If the first letter is "Y", "y", "T", or "t",
   the value assigned is TRUE. Otherwise it is FALSE. The file status is set to the value
   allRight, endOfLine, or endOfInput. *)

PROCEDURE Write( outfile : File; b : BOOLEAN ); (* Writes the value of b in true-false format to output stream outfile. *)

PROCEDURE Write F?( outfile : File; fmtStr : ARRAY OF CHAR; items : CARDINAL; VARIADIC v[items] OF b : BOOLEAN ); (* Writes a formatted textual representation of one or more BOOLEAN values to output stream outfile. The value

   of parameter items is calculated and inserted automatically. The output format is determined by fmtStr. *)
to:
    trueFalseFormat : "TRUE" | "FALSE" ;
    yesNoFormat : "YES" | "NO" ; *)

PROCEDURE Read ( infile : File; VAR b : BOOLEAN ); (* Reads the textual representation of a BOOLEAN value from stream infile

   - any leading whitespace is skipped
   - any remaining characters that are part of the value being read are
     removed from infile
   - the textual representation of the value read is assigned to b
   - the file status is set to any of:
     success, outOfRange, wrongFormat, endOfLine, or endOfInput. This
   procedure is substituted for invocations of READ with a BOOLEAN argument.*)

PROCEDURE Write ( outfile : File; b : BOOLEAN ); (* Writes the textual representation of BOOLEAN b to stream outfile. This

   procedure is substituted for invocations of WRITE with a BOOLEAN argument.*)

PROCEDURE Write F? ( outfile : File;

                   CONST fmtStr : ARRAY OF CHAR;
                   items        : VARIADIC OF BOOLEAN );

(* Writes a formatted textual representation of one or more BOOLEAN values to

   output stream outfile. The output format is determined by fmtStr. This
   procedure is substituted for invocations of WRITEF with one or more
   BOOLEAN arguments. *)