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 LONGCARD

DEFINITION MODULE LONGCARD;

(* I/O Module for Type LONGCARD *)

FROM FileIO IMPORT File;

(* EBNF of the textual representation of LONGCARD values:
    cardinalValue : simpleFormat |
        cBase16Format | m2Base16Format | universalFormat ;
    simpleFormat : decimalDigit+ ;
    cBase16Format : "0x" base16Digit+ ;
    m2Base16Format : "0" base16Digit+ "H" ;
    universalFormat :  sign? fillChar* numeral ;
    sign : "+" ;
    fillChar : " " | "*" | "0" ;
    numeral : leadDigitGroup ( separator? digitGroup )* ;
    separator : " " | "." | "," ;
    leadDigitGroup : decimalDigit decimalDigit? decimalDigit? ;
    digitGroup : decimalDigit decimalDigit decimalDigit ;
    decimalDigit  : "0" .. "9" ;
    base16Digit : decimalDigit | "A" .. "F" ; *)

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

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

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

END LONGCARD.