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

Regex IO

DEFINITION MODULE RegexIO;

(* Regular Expression based IO *)


IMPORT FileIO;
IMPORT Regex;


TYPE
    Status = ( +FileIO.Status, invalidNFA );


(* ---------------------------------------------------------------------------
 * procedure:  RegexIO.ReadMatchingStr( file, automaton, str, status )
 * ---------------------------------------------------------------------------
 *
 * Matches the input stream at the current reading position of <file>  against
 * regular expression automaton <automaton>  and passes the matched portion of
 * the input back in <str>.  The reading position of <file> is advanced by the
 * number of octets read and the status is passed back in <status>. *)

PROCEDURE ReadMatchingStr ( file       : FileIO.File;
                            automaton  : Regex.NFA;
                            VAR str    : ARRAY OF CHAR;
                            VAR status : Status );


(* ---------------------------------------------------------------------------
 * procedure:  RegexIO.SkipMatchingStr( file, automaton, status )
 * ---------------------------------------------------------------------------
 *
 * Matches the input stream at the current reading position of <file>  against
 * regular expression automaton <automaton>  and skips  the matched portion of
 * the input.  The  reading position  of <file>  is advanced  by the number of
 * octets skipped and  the status is passed back in <status>. *)

PROCEDURE SkipMatchingStr ( file       : FileIO.File;
                            automaton  : Regex.NFA;
                            VAR status : Status );


(* ---------------------------------------------------------------------------
 * procedure:  RegexIO.WriteMatchingStr( file, automaton, str, status )
 * ---------------------------------------------------------------------------
 *
 * Matches string <str>  against regular expression automaton <automaton>  and
 * writes <str> to file <file>  if it matches.  The writing position of <file>
 * is advanced by the number of octets written  and  the status is passed back
 * in <status>. *)

PROCEDURE WriteMatchingStr ( file       : FileIO.File;
                             automaton  : Regex.NFA;
                             CONST str  : ARRAY OF CHAR;
                             VAR status : Status );

END RegexIO.