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 BITSET

DEFINITION MODULE BITSET;

(* I/O Module for Type BITSET *)

FROM FileIO IMPORT File;

(* The EBNF for the textual representation of BITSET values is:
    bitsetValue : simpleFormat | compactFormat | bitGroupFormat ;
    simpleFormat : bit+ ;
    compactFormat : base16Digit+ ;
    bitGroupFormat : "{" bit+ ( groupSeparator? bit+ )* "}" ;
    groupSeparator : " " | "." ;
    bit  : "0" | "1" ;
    base16Digit : "0" .. "9" | "A" .. "F" ;
   The number of bits shown is equal to the bitwidth of the BITSET type. *)

PROCEDURE Read ( infile : File; VAR set : BITSET );
(* Reads the textual representation of a BITSET 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 set
   - the file status is set to any of:
     success, outOfRange, wrongFormat, endOfLine, or endOfInput. This
   procedure is substituted for invocations of READ with a BITSET argument. *)

PROCEDURE Write ( outfile : File; CONST set : BITSET );
(* Writes the value of BITSET set in simple format to stream outfile. This
   procedure is substituted for invocations of WRITE with a CHARSET argument.*)

PROCEDURE WriteF ( outfile      : File;
                   CONST fmtStr : ARRAY OF CHAR;
                   items        : VARIADIC OF CONST BITSET );
(* Writes a formatted textual representation of one or more BITSET values to
   output stream outfile. The output format is determined by fmtStr. This
   procedure is substituted for invocations of WRITEF with one or more
   BITSET arguments. *)

END BITSET.