edu.umd.cfar.lamp.viper.util
Interface ErrorWriter

All Known Implementing Classes:
LimitationsParser, VReader

public interface ErrorWriter

This interface should be used by all classes that perform parsing functions to write compiler-style errors. It is a set of standard error printing functions. Classes that generate the errors should use specify the column numbers if possible, as it makes the errors easier to understand. I would recommend that implementors use the StringHelp.underliner() to implement the *AtLineNumber functions.

Author:
David Mihalcik

Method Summary
 void printError(java.lang.String message)
          Print an error.
 void printError(java.lang.String message, int start, int stop)
          Print an error at a specific place inside the current line.
 void printErrorAtLineNumber(java.lang.String message, int lineNum)
          Print an error at a a specific line number.
 void printErrorTotals()
          Print out the error count totals, usually in the form x Errors, y Warnings, z General Errors
 void printGeneralError(java.lang.String message)
          Prints an error that is unconnected to a line number.
 void printWarning(java.lang.String message)
          Print an warning.
 void printWarning(java.lang.String message, int start, int stop)
          Print an warning at a specific place inside the current line.
 void printWarningAtLineNumber(java.lang.String message, int lineNum)
          Print an warning at a a specific line number.
 void setOutput(java.io.PrintWriter pw)
          Specify where to send the output.
 

Method Detail

setOutput

public void setOutput(java.io.PrintWriter pw)
Specify where to send the output. Usually, it is System.err, but it could be a log file.

Parameters:
pw - A PrintWriter associated with the proper stream.

printError

public void printError(java.lang.String message,
                       int start,
                       int stop)
Print an error at a specific place inside the current line. Errors are something that prevents the file from being understood usefully.

Parameters:
message - the message to print with the error
start - the column where the error begins
stop - the column where the error ends

printError

public void printError(java.lang.String message)
Print an error. Errors are something that prevents the file from being understood usefully. This is used when the error refers to the whole line or the parser is unable to determine where the error occurred in the line.

Parameters:
message - the message to print with the error
See Also:
printError(String message, int start, int stop)

printErrorAtLineNumber

public void printErrorAtLineNumber(java.lang.String message,
                                   int lineNum)
Print an error at a a specific line number. Errors are something that prevents the file from being understood usefully. This is used when the error refers to a line that has already been parsed, but the has only now been proven incorrect.

Parameters:
message - The message to print with the error.
lineNum - The line where the error occured.

printWarning

public void printWarning(java.lang.String message,
                         int start,
                         int stop)
Print an warning at a specific place inside the current line. A warning may make the parser generate an improper representation or otherwise misinterpret the data, but not necessarily.

Parameters:
message - the message to print with the warning
start - the column where the questionable part begins
stop - the column where the questionable part ends

printWarning

public void printWarning(java.lang.String message)
Print an warning. A warning may make the parser generate an improper representation or otherwise misinterpret the data, but not necessarily. This is used when the error refers to the whole line or the parser is unable to determine where the fault occurred in the line.

Parameters:
message - the message to print with the warning

printWarningAtLineNumber

public void printWarningAtLineNumber(java.lang.String message,
                                     int lineNum)
Print an warning at a a specific line number. A warning may make the parser generate an improper representation or otherwise misinterpret the data, but not necessarily. This is used when the error refers to a line that has already been parsed, but the has only now been discovered to be invalid.

Parameters:
message - the message to print with the warning
lineNum - The line where the error occured.

printGeneralError

public void printGeneralError(java.lang.String message)
Prints an error that is unconnected to a line number. For example, error opening file, I/O exception, etc

Parameters:
message - the message to print with the warning

printErrorTotals

public void printErrorTotals()
Print out the error count totals, usually in the form
  x Errors, y Warnings, z General Errors