net.percederberg.grammatica.parser
Class ParseException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--net.percederberg.grammatica.parser.ParseException
All Implemented Interfaces:
java.io.Serializable

public class ParseException
extends java.lang.Exception

A parse exception.

Version:
1.0
Author:
Per Cederberg,
See Also:
Serialized Form

Field Summary
static int ANALYSIS_ERROR
          The analysis error type constant.
static int INTERNAL_ERROR
          The internal error type constant.
static int INVALID_TOKEN_ERROR
          The invalid token error type constant.
static int IO_ERROR
          The I/O error type constant.
static int UNEXPECTED_CHAR_ERROR
          The unexpected character error type constant.
static int UNEXPECTED_EOF_ERROR
          The unexpected end of file error type constant.
static int UNEXPECTED_TOKEN_ERROR
          The unexpected token error type constant.
 
Constructor Summary
ParseException(int type, java.lang.String info, java.util.ArrayList details, int line, int column)
          Creates a new parse exception.
ParseException(int type, java.lang.String info, int line, int column)
          Creates a new parse exception.
 
Method Summary
 int getColumn()
          Returns the column number where the error occured.
 java.util.ArrayList getDetails()
          Returns the additional detailed error information.
 int getErrorType()
          Returns the error type.
 java.lang.String getInfo()
          Returns the additional error information.
 int getLine()
          Returns the line number where the error occured.
 java.lang.String getMessage()
          Returns a default error message.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INTERNAL_ERROR

public static final int INTERNAL_ERROR
The internal error type constant. This type is only used to signal an error that is a result of a bug in the parser or tokenizer code.

See Also:
Constant Field Values

IO_ERROR

public static final int IO_ERROR
The I/O error type constant. This type is used for stream I/O errors.

See Also:
Constant Field Values

UNEXPECTED_EOF_ERROR

public static final int UNEXPECTED_EOF_ERROR
The unexpected end of file error type constant. This type is used when end of file is encountered instead of a valid token.

See Also:
Constant Field Values

UNEXPECTED_CHAR_ERROR

public static final int UNEXPECTED_CHAR_ERROR
The unexpected character error type constant. This type is used when a character is read that isn't handled by one of the token patterns.

See Also:
Constant Field Values

UNEXPECTED_TOKEN_ERROR

public static final int UNEXPECTED_TOKEN_ERROR
The unexpected token error type constant. This type is used when another token than the expected one is encountered.

See Also:
Constant Field Values

INVALID_TOKEN_ERROR

public static final int INVALID_TOKEN_ERROR
The invalid token error type constant. This type is used when a token pattern with an error message is matched. The additional information provided should contain the error message.

See Also:
Constant Field Values

ANALYSIS_ERROR

public static final int ANALYSIS_ERROR
The analysis error type constant. This type is used when an error is encountered in the analysis. The additional information provided should contain the error message.

See Also:
Constant Field Values
Constructor Detail

ParseException

public ParseException(int type,
                      java.lang.String info,
                      int line,
                      int column)
Creates a new parse exception.

Parameters:
type - the parse error type
info - the additional information
line - the line number, or -1 for unknown
column - the column number, or -1 for unknown

ParseException

public ParseException(int type,
                      java.lang.String info,
                      java.util.ArrayList details,
                      int line,
                      int column)
Creates a new parse exception. This constructor is only used to supply the detailed information array, which is only used for expected token errors. The list then contains descriptions of the expected tokens.

Parameters:
type - the parse error type
info - the additional information
details - the additional detailed information
line - the line number, or -1 for unknown
column - the column number, or -1 for unknown
Method Detail

getErrorType

public int getErrorType()
Returns the error type.

Returns:
the error type

getInfo

public java.lang.String getInfo()
Returns the additional error information.

Returns:
the additional error information

getDetails

public java.util.ArrayList getDetails()
Returns the additional detailed error information.

Returns:
the additional detailed error information

getLine

public int getLine()
Returns the line number where the error occured.

Returns:
the line number of the error, or -1 if unknown

getColumn

public int getColumn()
Returns the column number where the error occured.

Returns:
the column number of the error, or -1 if unknown

getMessage

public java.lang.String getMessage()
Returns a default error message.

Overrides:
getMessage in class java.lang.Throwable
Returns:
a default error message