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 LONGBITSET

Spec.IOModuleLONGBITSET History

Hide minor edits - Show changes to output

2010-05-24 12:44 by benjk -
Added lines 1-41:
[@DEFINITION MODULE LONGBITSET;

(* I/O Module for Type LONGBITSET *)

FROM FileIO IMPORT File;

(* The EBNF for the textual representation of LONGBITSET 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 LONGBITSET type. *)

PROCEDURE Read ( infile : File; VAR set : LONGBITSET );
(* Reads the textual representation of a LONGBITSET 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 LONGBITSET
  argument. *)

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

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

END LONGBITSET.@]