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

Scanner

Spec.Scanner History

Hide minor edits - Show changes to output

2010-05-24 12:38 by benjk -
Added lines 1-36:
[@DEFINITION MODULE Scanner;

(* Primitives for Scanning Text Files *)


FROM FileIO IMPORT File;
IMPORT CHARSET;


(* Read text *)

PROCEDURE ReadStrWithChars ( file : File; VAR s : ARRAY OF CHAR;
                            CONST trimLeading, charsToRead : CHARSET );
(* Reads a string from <file> and passes it back in <s>. Any leading
  characters in set <trimLeading> are ignored. Characters are read
  until the first character not in set <charsToRead> is found. *)

PROCEDURE ReadStrToDelim ( file : File; VAR s : ARRAY OF CHAR;
                          CONST trimLeading, delimiterChars : CHARSET );
(* Reads a string from <file> and passes it back in <s>. Any leading
  characters in set <trimLeading> are ignored. Characters are read
  until the first delimiter character is found. Delimiter characters
  are defined by set <delimiterChars>. *)


(* Skip text *)

PROCEDURE SkipChars ( file : File; CONST skipChars : CHARSET );
(* Read and ignore any characters up to the first character
  not in set <skipChars>. *)

PROCEDURE SkipTo ( File : File; CONST skipToChar : CHARSET );
(* Read and ignore all characters up to but excluding the first
  character that is a member of set <skipToChar>. *)

END Scanner.@]