Oberon || Library || Module Index || Search Engine || Definition || Module

Ulm's Oberon Library:


Comments - comment stripping input filter


CONST delimlen = 4;
TYPE Delimiter = ARRAY delimlen OF CHAR;
TYPE Syntax = POINTER TO SyntaxRec;
TYPE SyntaxRec =
   RECORD                   (* comment syntax *)
      start: Delimiter;     (* starts a comment *)
      inclStart: BOOLEAN;   (* belongs start to the comment? *)
      end: Delimiter;       (* ends a comment *)
      inclEnd: BOOLEAN;     (* belongs end to the comment? *)
      nested: BOOLEAN;      (* may comments be nested? *)

PROCEDURE Open(VAR s: Streams.Stream; input: Streams.Stream; commentSyntax: Syntax);


Comments removes comments of a given syntax from an input stream.

Open returns a newly opened stream s for reading which gets its input from input except that all comments are stripped off. The comment syntax is given by syntax: comments are delimited by start and end. inclStart and inclEnd determine whether the delimiters belong to the comment or not. Comments may be nested, if nested is set to TRUE.

Two Examples:

|start	  |  (*	      #		  |
|inclStart|  TRUE     TRUE	  |
|end	  |  *)	      ASCII.nl	  |
|inclEnd  |  TRUE     FALSE	  |
|nested	  |  TRUE     FALSE	  |


Error events which are related to input are being forwarded to the event queue of s.


RelatedEvents, Streams


There exist languages whose comment syntax is not covered by this module, e.g. ISO-Pascal or C++. In general, these cases can be solved by concatenating Comments filters.
Edited by: borchert, last change: 91/11/18, revision: 1.2, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module