REPORTINFO(5)

Table of Contents

Name

reportinfo
reports a normal message
reporterror
reports an error and increments error count
reportwarning
reports a warning and increments warning count
agoutput
outputs a message to agoutfile
agoutfile
output file used by agoutput (default is stdout)
agexit
exits an SDTool
errorcount
number of reported errors
warningcount
number of reported warnings
maxerrors
number of reported errors before aborting the SDTool
maxwarnings
number of warnings printed
Agerror
parameter value to agoutput specifying an error message Agwarning parameter value to agoutput specifying a warning message
Aginfo
parameter value to agoutput specifying an information message

Synopsis

VOID reportinfo(message [, arg] ... )
STRING message;
STRING arg;
VOID reporterror(tree, message [, arg] ... ) ANY tree;
STRING message;
STRING arg;
VOID reportwarning(tree, message [, arg] ... ) ANY tree;
STRING message;
STRING arg;
VOID agoutput(kind, tree, message [, arg] ... ) int kind;
ANY tree;
STRING message;
STRING arg;
VOID agexit(num);
int num;
int errorcount, warningcount, maxerrors, maxwarnings; FILE *agoutfile = stdout;

Description

These components of the run-time library provide a uniform way for SDTools to write output messages. Normal messages, error messages and warning messages are all supported.

Routine reportinfo sends normal messages to an SDTool's output. The interface to reportinfo is the same as that of the C library routine printf.

Routine reporterror sends error messages to an SDTool's output. The message and arg arguments are the same as in reportinfo. The tree argument may be used to associate the error message with a location in the parse tree. If the

tree argument is a parse tree node then the error message will automatically specify the line and column numbers in the specification file where the text associated with that parse tree node begins. And if this specification file is different from the the file name in sourcename (see VERSION(5) ) then the name of the file is printed also. If the tree argument is NULL then no line or column numbers or file name is printed. The global variable errorcount is incremented each time reporterror is called. If errorcount eventually exceeds the value in global variable maxerrors, then agexit is called and the SDTool terminates. By default errorcount and maxerrors are initialized to zero and 50 respectively; these values can be changed in the startcode section (see STARTCODE(2) ).

Routine reportwarning sends warning messages to an SDTool's output. The arguments are used identically as in reporterror. The global variable warningcount is incremented each time reportwarning is called. If warningcount eventually exceeds the value in global variable maxwarnings, then the SDTool continues execution, but it will not print any more warning messages. A message at the end of SDTool execution will write the total number of warnings. By default warningcount and maxwarnings are initialized to zero and 50 respectively.

A newline is appended to the message by all three of reporterror, reportwarning and reportinfo.

Reporterror, reportwarning and reportinfo all call agoutput. agoutput can be easily replaced by a custom routine to redirect or reformat all output from an SDTool. The first parameter to agoutput specifies the kind of message; the possible values are Agerror, Agwarning and Aginfo.

agoutput writes all messages to the file in global variable agoutfile. By default this file is standard output, but this can be changed by the SDTool builder. For example, the following statement:
agoutfile = stderr;
could be placed in the startcode section to direct all output from the SDTool to standard error.

The routine agexit terminates an SDTool. agexit writes a final message, if necessary, about the number of warning messages. As its last action, agexit calls the standard exit routine and passes the num parameter to it. This provides a uniform way to abort an SDTool with an exit code. A good value to use for num is the value of errorcount; the exit code then specifies the number of errors reported by the SDTool. num should be zero for a normal, error-free

exit.

Example

%declare
int temp;
BOOLEAN undeclared(); /* checks for undeclared identifiers */ %startcode
maxerrors = 10; /* change default from 50 to 10 */ maxwarnings = 100; /* change default from 50 to 100 */ %middlecode
FORALL(x,ID,top,Id) LOOP
if (undeclared(x))
reporterror(x,"Undeclared variable: %s",tok(x)); ENDLOOP

See Also

VERSION(5)


© 1990 Lucent Technologies, Inc
© 1998 Harmony Software, Inc