|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Throwable java.lang.Exception marf.util.MARFException marf.nlp.NLPException marf.nlp.Parsing.CompilerError marf.nlp.Parsing.SyntaxError
public class SyntaxError
Represents a Syntax Error.
$Id: SyntaxError.java,v 1.21 2008/01/03 03:21:57 mokhov Exp $
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 |
---|
public static final int ERR_GENERAL_SYNTAX_ERROR
public static final int ERR_MISMATCHED_PARENS
public static final int ERR_NO_PROGRAM
public static final int ERR_MISSING_SEMICOLON
public static final int ERR_CUSTOM
protected Token oFaultingToken
protected static final int POP
protected static final int SCAN
Constructor Detail |
---|
public SyntaxError(int piErrorCode)
piErrorCode
- type of syntax errorpublic SyntaxError(int piErrorCode, Token poFaultingToken)
piErrorCode
- type of syntax errorpoFaultingToken
- the token that caused itpublic SyntaxError(Token poFaultingToken, java.lang.String pstrCustomErrorMessage)
poFaultingToken
- the token that caused the errorpstrCustomErrorMessage
- user-defined error messagepublic SyntaxError(java.lang.String pstrEncodedCode)
pstrEncodedCode
- the string code.public SyntaxError()
super()
.
public SyntaxError(java.lang.Exception poException)
poException
- the exception to wrappublic SyntaxError(java.lang.String pstrMessage, java.lang.Exception poException)
pstrMessage
- the custom error messagepoException
- the exception to wrapMethod Detail |
---|
public void setErrorCode(java.lang.String pstrCode)
pstrCode
- the string code to convert to numericpublic void updateTokenInfo(Token poFaultingToken)
poFaultingToken
- the faulting token that caused the errorpublic void setLineNo(int piLineNo)
piLineNo
- the line number of the errorpublic boolean serialize(int piOperation, java.io.FileWriter poFileWriter)
piOperation
- 0 for load (not implemented), 1 for save as textpoFileWriter
- writer to write the error message to
true
if the operation was successfulpublic boolean isScanRecoveryAction()
true
if the action is SCANSCAN
public boolean isPopRecoveryAction()
true
if the action is POPPOP
public void setScanRecoveryAction()
SCAN
public void setPopRecoveryAction()
POP
public static java.lang.String getMARFSourceCodeRevision()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |