00001 /* 00002 Copyright 1996-2001 00003 Simon Whiteside 00004 00005 $Id: skParseException_h-source.html,v 1.17 2001/07/05 09:56:08 sdw Exp $ 00006 */ 00007 #ifndef SKPARSEEXCEPTION_H 00008 #define SKPARSEEXCEPTION_H 00009 00010 #include "skString.h" 00011 #include "skValist.h" 00012 00016 class skCompileError 00017 { 00018 public: 00022 skCompileError() 00023 : m_LineNum(0){ 00024 } 00028 skCompileError(skString location,int line_num,const skString& msg,const skString& lex_buffer) 00029 : m_Location(location),m_LineNum(line_num),m_Msg(msg),m_LexBuffer(lex_buffer){ 00030 } 00034 skString location() const{ 00035 return m_Location; 00036 } 00040 int lineNum() const{ 00041 return m_LineNum; 00042 } 00046 skString msg() const{ 00047 return m_Msg; 00048 } 00052 skString lexBuffer() const{ 00053 return m_LexBuffer; 00054 } 00058 skString toString() const { 00059 return m_Location+skSTR(":")+skString::from(m_LineNum)+skSTR(":")+m_Msg+skSTR(" near \"")+m_LexBuffer+skSTR("\""); 00060 } 00061 private: 00062 int m_LineNum; 00063 skString m_Location; 00064 skString m_LexBuffer; 00065 skString m_Msg; 00066 }; 00070 class skCompileErrorList : public skTVAList<skCompileError> 00071 { 00072 }; 00076 class skParseException { 00077 public: 00081 skParseException(const skCompileErrorList& errors) : m_Errors(errors) { 00082 } 00086 const skCompileErrorList& getErrors() const{ 00087 return m_Errors; 00088 } 00092 skString toString() const { 00093 skString ret; 00094 for (unsigned int i=0;i<m_Errors.entries();i++) 00095 ret+=m_Errors[i].toString()+skSTR("\n"); 00096 return ret; 00097 } 00098 private: 00099 skCompileErrorList m_Errors; 00100 }; 00101 00102 #endif