pobs
Interface PErrorHandler

All Known Implementing Classes:
PDefaultErrorHandler

public interface PErrorHandler

Interface of all error handlers. An error handler is called if a parser found a mismatch.

Author:
Franz-Josef Elmer

Method Summary
 java.lang.String createErrorMessage(PScanner input)
          Creates a human readable error message using the specified input to get reasonable error positions (like line number and column number).
 long getErrorPosition()
          Gets the actual error position.
 void notifySemanticError(long position, java.lang.RuntimeException exception)
          Notifies the error handler that a semantic error occured during execution of a PAction attached to the specified parser.
 void notifySyntaxError(long position, PParser parser)
          Notifies the error handler that a syntax error occured for the specified parser at the specified parsing position.
 boolean semanticErrorOccured()
          Returns true if at least one semantic error occured.
 

Method Detail

notifySyntaxError

public void notifySyntaxError(long position,
                              PParser parser)
Notifies the error handler that a syntax error occured for the specified parser at the specified parsing position. This method might be called several times even if complete parsing is successful.

From both types of notifiction events concrete implementations must find out where the actual error occured and what is its reason. For the later PParser.getErrorInfo() can be used.

Parameters:
position - Parsing position.
parser - Parser who has detected a syntax error.

notifySemanticError

public void notifySemanticError(long position,
                                java.lang.RuntimeException exception)
Notifies the error handler that a semantic error occured during execution of a PAction attached to the specified parser. This method might be called several times even if complete parsing is successful.

From both types of notifiction events concrete implementations must find out where the actual error occured and what is its reason. For the later exception.getMessage() can be used.

Parameters:
position - Parsing position.
exception - Exception thrown by the PAction instance.

getErrorPosition

public long getErrorPosition()
Gets the actual error position.

Returns:
actual parsing position where the error occured.

semanticErrorOccured

public boolean semanticErrorOccured()
Returns true if at least one semantic error occured.


createErrorMessage

public java.lang.String createErrorMessage(PScanner input)
Creates a human readable error message using the specified input to get reasonable error positions (like line number and column number).

Parameters:
input - Input source of parsing.
Returns:
error message.