marf.nlp.Parsing
Class SyntaxError

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by marf.util.MARFException
              extended by marf.nlp.NLPException
                  extended by marf.nlp.Parsing.CompilerError
                      extended by marf.nlp.Parsing.SyntaxError
All Implemented Interfaces:
java.io.Serializable, IMARFException

public class SyntaxError
extends CompilerError

Represents a Syntax Error.

$Id: SyntaxError.java,v 1.21 2008/01/03 03:21:57 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.21 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
static int ERR_CUSTOM
          Custom error message as alternative to 'unknown'.
static int ERR_GENERAL_SYNTAX_ERROR
          General Syntax Error.
static int ERR_MISMATCHED_PARENS
          Mismatched Parenthesis Error.
static int ERR_MISSING_SEMICOLON
          Unterminated statement or declaration.
static int ERR_NO_PROGRAM
          No "main()" program Error.
protected  Token oFaultingToken
          Token information at which Parser encountered the error.
protected static int POP
          Recovery action code, specifying that to recover from an error one needs to pop tokens from the stack.
protected static int SCAN
          Recovery action code specifying that one needs to keep scanning to recover.
 
Fields inherited from class marf.nlp.Parsing.CompilerError
iCurrentErrorCode, iLineNo, OK
 
Fields inherited from class marf.util.MARFException
strMessage
 
Constructor Summary
SyntaxError()
          Default constructor that merely calls super().
SyntaxError(java.lang.Exception poException)
          Constructs SyntaxError with wrapped Exception object.
SyntaxError(int piErrorCode)
          Constructor with the error code.
SyntaxError(int piErrorCode, Token poFaultingToken)
          Constructor with the error code and its cause.
SyntaxError(java.lang.String pstrEncodedCode)
          Constructs a syntax error with the encoded code.
SyntaxError(java.lang.String pstrMessage, java.lang.Exception poException)
          Constructs SyntaxError with wrapped Exception object and a custom error message.
SyntaxError(Token poFaultingToken, java.lang.String pstrCustomErrorMessage)
          Constructor 2 - an alternative to Unknown Error.
 
Method Summary
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 boolean isPopRecoveryAction()
          Checks whether the recovery action to follow this syntax error is to "pop last token from the stack".
 boolean isScanRecoveryAction()
          Checks whether the recovery action to follow this syntax error is to "keep scanning".
 boolean serialize(int piOperation, java.io.FileWriter poFileWriter)
          Serialization routine.
 void setErrorCode(java.lang.String pstrCode)
          Sets error code given its string representation (as in token's lexeme).
 void setLineNo(int piLineNo)
          Updates location.
 void setPopRecoveryAction()
          Sets current error recovery action to SCAN.
 void setScanRecoveryAction()
          Sets current error recovery action to SCAN.
 void updateTokenInfo(Token poFaultingToken)
          Allows updating the state of an error, since the info might not be initially available (as in the TT, for example).
 
Methods inherited from class marf.nlp.Parsing.CompilerError
getCurrentErrorCode, getLineNo
 
Methods inherited from class marf.util.MARFException
create, create, create, create, getMessage, toString
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERR_GENERAL_SYNTAX_ERROR

public static final int ERR_GENERAL_SYNTAX_ERROR
General Syntax Error.

See Also:
Constant Field Values

ERR_MISMATCHED_PARENS

public static final int ERR_MISMATCHED_PARENS
Mismatched Parenthesis Error.

See Also:
Constant Field Values

ERR_NO_PROGRAM

public static final int ERR_NO_PROGRAM
No "main()" program Error.

See Also:
Constant Field Values

ERR_MISSING_SEMICOLON

public static final int ERR_MISSING_SEMICOLON
Unterminated statement or declaration.

See Also:
Constant Field Values

ERR_CUSTOM

public static final int ERR_CUSTOM
Custom error message as alternative to 'unknown'.

See Also:
Constant Field Values

oFaultingToken

protected Token oFaultingToken
Token information at which Parser encountered the error.

Since:
October 2, 2001

POP

protected static final int POP
Recovery action code, specifying that to recover from an error one needs to pop tokens from the stack.

See Also:
Constant Field Values

SCAN

protected static final int SCAN
Recovery action code specifying that one needs to keep scanning to recover.

See Also:
Constant Field Values
Constructor Detail

SyntaxError

public SyntaxError(int piErrorCode)
Constructor with the error code.

Parameters:
piErrorCode - type of syntax error

SyntaxError

public SyntaxError(int piErrorCode,
                   Token poFaultingToken)
Constructor with the error code and its cause.

Parameters:
piErrorCode - type of syntax error
poFaultingToken - the token that caused it

SyntaxError

public SyntaxError(Token poFaultingToken,
                   java.lang.String pstrCustomErrorMessage)
Constructor 2 - an alternative to Unknown Error.

Parameters:
poFaultingToken - the token that caused the error
pstrCustomErrorMessage - user-defined error message

SyntaxError

public SyntaxError(java.lang.String pstrEncodedCode)
Constructs a syntax error with the encoded code.

Parameters:
pstrEncodedCode - the string code.

SyntaxError

public SyntaxError()
Default constructor that merely calls super().

Since:
0.3.0.5

SyntaxError

public SyntaxError(java.lang.Exception poException)
Constructs SyntaxError with wrapped Exception object.

Parameters:
poException - the exception to wrap
Since:
0.3.0.5

SyntaxError

public SyntaxError(java.lang.String pstrMessage,
                   java.lang.Exception poException)
Constructs SyntaxError with wrapped Exception object and a custom error message.

Parameters:
pstrMessage - the custom error message
poException - the exception to wrap
Since:
0.3.0.5
Method Detail

setErrorCode

public void setErrorCode(java.lang.String pstrCode)
Sets error code given its string representation (as in token's lexeme).

Parameters:
pstrCode - the string code to convert to numeric

updateTokenInfo

public void updateTokenInfo(Token poFaultingToken)
Allows updating the state of an error, since the info might not be initially available (as in the TT, for example).

Parameters:
poFaultingToken - the faulting token that caused the error

setLineNo

public void setLineNo(int piLineNo)
Updates location.

Parameters:
piLineNo - the line number of the error

serialize

public boolean serialize(int piOperation,
                         java.io.FileWriter poFileWriter)
Serialization routine. TODO: migrate to MARF dump/restore mechanism.

Parameters:
piOperation - 0 for load (not implemented), 1 for save as text
poFileWriter - writer to write the error message to
Returns:
true if the operation was successful

isScanRecoveryAction

public boolean isScanRecoveryAction()
Checks whether the recovery action to follow this syntax error is to "keep scanning".

Returns:
true if the action is SCAN
See Also:
SCAN

isPopRecoveryAction

public boolean isPopRecoveryAction()
Checks whether the recovery action to follow this syntax error is to "pop last token from the stack".

Returns:
true if the action is POP
See Also:
POP

setScanRecoveryAction

public void setScanRecoveryAction()
Sets current error recovery action to SCAN.

See Also:
SCAN

setPopRecoveryAction

public void setPopRecoveryAction()
Sets current error recovery action to SCAN.

See Also:
POP

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Retrieves class' revision.

Returns:
revision string


SourceForge Logo