semanticAnalyzer
Class SemanticError

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by semanticAnalyzer.SemanticError
All Implemented Interfaces:
java.io.Serializable

public class SemanticError
extends java.lang.Exception

This class is used as a general exception class for whatever semantic error can occur. Feel free to derive specialized classes or use only this one. Whenever this class is instanciated, the static error-count will be incremented to keep track of the total number of errors. After semantic analysis, exitIfErrorOccured() can be used to generate a final error message and to reset the counter.

See Also:
Serialized Form

Constructor Summary
SemanticError(java.lang.String errorMessage)
           
SemanticError(java.lang.String errorMessage, AbstractSymbol filename, TreeNode t)
           
SemanticError(java.lang.String errorMessage, Class_ c)
           
 
Method Summary
static void exitIfErrorsOccured()
          Checks if any errors occured.
protected static java.lang.String makeErrorMessage(AbstractSymbol filename, TreeNode t)
          Returns a string containing the file name and the line number of the given tree node.
protected static java.lang.String makeErrorMessage(Class_ c)
          Returns an error-information-string with the line number and file name of the given class.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SemanticError

public SemanticError(java.lang.String errorMessage)

SemanticError

public SemanticError(java.lang.String errorMessage,
                     Class_ c)

SemanticError

public SemanticError(java.lang.String errorMessage,
                     AbstractSymbol filename,
                     TreeNode t)
Method Detail

makeErrorMessage

protected static java.lang.String makeErrorMessage(Class_ c)
Returns an error-information-string with the line number and file name of the given class.

Parameters:
c - the class
Returns:
a string which can be used as (part of) the error message

makeErrorMessage

protected static java.lang.String makeErrorMessage(AbstractSymbol filename,
                                                   TreeNode t)
Returns a string containing the file name and the line number of the given tree node.

Parameters:
filename - the file name
t - the tree node
Returns:
a string which can be used as (part of) the error message

exitIfErrorsOccured

public static void exitIfErrorsOccured()
                                throws SemanticError
Checks if any errors occured. If so, an information is printed and the program is stopped.

Throws:
SemanticError