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 WORD

DEFINITION MODULE WORD;

(* I/O Module for Type WORD *)

FROM SYSTEM IMPORT WORD;
FROM FileIO IMPORT File;

(* EBNF of the textual representation of WORD values:

    wordValue :
       digitGroup digitGroup ( groupSeparator? digitGroup digitGroup )* ;
    digitGroup : base16Digit base16Digit ;
    base16Digit : "0" .. "9" | "A" .. "F" ;
    groupSeparator : " " | "." ;

    static semantics:

    WORD values are always left padded with zeroes to the length
    required to represent the maximum value of type WORD. *)

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

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

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

END WORD.