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

Ulm's Oberon Library:


CompilerErrors - standardized events for compilation errors


TYPE ErrorEvent = POINTER TO ErrorEventRec;
TYPE ErrorEventRec =
      loc1, loc2, reference: CompilerObjects.Location;
      longmsg: Streams.Stream;
VAR error: Events.EventType;

PROCEDURE Raise(errors: RelatedEvents.Object; at: CompilerObjects.Location; message: ARRAY OF CHAR);

PROCEDURE Open(VAR s: Streams.Stream); PROCEDURE At1(s: Streams.Stream; location: CompilerObjects.Location); PROCEDURE At2(s: Streams.Stream; location: CompilerObjects.Location); PROCEDURE Ref(s: Streams.Stream; location: CompilerObjects.Location); PROCEDURE AtObject1(s: Streams.Stream; object: CompilerObjects.Object); PROCEDURE AtObject2(s: Streams.Stream; object: CompilerObjects.Object); PROCEDURE RefObject(s: Streams.Stream; object: CompilerObjects.Object); PROCEDURE Close(s: Streams.Stream; errors: RelatedEvents.Object);

PROCEDURE GetSortedErrors(errors: RelatedEvents.Object; VAR it: Iterators.Iterator);


CompilerErrors provides standardized events for compilation errors that allow modules like Listers to generate integrated error listings.

As all error events generated by CompilerErrors are passed to RelatedEvents, an error object is needed that collects all error events, i.e. RelatedEvents.QueueEvents must be called for it. This object may be an otherwise empty object or any other extension of RelatedEvents.Object that is permitted to receive other error events as well.

Error events are created in a short and simple way by Raise, or, in case of more elaborate messages, by Open, various location referencing procedures, and Close. Finally, GetSortedErrors may be called to extract all compilation error events from errors (but leaving all other events), sorted by their primary location.

All error events generated by CompilerErrors have following components:

Shared event type that is always set to CompilerErrors.error.
Abbreviated error message of type Events.Message.
Primary location, always non-NIL. Used as key by GetSortedErrors.
Is set if two items belong to this error event. May be NIL. loc2 is expected to be close to loc1 and must belong to the same source. Example: Two expressions combined by an operator that are not compatible to each other.
A more distant location that is given as reference. It may even belong to another source as loc1. May be NIL. Example: First declaration in case of multiple declarations.
Non-abbreviated error message.

Raise creates a simple error event referencing just one location and giving a message.

Open creates a stream where the error message may be written to and which, in addition, supports following operations: At1, At2, and Ref set the primary, secondary, and reference location, respectively. AtObject1, AtObject2, and RefObject work similarly but take the location from object.loc instead. Note that either At1 or AtObject1 must be called. If the error message has been printed to s and all locations are defined, Close generates the error event and relates it to errors.

GetSortedErrors removes all error events that are extensions of CompilerErrors.ErrorEvent from errors and returns them in sorted order (by their primary location) through it.


CompilerErrors does not generate any additional error events on its own. Assertions fail in case of


base type of locations
general interface for error listers
object-oriented event handling


CompilerErrors does not offer a pretty-printing interface procedure using Errors.AssignWriteProcedure (see Errors) as this task is better left to listing generators.
Edited by: borchert, last change: 2000/05/28, revision: 1.1, converted to HTML: 2000/05/28

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