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 BYTE

Spec.IOModuleBYTE History

Hide minor edits - Show changes to markup

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

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

to:

(* I/O Module for Type BYTE *)

Changed lines 8-18 from:

(* The EBNF for the textual representation of values of type BYTE is as follows:

    byteValue : simpleFormat | cLiteralFormat | m2LiteralFormat | m2binaryLiteralFormat ;
    simpleFormat : ( sedecimalDigit sedecimalDigit )+ ;
    cLiteralFormat : '0x' simpleFormat ;
    m2LiteralFormat : '0' simpleFormat 'H' ;
    m2binaryLiteralFormat : ( bit bit bit bit bit bit bit bit )+ 'B' ;
    sedecimalDigit : '0' .. '9' | 'A' .. 'F' ;
    bit : '0' | '1' ; *)

PROCEDURE Read( infile : File; VAR n : BYTE ); (* Reads the textual representation of an BYTE value in simple format from input stream infile

to:

(* EBNF of the textual representation of BYTE values:

    byteValue : simpleFormat |
        cBase16Format | m2Base2Format | m2Base16Format ;
    simpleFormat : ( base16Digit base16Digit )+ ;
    cBase16Format : "0x" simpleFormat ;
    m2Base16Format : "0" simpleFormat "H" ;
    m2Base2Format : ( bit bit bit bit bit bit bit bit )+ "B" ;
    base16Digit : "0" .. "9" | "A" .. "F" ;
    bit : "0" | "1" ; *)

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

Changed lines 21-30 from:
   - any remaining characters that are part of the numeral being read are removed from infile
   - the numeric value of the numeral string read is assigned to the variable passed in for n
   - the file status is set to any of allRight, outOfRange, wrongFormat, endOfLine, or endOfInput *)

PROCEDURE Write( outfile : File; n : BYTE ); (* Writes the textual representation of value n in simple format to output stream outfile *)

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

   of parameter items is calculated and inserted automatically. The output format is determined by fmtStr. *)
to:
   - 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 BYTE argument. *)

PROCEDURE Write ( outfile : File; b : BYTE ); (* Writes the value of BYTE b in simple format to stream outfile. This

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

PROCEDURE Write F? ( outfile : File;

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

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

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