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


Ulm's Oberon Library:
Comments


NAME

Comments - comment stripping input filter

SYNOPSIS

CONST delimlen = 4;
TYPE Delimiter = ARRAY delimlen OF CHAR;
TYPE Syntax = POINTER TO SyntaxRec;
TYPE SyntaxRec =
   RECORD                   (* comment syntax *)
      (Objects.ObjectRec)
      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? *)
   END;


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

DESCRIPTION

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:

___________________________________
|_________|__Oberon___Bourne_Shell|
|start	  |  (*	      #		  |
|inclStart|  TRUE     TRUE	  |
|end	  |  *)	      ASCII.nl	  |
|inclEnd  |  TRUE     FALSE	  |
|nested	  |  TRUE     FALSE	  |
|_________|_______________________|

DIAGNOSTICS

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

SEE ALSO

RelatedEvents, Streams

BUGS

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